:root {
  --bg: #09090b;
  --bg-elevated: #111114;
  --bg-card: #141418;
  --bg-subtle: #18181d;
  --bg-hover: #1f1f26;
  --bg-active: rgba(16, 185, 129, 0.12);
  --bubble-in: #18181d;
  --bubble-out: #064e3b;
  --bubble-out-border: rgba(16, 185, 129, 0.35);
  --text: #fafafa;
  --text-muted: #a1a1aa;
  --text-dim: #71717a;
  --accent: #10b981;
  --accent-strong: #059669;
  --accent-glow: rgba(16, 185, 129, 0.2);
  --border: #27272a;
  --border-subtle: #1e1e23;
  --danger: #ef4444;
  --warning: #f59e0b;
  --radius-lg: 14px;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow-lg: 0 20px 50px rgba(0, 0, 0, 0.75);
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'Cascadia Code', Consolas, monospace;
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
}

/* Scrollbars */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: #27272a;
  border-radius: 999px;
}
::-webkit-scrollbar-thumb:hover {
  background: #3f3f46;
}

.hidden {
  display: none !important;
}

/* ============================================================================
   1. ЭКРАН АВТОРИЗАЦИИ ПО QR-КОДУ (PAIRING SCREEN)
   ============================================================================ */
.auth-screen {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background-color: var(--bg);
  background-image:
    radial-gradient(circle at 50% 0%, rgba(16, 185, 129, 0.10), transparent 55%),
    linear-gradient(to right, rgba(255, 255, 255, 0.02) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(255, 255, 255, 0.02) 1px, transparent 1px);
  background-size: 100% 100%, 48px 48px, 48px 48px;
  z-index: 100;
}

.auth-topbar {
  position: absolute;
  top: 24px;
  left: 32px;
  right: 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: var(--text);
}

.brand-icon {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  background: linear-gradient(135deg, #10b981, #047857);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 20px rgba(16, 185, 129, 0.35);
}

.brand-title {
  font-weight: 700;
  font-size: 18px;
  letter-spacing: -0.02em;
}

.brand-tag {
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.35);
  color: var(--accent);
}

.auth-card {
  width: 100%;
  max-width: 900px;
  background: rgba(18, 18, 22, 0.92);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow-lg);
  display: grid;
  grid-template-columns: 1.25fr 1fr;
  overflow: hidden;
}

.auth-info {
  padding: 40px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  border-right: 1px solid var(--border-subtle);
}

.crypto-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: fit-content;
  padding: 5px 12px;
  border-radius: 999px;
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.28);
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 11px;
  margin-bottom: 18px;
}

.auth-info h1 {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 10px;
  line-height: 1.25;
}

.auth-subtitle {
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.55;
  margin-bottom: 26px;
}

.steps-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 28px;
}

.steps-list li {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  font-size: 14px;
  line-height: 1.5;
  color: #e4e4e7;
}

.step-num {
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
}

.auth-footer-controls {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-top: 18px;
  border-top: 1px solid var(--border-subtle);
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--text-muted);
  cursor: pointer;
}

.checkbox-row input {
  accent-color: var(--accent);
  width: 15px;
  height: 15px;
}

.auth-actions-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 4px;
}

.btn-secondary {
  background: var(--bg-subtle);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

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

.auth-qr-pane {
  padding: 40px 32px;
  background: rgba(12, 12, 15, 0.75);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.qr-frame {
  position: relative;
  padding: 16px;
  background: #ffffff;
  border-radius: 16px;
  box-shadow: 0 12px 35px rgba(0, 0, 0, 0.55), 0 0 0 4px rgba(16, 185, 129, 0.22);
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.qr-center-badge {
  position: absolute;
  width: 44px;
  height: 44px;
  border-radius: 11px;
  background: #09090b;
  border: 3px solid #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
  pointer-events: none;
}

.qr-status-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 6px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 10px var(--accent);
  animation: pulseDot 2s infinite;
}

.status-dot.warn {
  background: var(--warning);
  box-shadow: 0 0 10px var(--warning);
}

.status-dot.danger {
  background: var(--danger);
  box-shadow: 0 0 10px var(--danger);
}

@keyframes pulseDot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.45; transform: scale(0.88); }
}

.qr-timer-text {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text-dim);
}

/* ============================================================================
   2. ОСНОВНОЙ ИНТЕРФЕЙС МЕССЕНДЖЕРА (3-COLUMN WORKSPACE)
   ============================================================================ */
.app-workspace {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

/* Top warning banner if phone disconnects */
.relay-banner {
  background: rgba(245, 158, 11, 0.14);
  border-bottom: 1px solid rgba(245, 158, 11, 0.35);
  color: #fbbf24;
  padding: 8px 16px;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.workspace-grid {
  flex: 1;
  display: flex;
  min-height: 0;
  width: 100%;
}

/* 2.1 Left Navigation Rail (64px) */
.nav-rail {
  width: 68px;
  background: var(--bg-elevated);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 16px 0;
  flex-shrink: 0;
}

.rail-top, .rail-bottom {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.self-avatar-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: linear-gradient(135deg, #10b981, #059669);
  color: #052e16;
  font-weight: 700;
  font-size: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  cursor: pointer;
  border: 2px solid rgba(16, 185, 129, 0.45);
  margin-bottom: 8px;
}

.self-avatar-btn .online-ring {
  position: absolute;
  right: -1px;
  bottom: -1px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--bg-elevated);
}

.rail-btn {
  width: 44px;
  height: 44px;
  border-radius: 11px;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  transition: all 0.15s ease;
}

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

.rail-btn.active {
  background: var(--bg-active);
  border-color: rgba(16, 185, 129, 0.35);
  color: var(--accent);
}

.phone-widget {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 8px 6px;
  border-radius: 10px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--accent);
  cursor: pointer;
}

/* 2.2 Middle Column: Conversation List (340px) */
.chat-sidebar {
  width: 350px;
  background: var(--bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.sidebar-header {
  padding: 16px;
  border-bottom: 1px solid var(--border-subtle);
}

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

.sidebar-title-row h2 {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.phone-model-tag {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--accent);
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.25);
  padding: 3px 8px;
  border-radius: 999px;
}

.search-box {
  position: relative;
  display: flex;
  align-items: center;
}

.search-box input {
  width: 100%;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 9px 12px 9px 34px;
  color: var(--text);
  font-size: 13.5px;
  outline: none;
  transition: border-color 0.15s;
}

.search-box input:focus {
  border-color: var(--accent);
}

.search-box svg {
  position: absolute;
  left: 11px;
  color: var(--text-dim);
  pointer-events: none;
}

.folder-tabs {
  display: flex;
  gap: 6px;
  margin-top: 10px;
  overflow-x: auto;
}

.folder-tab {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
}

.folder-tab.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #052e16;
  font-weight: 600;
}

.threads-list {
  flex: 1;
  overflow-y: auto;
  padding: 6px 8px;
}

.thread-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.12s ease;
  margin-bottom: 2px;
}

.thread-item:hover {
  background: var(--bg-subtle);
}

.thread-item.active {
  background: var(--bg-active);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.avatar-circle {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: #27272a;
  color: var(--text);
  font-weight: 600;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
  position: relative;
}

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

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

.thread-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}

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

.thread-time {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
  flex-shrink: 0;
}

.thread-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.thread-snippet {
  font-size: 13px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.unread-badge {
  background: var(--accent);
  color: #052e16;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* 2.3 Right Main Column: Active Conversation */
.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background-color: var(--bg);
  background-image:
    linear-gradient(to right, rgba(255, 255, 255, 0.015) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(255, 255, 255, 0.015) 1px, transparent 1px);
  background-size: 40px 40px;
}

.empty-chat-placeholder {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 32px;
  color: var(--text-muted);
}

.empty-chat-placeholder .shield-circle {
  width: 72px;
  height: 72px;
  border-radius: 20px;
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 18px;
  color: var(--accent);
}

.chat-header {
  height: 66px;
  padding: 0 20px;
  background: rgba(17, 17, 20, 0.88);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.chat-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
}

.chat-header-title {
  font-size: 15.5px;
  font-weight: 600;
}

.chat-header-sub {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

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

.e2ee-pill {
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: var(--accent);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
}

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s;
}

.icon-btn:hover {
  color: var(--text);
  border-color: var(--accent);
}

/* Message Stream */
.messages-viewport {
  flex: 1;
  overflow-y: auto;
  padding: 20px 28px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.date-divider {
  align-self: center;
  margin: 10px 0;
  padding: 4px 12px;
  border-radius: 999px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
}

.msg-row {
  display: flex;
  flex-direction: column;
  max-width: 68%;
  position: relative;
}

.msg-row.incoming {
  align-self: flex-start;
}

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

.msg-bubble {
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 14.2px;
  line-height: 1.5;
  word-wrap: break-word;
  position: relative;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}

.msg-row.incoming .msg-bubble {
  background: var(--bubble-in);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}

.msg-row.outgoing .msg-bubble {
  background: var(--bubble-out);
  border: 1px solid var(--bubble-out-border);
  border-bottom-right-radius: 4px;
}

.msg-sender-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 4px;
}

.msg-quote {
  background: rgba(0, 0, 0, 0.28);
  border-left: 3px solid var(--accent);
  border-radius: 6px;
  padding: 6px 10px;
  margin-bottom: 6px;
  font-size: 12.5px;
  cursor: pointer;
}

.msg-quote-author {
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 2px;
}

.msg-quote-text {
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Signal 8.33+ Spoiler Text */
.spoiler-span {
  background: #3f3f46;
  color: transparent;
  border-radius: 4px;
  padding: 0 4px;
  cursor: pointer;
  user-select: none;
  transition: all 0.2s ease;
}

.spoiler-span.revealed {
  background: rgba(255, 255, 255, 0.08);
  color: inherit;
  user-select: text;
}

/* Attachments inside messages */
.msg-attachments {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 6px;
}

.msg-image-attachment {
  max-width: 320px;
  max-height: 280px;
  border-radius: 10px;
  cursor: zoom-in;
  object-fit: cover;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.msg-file-card {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid rgba(255, 255, 255, 0.12);
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
}

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

.msg-file-name {
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.msg-file-size {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
}

.msg-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 5px;
  margin-top: 4px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: rgba(255, 255, 255, 0.55);
}

.msg-Check {
  color: var(--accent);
  font-weight: 700;
}

/* Hover actions on message (Reply + React) */
.msg-hover-bar {
  position: absolute;
  top: -18px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px 8px;
  display: none;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.55);
  z-index: 30;
}

.msg-hover-bar::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -10px;
  height: 10px;
}

.msg-row.incoming .msg-hover-bar {
  left: 0;
  right: auto;
}

.msg-row.outgoing .msg-hover-bar {
  right: 0;
  left: auto;
}

.msg-row:hover .msg-hover-bar {
  display: flex;
}

.react-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 13px;
  padding: 2px 4px;
  border-radius: 4px;
}

.react-btn:hover {
  background: var(--bg-hover);
}

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

.reaction-pill {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 12px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
}

/* Composer Bar */
.composer-wrap {
  background: var(--bg-elevated);
  border-top: 1px solid var(--border);
  padding: 12px 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.reply-preview-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-subtle);
  border-left: 3px solid var(--accent);
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 12.5px;
}

.composer-row {
  display: flex;
  align-items: flex-end;
  gap: 10px;
}

.composer-input {
  flex: 1;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 14px;
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.45;
  max-height: 130px;
  min-height: 42px;
  resize: none;
  outline: none;
}

.composer-input:focus {
  border-color: var(--accent);
}

.send-btn {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: var(--accent);
  border: none;
  color: #052e16;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform 0.12s ease, background 0.12s ease;
}

.send-btn:hover {
  background: var(--accent-strong);
  color: #ffffff;
  transform: translateY(-1px);
}

/* 2.4 Right Info Drawer (320px) */
.info-drawer {
  width: 310px;
  background: var(--bg-elevated);
  border-left: 1px solid var(--border);
  padding: 24px 18px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  overflow-y: auto;
  flex-shrink: 0;
}

.drawer-profile {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--border-subtle);
}

.drawer-profile .avatar-circle {
  width: 76px;
  height: 76px;
  font-size: 26px;
  margin-bottom: 12px;
}

.info-card {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
}

.info-card-label {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
  text-transform: uppercase;
  margin-bottom: 6px;
}

.fingerprint-grid {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--accent);
  letter-spacing: 0.06em;
  background: rgba(16, 185, 129, 0.08);
  border: 1px solid rgba(16, 185, 129, 0.25);
  border-radius: 8px;
  padding: 10px;
  text-align: center;
}

/* Lightbox Modal */
.lightbox-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.88);
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
}

.lightbox-modal img {
  max-width: 90vw;
  max-height: 88vh;
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
}

/* New Chat Button & Primary Buttons */
.active-chat-container {
  flex: 1;
  width: 100%;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.revoked-notice-banner {
  width: 100%;
  max-width: 900px;
  margin-bottom: 16px;
  padding: 12px 18px;
  border-radius: 12px;
  background: rgba(239, 68, 68, 0.14);
  border: 1px solid rgba(239, 68, 68, 0.42);
  color: #fca5a5;
  font-size: 13.5px;
  font-weight: 600;
  text-align: center;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.new-chat-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 11px;
  border-radius: 8px;
  background: rgba(16, 185, 129, 0.14);
  border: 1px solid rgba(16, 185, 129, 0.35);
  color: var(--emerald-bright, #10b981);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.new-chat-btn:hover {
  background: rgba(16, 185, 129, 0.24);
  border-color: var(--accent);
}

.btn-primary-sm {
  background: var(--accent);
  color: #052e16;
  border: none;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease;
}

.btn-primary-sm:hover {
  background: var(--accent-strong);
  color: #ffffff;
}

.btn-danger-full {
  width: 100%;
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.35);
  padding: 9px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-danger-full:hover {
  background: rgba(239, 68, 68, 0.28);
  color: #ffffff;
}

/* Circular Video Notes ("Кругляшки") */
.msg-bubble.msg-bubble-videonote {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  padding: 2px 0 !important;
}

.msg-bubble.msg-bubble-videonote .msg-sender-name {
  display: inline-block;
  background: rgba(24, 24, 29, 0.88);
  border: 1px solid var(--border);
  padding: 2px 10px;
  border-radius: 999px;
  margin-bottom: 6px;
}

.msg-bubble.msg-bubble-videonote .msg-meta {
  display: inline-flex;
  background: rgba(24, 24, 29, 0.88);
  border: 1px solid var(--border);
  padding: 2px 8px;
  border-radius: 999px;
  margin-top: 4px;
  align-self: flex-end;
}

.msg-videonote-wrap {
  position: relative;
  width: 216px;
  height: 216px;
  border-radius: 50%;
  overflow: hidden;
  border: 3px solid var(--accent);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(16, 185, 129, 0.2);
  background: radial-gradient(circle at 50% 35%, #182229, #090d11);
  cursor: pointer;
  margin: 4px 0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.msg-videonote {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  display: block;
}

.videonote-loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-align: center;
  padding: 16px;
  color: var(--text-muted);
  font-size: 12px;
}

.videonote-spinner {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 3px solid rgba(16, 185, 129, 0.22);
  border-top-color: var(--accent);
  animation: vnSpin 0.9s linear infinite;
}

@keyframes vnSpin {
  to { transform: rotate(360deg); }
}

.videonote-mute-badge {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.72);
  color: #fff;
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
  backdrop-filter: blur(4px);
  pointer-events: none;
  white-space: nowrap;
}

.videonote-recorder-circle {
  width: 240px;
  height: 240px;
  border-radius: 50%;
  overflow: hidden;
  border: 3px solid var(--accent);
  background: #000;
  box-shadow: 0 0 25px rgba(16, 185, 129, 0.25);
}

.videonote-recorder-circle video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1);
}

/* Custom Voice Message Player ("Аудиозаписи") */
.msg-voice-player {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 245px;
  max-width: 310px;
  padding: 6px 8px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.18);
}

.voice-play-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent);
  color: #052e16;
  border: none;
  font-size: 14px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}

.voice-wave-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}

.voice-progress-track {
  width: 100%;
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
  overflow: hidden;
  cursor: pointer;
}

.voice-progress-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  border-radius: 999px;
  transition: width 0.1s linear;
}

.voice-meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.voice-speed-btn {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: var(--text);
  border-radius: 6px;
  padding: 1px 6px;
  font-size: 10.5px;
  font-family: var(--font-mono);
  cursor: pointer;
}

/* Voice Recording Bar & Emoji Popover */
.composer-recording-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 18px;
  background: rgba(239, 68, 68, 0.12);
  border-top: 1px solid rgba(239, 68, 68, 0.3);
}

.rec-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #ef4444;
  box-shadow: 0 0 10px #ef4444;
  animation: pulseDot 1s infinite;
}

.emoji-popover {
  position: absolute;
  bottom: 68px;
  left: 56px;
  width: 288px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px;
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  box-shadow: var(--shadow-lg);
  z-index: 200;
}

.emoji-item {
  background: transparent;
  border: none;
  font-size: 20px;
  padding: 5px;
  border-radius: 6px;
  cursor: pointer;
}

.emoji-item:hover {
  background: var(--bg-hover);
}

/* Info Drawer Extras */
.drawer-about {
  margin-top: 8px;
  font-size: 12.5px;
  color: var(--text-muted);
  line-height: 1.45;
  padding: 6px 10px;
  background: var(--bg-subtle);
  border-radius: 8px;
  max-width: 100%;
}

.drawer-actions-row {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.drawer-members-list, .drawer-media-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 260px;
  overflow-y: auto;
  margin-top: 8px;
}

.member-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.12s ease;
}

.member-row:hover {
  background: var(--bg-hover);
}

/* Modals (Phone Status, New Chat, Video Note, Stories) */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 450;
  padding: 16px;
}

.modal-card {
  width: 100%;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

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

.modal-body {
  padding: 18px;
}

.modal-input {
  flex: 1;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 12px;
  color: var(--text);
  font-size: 13.5px;
  outline: none;
}

.modal-input:focus {
  border-color: var(--accent);
}

.phone-status-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.phone-stat-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 12px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  font-size: 13px;
}

.phone-stat-label {
  color: var(--text-muted);
}

.modal-contacts-list {
  max-height: 290px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* Story Viewer Modal */
.story-viewer-card {
  width: 100%;
  max-width: 440px;
  height: 82vh;
  max-height: 720px;
  background: #090d12;
  border: 1px solid var(--border);
  border-radius: 18px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}

.story-viewer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: rgba(0, 0, 0, 0.55);
  border-bottom: 1px solid var(--border-subtle);
}

.story-content-stage {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  padding: 16px;
  text-align: center;
}

.story-content-stage img, .story-content-stage video {
  max-width: 100%;
  max-height: 100%;
  border-radius: 10px;
  object-fit: contain;
}

.story-reply-bar {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  background: var(--bg-elevated);
  border-top: 1px solid var(--border-subtle);
}

@media (max-width: 860px) {
  .auth-card {
    grid-template-columns: 1fr;
    max-height: 92vh;
    overflow-y: auto;
  }
  .auth-info {
    border-right: none;
    border-bottom: 1px solid var(--border-subtle);
    padding: 24px;
  }
  .chat-sidebar {
    width: 280px;
  }
  .info-drawer {
    display: none;
  }
}
