:root {
  --bg-primary: #0a0b10;
  --bg-secondary: #12141c;
  --bg-sidebar: #171923;
  --bg-card: rgba(26, 29, 41, 0.6);
  --border-color: rgba(255, 255, 255, 0.08);
  
  --accent-primary: #6366f1;
  --accent-primary-hover: #4f46e5;
  --accent-secondary: #06b6d4;
  --accent-success: #10b981;
  --accent-purple: #a855f7;
  
  --text-main: #f3f4f6;
  --text-muted: #9ca3af;
  --text-dark: #6b7280;
  
  --font-sans: 'Outfit', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  
  --glow-shadow: 0 0 20px rgba(99, 102, 241, 0.25);
  --card-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
}

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

html, body {
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
  /* Prevent overscroll bounce on iOS */
  overscroll-behavior-y: none;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-primary);
  color: var(--text-main);
  /* Use 100% instead of 100dvh to avoid Android navigation bar overlap */
  height: 100%;
}

/* Scrollbars */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.1);
}
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* App container */
#app {
  display: flex;
  width: 100vw;
  height: 100%;
  position: relative;
  background-image: radial-gradient(circle at 10% 20%, rgba(99, 102, 241, 0.05) 0%, transparent 40%),
                    radial-gradient(circle at 90% 80%, rgba(168, 85, 247, 0.05) 0%, transparent 40%);
  padding-bottom: env(safe-area-inset-bottom);
  padding-top: env(safe-area-inset-top);
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

/* Common screens */
.screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
}

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

/* --- AUTH SCREEN --- */
#auth-screen {
  justify-content: center;
  align-items: center;
  background-color: var(--bg-primary);
}

.auth-card {
  width: 100%;
  max-width: 440px;
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  box-shadow: var(--card-shadow);
  border-radius: 20px;
  padding: 40px;
  text-align: center;
  animation: floatIn 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.logo {
  margin-bottom: 30px;
}

.shield-icon {
  font-size: 4rem;
  display: inline-block;
  margin-bottom: 15px;
  filter: drop-shadow(0 0 10px rgba(99, 102, 241, 0.5));
  animation: pulseShield 2s infinite ease-in-out;
}

.logo h1 {
  font-weight: 700;
  font-size: 2.2rem;
  background: linear-gradient(135deg, #a5b4fc, #c084fc);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 8px;
}

.logo p {
  color: var(--text-muted);
  font-size: 0.95rem;
}

.input-group {
  text-align: left;
  margin-bottom: 24px;
}

.input-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.input-group input {
  width: 100%;
  background-color: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 14px 16px;
  color: var(--text-main);
  font-family: var(--font-sans);
  font-size: 1rem;
  transition: all 0.3s ease;
}

.input-group input:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.btn-primary {
  width: 100%;
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-purple));
  color: white;
  border: none;
  border-radius: 10px;
  padding: 14px;
  font-family: var(--font-sans);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
  display: flex;
  justify-content: center;
  align-items: center;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(99, 102, 241, 0.4);
}

.btn-primary:active {
  transform: translateY(0);
}

.auth-status {
  margin-top: 20px;
  font-size: 0.8rem;
  color: var(--text-dark);
}

/* --- MAIN INTERFACE: CHAT SCREEN --- */
#chat-screen {
  display: grid;
  grid-template-columns: 320px 1fr 340px;
  width: 100%;
  height: 100%;
  transition: grid-template-columns 0.3s ease;
}

#chat-screen.crypto-collapsed {
  grid-template-columns: 320px 1fr 0px;
}

#chat-screen.crypto-collapsed .crypto-panel {
  display: none !important;
}


/* --- SIDEBAR --- */
.sidebar {
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}

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

.user-profile {
  display: flex;
  align-items: center;
  gap: 12px;
}

.avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
  color: white;
  display: flex;
  justify-content: center;
  align-items: center;
  font-weight: 700;
  font-size: 1.2rem;
  text-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.user-info h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 2px;
}

.status-online {
  font-size: 0.75rem;
  color: var(--accent-success);
  display: flex;
  align-items: center;
  gap: 4px;
}

.status-online::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: var(--accent-success);
  box-shadow: 0 0 8px var(--accent-success);
}

.sidebar-tabs {
  display: flex;
  border-bottom: 1px solid var(--border-color);
}

.tab-btn {
  flex: 1;
  background: none;
  border: none;
  padding: 14px 2px;
  font-family: var(--font-sans);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.3s ease;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tab-btn:hover {
  color: var(--text-main);
  background-color: rgba(255,255,255,0.02);
}

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

.tab-badge {
  background: var(--accent-primary);
  color: white;
  font-size: 0.65rem;
  padding: 2px 6px;
  border-radius: 10px;
  margin-left: 4px;
  vertical-align: middle;
  display: inline-block;
  line-height: 1;
}

.sidebar-content {
  flex: 1;
  overflow-y: auto;
  position: relative;
  min-height: 0;
}

.list-container {
  display: none;
  padding: 12px;
}

.list-container.active {
  display: block;
}

.list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-bottom: 4px;
  border: 1px solid transparent;
}

.list-item:hover {
  background-color: rgba(255, 255, 255, 0.04);
}

.list-item.active {
  background-color: rgba(99, 102, 241, 0.15);
  border-color: rgba(99, 102, 241, 0.25);
}

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

.list-item-name {
  font-weight: 500;
  font-size: 0.95rem;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.list-item-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.btn-delete-bridge:hover,
.btn-delete-chat:hover,
.btn-delete-group:hover {
  color: #f87171 !important;
}

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-dark);
  font-size: 0.85rem;
}

.sidebar-actions {
  padding: 16px;
  border-top: 1px solid var(--border-color);
}

.btn-secondary {
  width: 100%;
  background-color: rgba(255, 255, 255, 0.04);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 12px;
  font-family: var(--font-sans);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s ease;
}

.btn-secondary:hover {
  background-color: rgba(255, 255, 255, 0.08);
  border-color: var(--text-muted);
}

/* --- CHAT AREA --- */
.chat-area {
  background-color: var(--bg-secondary);
  display: flex;
  flex-direction: column;
  position: relative;
  height: 100%;
  min-height: 0;
}

.empty-chat-state {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100%;
  width: 100%;
}

.chat-placeholder {
  text-align: center;
  max-width: 400px;
  padding: 20px;
}

.placeholder-icon {
  font-size: 3.5rem;
  display: inline-block;
  margin-bottom: 20px;
  opacity: 0.4;
}

.chat-placeholder h2 {
  font-size: 1.4rem;
  font-weight: 600;
  margin-bottom: 10px;
}

.chat-placeholder p {
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.chat-active-container {
  display: flex;
  flex-direction: column;
  height: 100%;
  width: 100%;
  min-height: 0;
}

.chat-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background-color: rgba(18, 20, 28, 0.8);
  backdrop-filter: blur(8px);
}

.chat-target-info h2 {
  font-size: 1.2rem;
  font-weight: 600;
  margin-bottom: 2px;
}

.chat-subtitle {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.security-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background-color: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.2);
  border-radius: 20px;
  color: var(--accent-success);
  font-size: 0.8rem;
  font-weight: 500;
}

.security-status {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 30px;
  background-color: rgba(99, 102, 241, 0.12);
  border: 1px solid rgba(99, 102, 241, 0.25);
  color: #a5b4fc;
  font-size: 0.8rem;
  font-weight: 500;
}

.messages-stream {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Message Bubbles */
.message-row {
  display: flex;
  width: 100%;
}

.message-row.sent {
  justify-content: flex-end;
}

.message-row.received {
  justify-content: flex-start;
}

.message-bubble {
  max-width: 70%;
  padding: 12px 16px;
  border-radius: 16px;
  font-size: 0.95rem;
  line-height: 1.45;
  position: relative;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

.message-row.sent .message-bubble {
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-purple));
  color: white;
  border-bottom-right-radius: 4px;
}

.message-row.received .message-bubble {
  background-color: var(--bg-sidebar);
  color: var(--text-main);
  border-bottom-left-radius: 4px;
  border: 1px solid var(--border-color);
}

.msg-sender {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--accent-secondary);
  margin-bottom: 4px;
  display: block;
}

.msg-text {
  word-break: break-word;
  white-space: pre-wrap;
}

.msg-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  font-size: 0.7rem;
  color: rgba(255,255,255,0.6);
  margin-top: 6px;
}

.message-row.received .msg-meta {
  color: var(--text-muted);
}

.lock-small {
  font-size: 0.75rem;
}

.chat-input-area {
  padding: 20px 24px;
  background-color: var(--bg-secondary);
  border-top: 1px solid var(--border-color);
}

#message-form {
  display: flex;
  gap: 12px;
}

#message-input {
  flex: 1;
  background-color: rgba(0,0,0,0.25);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 14px 18px;
  color: var(--text-main);
  font-family: var(--font-sans);
  font-size: 0.95rem;
  transition: all 0.3s ease;
}

#message-input:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.btn-send {
  background-color: var(--accent-primary);
  border: none;
  border-radius: 12px;
  width: 50px;
  height: 50px;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 1.2rem;
}

.btn-send:hover {
  background-color: var(--accent-primary-hover);
  transform: scale(1.03);
}

.btn-attach {
  background-color: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  width: 50px;
  height: 50px;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 1.2rem;
  color: var(--text-main);
}

.btn-attach:hover {
  background-color: rgba(255, 255, 255, 0.08);
  border-color: var(--text-muted);
  transform: scale(1.03);
}

/* --- CRYPTO DASHBOARD --- */
.crypto-panel {
  background-color: var(--bg-sidebar);
  border-left: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.panel-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.panel-header h3 {
  font-size: 1rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.badge {
  background-color: rgba(99, 102, 241, 0.15);
  border: 1px solid rgba(99, 102, 241, 0.3);
  color: #a5b4fc;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-family: var(--font-mono);
  font-weight: 500;
}

.panel-content {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.crypto-card {
  background-color: rgba(0, 0, 0, 0.15);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  padding: 16px;
}

.crypto-card h4 {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-main);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.crypto-key-item {
  margin-bottom: 12px;
}

.crypto-key-item:last-child {
  margin-bottom: 0;
}

.key-label {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.key-value {
  background-color: rgba(0,0,0,0.3);
  border: 1px solid rgba(255,255,255,0.03);
  border-radius: 6px;
  padding: 8px 10px;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--accent-secondary);
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 80px;
}

.fingerprint-display {
  display: flex;
  justify-content: center;
  align-items: center;
  background-color: rgba(99, 102, 241, 0.1);
  border: 1px dotted rgba(99, 102, 241, 0.3);
  border-radius: 6px;
  padding: 10px;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: #a5b4fc;
  font-weight: 600;
  letter-spacing: 0.05em;
}

/* --- MODAL --- */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  display: flex;
  justify-content: center;
  align-items: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  z-index: 100;
}

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

.modal {
  width: 100%;
  max-width: 480px;
  background-color: var(--bg-sidebar);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  padding: 30px;
  box-shadow: var(--card-shadow);
  transform: scale(0.9);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-overlay.active .modal {
  transform: scale(1);
}

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

.modal-header h3 {
  font-size: 1.2rem;
  font-weight: 600;
}

.close-modal {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  transition: color 0.2s ease;
}

.close-modal:hover {
  color: var(--text-main);
}

.member-checkbox-list {
  background-color: rgba(0,0,0,0.2);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  max-height: 180px;
  overflow-y: auto;
  padding: 8px;
}

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

.member-checkbox-item:hover {
  background-color: rgba(255,255,255,0.03);
}

.member-checkbox-item input {
  width: 18px;
  height: 18px;
  cursor: pointer;
}

.member-checkbox-item label {
  cursor: pointer;
  font-size: 0.95rem;
  flex: 1;
}

/* Utilities */
.hidden {
  display: none !important;
}

/* Animations */
@keyframes floatIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes pulseShield {
  0%, 100% {
    transform: scale(1);
    filter: drop-shadow(0 0 10px rgba(99, 102, 241, 0.4));
  }
  50% {
    transform: scale(1.05);
    filter: drop-shadow(0 0 20px rgba(99, 102, 241, 0.7));
  }
}

.spinner {
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top: 2px solid white;
  border-radius: 50%;
  width: 18px;
  height: 18px;
  animation: spin 0.8s linear infinite;
  display: inline-block;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

@keyframes pulse {
  0% {
    transform: scale(1.1);
    filter: drop-shadow(0 0 2px rgba(239, 68, 68, 0.4));
  }
  50% {
    transform: scale(1.3);
    filter: drop-shadow(0 0 10px rgba(239, 68, 68, 0.8));
  }
  100% {
    transform: scale(1.1);
    filter: drop-shadow(0 0 2px rgba(239, 68, 68, 0.4));
  }
}


/* Custom premium select styling for self-destruct timer */
.select-timer {
  background-color: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  color: var(--text-main);
  padding: 0 10px;
  font-family: var(--font-sans);
  font-size: 0.9rem;
  cursor: pointer;
  outline: none;
  transition: all 0.3s ease;
}
.select-timer:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}
select {
  background-color: #ffffff !important;
  color: #000000 !important;
  border: 1px solid var(--border-color);
  padding-right: 24px;
}

select option {
  background-color: #ffffff !important;
  color: #000000 !important;
}

/* Emoji fingerprint display styling */
.emoji-fingerprint-display {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  background-color: rgba(168, 85, 247, 0.1);
  border: 1px dashed rgba(168, 85, 247, 0.3);
  border-radius: 6px;
  padding: 10px;
  font-size: 1.5rem;
}

/* self-destruct timer badge on messages */
.msg-self-destruct-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 0.7rem;
  background-color: rgba(239, 68, 68, 0.15);
  color: #f87171;
  padding: 2px 6px;
  border-radius: 4px;
  margin-top: 4px;
}

/* prevent selecting text in secure mode */
.messages-stream {
  user-select: none;
  -webkit-user-select: none;
}

/* Telegram Channel Card Layout */
.message-row.tg-channel-row {
  justify-content: center;
}

.message-bubble.tg-channel-card {
  width: 100%;
  max-width: 640px; /* Max width for readability, matches telegram layout */
  background-color: var(--bg-sidebar);
  border: 1px solid var(--border-color);
  border-radius: 12px !important;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
  padding: 16px;
  box-sizing: border-box;
}

/* Telegram specific links styling */
.message-bubble.tg-channel-card a {
  color: #38bdf8 !important; /* light sky blue */
  text-decoration: none !important;
}

.message-bubble.tg-channel-card a:hover {
  text-decoration: underline !important;
  color: #7dd3fc !important;
}

/* Views and plane meta */
.message-bubble.tg-channel-card .msg-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 8px;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.message-bubble.tg-channel-card .tg-views {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  opacity: 0.85;
}

.message-bubble.tg-channel-card .tg-icon-plane {
  opacity: 0.7;
}

/* Telegram Image styling inside cards */
.message-bubble.tg-channel-card .tg-image-container {
  margin: -16px -16px 12px -16px !important; /* negative margin to span border-to-border */
  border-radius: 11px 11px 0 0 !important;
  overflow: hidden;
  border: none !important;
  background: rgba(0, 0, 0, 0.2);
}

.message-bubble.tg-channel-card .tg-image-container img {
  width: 100% !important;
  max-width: 100% !important;
  max-height: 380px !important;
  object-fit: cover !important;
}

/* Voice playback and recording button styles */
.btn-voice-play-pause:hover {
  transform: scale(1.1);
  filter: drop-shadow(0 0 8px rgba(139, 92, 246, 0.7)) !important;
}
.btn-mic:hover {
  color: #ef4444 !important;
  transform: scale(1.1);
}
.btn-cancel-rec:hover {
  transform: scale(1.2);
}

/* Join Requests Banner */
.join-requests-banner {
  animation: bannerIn 0.25s ease;
}

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

/* Sidebar actions two-row layout */
.sidebar-actions {
  flex-shrink: 0;
}

/* --- SETTINGS PANEL STYLING --- */
.settings-group {
  background: rgba(0, 0, 0, 0.15);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 14px;
}
.settings-group-title {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent-primary);
  margin-bottom: 12px;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 6px;
}
.settings-item {
  margin-bottom: 10px;
}
.settings-item:last-child {
  margin-bottom: 0;
}
.settings-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  display: block;
  margin-bottom: 4px;
}
.settings-value {
  font-size: 0.9rem;
  color: var(--text-main);
  font-weight: 500;
}

/* Custom switch toggle */
.switch-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(255, 255, 255, 0.1);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  transition: .3s;
}
.switch-toggle input:checked + .switch-slider {
  background-color: #10b981; /* Green */
  border-color: #10b981;
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.6);
}
.switch-slider:before {
  position: absolute;
  content: "";
  height: 14px;
  width: 14px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .3s;
  border-radius: 50%;
}
.switch-toggle input:checked + .switch-slider:before {
  transform: translateX(22px);
}

/* Device Item in active sessions */
.settings-device-item {
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.device-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.device-item-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.device-item-badge {
  font-size: 0.65rem;
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid var(--accent-success);
  color: var(--accent-success);
  padding: 1px 5px;
  border-radius: 10px;
  font-weight: 600;
}
.device-item-meta {
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* --- THEME OVERRIDES --- */
/* Light Mint Theme */
body.theme-light-mint {
  --bg-primary: #f0fdf4;
  --bg-secondary: #ffffff;
  --bg-sidebar: #f1f5f9;
  --bg-card: rgba(255, 255, 255, 0.9);
  --border-color: rgba(0, 0, 0, 0.08);
  
  --accent-primary: #059669;
  --accent-primary-hover: #047857;
  --accent-secondary: #0d9488;
  --accent-purple: #7c3aed;
  --accent-success: #059669;
  
  --text-main: #1f2937;
  --text-muted: #4b5563;
  --text-dark: #9ca3af;
  --glow-shadow: 0 0 20px rgba(5, 150, 105, 0.15);
}
body.theme-light-mint .sidebar,
body.theme-light-mint .chat-header,
body.theme-light-mint .chat-input-area,
body.theme-light-mint .crypto-panel {
  background-color: var(--bg-sidebar);
}
body.theme-light-mint .chat-area {
  background-color: var(--bg-secondary);
}
body.theme-light-mint .list-item:hover,
body.theme-light-mint .btn-secondary:hover {
  background-color: rgba(0, 0, 0, 0.04);
}
body.theme-light-mint .list-item.active {
  background-color: rgba(5, 150, 105, 0.12);
  border-color: rgba(5, 150, 105, 0.25);
}
body.theme-light-mint .message-row.received .message-bubble {
  background-color: #f1f5f9;
  color: #1f2937;
}

/* Amoled Black Theme */
body.theme-amoled-black {
  --bg-primary: #000000;
  --bg-secondary: #000000;
  --bg-sidebar: #000000;
  --bg-card: rgba(10, 10, 10, 0.95);
  --border-color: rgba(255, 255, 255, 0.12);
  
  --accent-primary: #a855f7;
  --accent-primary-hover: #9333ea;
  --accent-secondary: #06b6d4;
  --text-main: #ffffff;
  --text-muted: #8e8e93;
  --text-dark: #48484a;
  --glow-shadow: 0 0 20px rgba(168, 85, 247, 0.25);
}
body.theme-amoled-black .sidebar,
body.theme-amoled-black .chat-header,
body.theme-amoled-black .chat-input-area,
body.theme-amoled-black .crypto-panel {
  background-color: #000000;
}
body.theme-amoled-black .list-item:hover,
body.theme-amoled-black .btn-secondary:hover {
  background-color: rgba(255, 255, 255, 0.06);
}
body.theme-amoled-black .list-item.active {
  background-color: rgba(168, 85, 247, 0.2);
  border-color: rgba(168, 85, 247, 0.35);
}

/* Classic Blue Theme */
body.theme-classic-blue {
  --bg-primary: #0b132b;
  --bg-secondary: #1c2541;
  --bg-sidebar: #0b132b;
  --bg-card: rgba(28, 37, 65, 0.9);
  --border-color: rgba(255, 255, 255, 0.08);
  
  --accent-primary: #3b82f6;
  --accent-primary-hover: #2563eb;
  --accent-secondary: #00b4d8;
  --accent-purple: #8338ec;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dark: #475569;
  --glow-shadow: 0 0 20px rgba(59, 130, 246, 0.25);
}
body.theme-classic-blue .sidebar,
body.theme-classic-blue .chat-header,
body.theme-classic-blue .chat-input-area,
body.theme-classic-blue .crypto-panel {
  background-color: var(--bg-sidebar);
}
body.theme-classic-blue .list-item.active {
  background-color: rgba(59, 130, 246, 0.2);
  border-color: rgba(59, 130, 246, 0.35);
}

/* --- RECONNECTION BANNER & NETWORK FALLBACK --- */
.reconnection-banner {
  position: absolute;
  bottom: 90px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 18px;
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.3);
  backdrop-filter: blur(12px);
  border-radius: 30px;
  color: #fca5a5;
  font-size: 0.85rem;
  font-weight: 500;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  pointer-events: none;
  animation: slideDown 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.reconnection-banner.hidden {
  display: none !important;
}

.spinner-small {
  border: 2px solid rgba(252, 165, 165, 0.3);
  border-top: 2px solid #fca5a5;
  border-radius: 50%;
  width: 14px;
  height: 14px;
  animation: spin 0.8s linear infinite;
  display: inline-block;
}

@keyframes slideDown {
  from {
    transform: translate(-50%, -20px);
    opacity: 0;
  }
  to {
    transform: translate(-50%, 0);
    opacity: 1;
  }
}

.btn-settings-icon {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 8px;
  position: relative;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-settings-icon:hover {
  color: var(--text-main);
  background-color: rgba(255, 255, 255, 0.05);
}

.btn-settings-icon.active {
  color: var(--accent-primary);
  background-color: rgba(255, 255, 255, 0.08);
  transform: rotate(45deg);
}

/* Message Delete Button styling */
.message-bubble {
  position: relative;
}

.btn-msg-delete {
  position: absolute;
  top: 4px;
  right: 6px;
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.4);
  font-size: 0.8rem;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s ease, color 0.2s ease;
  padding: 2px;
  line-height: 1;
  border-radius: 4px;
}

.message-row.received .btn-msg-delete {
  color: var(--text-muted);
}

.message-bubble:hover .btn-msg-delete {
  opacity: 1;
}

.btn-msg-delete:hover {
  color: #ef4444 !important;
  background-color: rgba(239, 68, 68, 0.1);
}

.btn-msg-react {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: var(--bg-sidebar);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  font-size: 1.1rem;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  box-shadow: 0 4px 10px rgba(0,0,0,0.15);
  z-index: 10;
}

.message-row.sent .btn-msg-react {
  left: -42px;
  right: auto;
}

.message-row.received .btn-msg-react {
  right: -42px;
  left: auto;
}

.message-bubble:hover .btn-msg-react {
  opacity: 1;
}

.btn-msg-react:hover {
  transform: translateY(-50%) scale(1.15);
  box-shadow: 0 6px 14px rgba(0,0,0,0.25);
}

.reaction-picker-popup {
  position: absolute;
  z-index: 1200;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  padding: 6px 12px;
  display: flex;
  gap: 8px;
  box-shadow: 0 4px 15px rgba(0,0,0,0.5);
  animation: scaleIn 0.15s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.reaction-picker-emoji {
  font-size: 1.15rem;
  cursor: pointer;
  transition: transform 0.2s ease;
  user-select: none;
}

.reaction-picker-emoji:hover {
  transform: scale(1.3);
}

.reaction-badge {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.04);
  padding: 2px 6px;
  border-radius: 10px;
  font-size: 0.72rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  user-select: none;
  transition: all 0.2s ease;
}

.reaction-badge:hover {
  background: rgba(255,255,255,0.12);
  border-color: rgba(255,255,255,0.08);
}


@keyframes scaleIn {
  from {
    transform: scale(0.9);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

/* Delete Message Modal styling */
.delete-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  font-family: var(--font-sans);
}

.delete-modal-content {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 24px;
  width: 90%;
  max-width: 360px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
  animation: scaleIn 0.18s cubic-bezier(0.34, 1.56, 0.64, 1);
  color: var(--text-main);
  text-align: center;
}

.delete-modal-content h3 {
  margin-top: 0;
  margin-bottom: 12px;
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-main);
}

.delete-modal-content p {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 24px;
  line-height: 1.45;
}

.delete-modal-btn {
  width: 100%;
  padding: 12px;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 10px;
  cursor: pointer;
  transition: background-color 0.2s ease, transform 0.1s ease;
  border: none;
  outline: none;
}

.delete-modal-btn:active {
  transform: scale(0.98);
}

.delete-modal-btn-me {
  background-color: rgba(120, 120, 120, 0.1);
  border: 1px solid var(--border-color);
  color: var(--text-main);
}

.delete-modal-btn-me:hover {
  background-color: rgba(120, 120, 120, 0.18);
}

.delete-modal-btn-everyone {
  background-color: #ef4444;
  color: white;
}

.delete-modal-btn-everyone:hover {
  background-color: #dc2626;
}

.delete-modal-btn-cancel {
  background: none;
  color: var(--text-muted);
  font-weight: 500;
  margin-bottom: 0;
}
/* --- MOBILE RESPONSIVENESS --- */
@media (max-width: 800px) {
  /* Auth screen: must scroll on small screens */
  #auth-screen {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    align-items: flex-start;
    padding: 10px 0;
    flex-direction: column;
  }
  .auth-card {
    max-width: 100%;
    padding: 16px 14px;
    border-radius: 12px;
    margin: 0 auto;
    width: calc(100% - 20px);
    overflow: hidden;
    word-wrap: break-word;
  }
  .auth-card .logo img {
    width: 50px !important;
    height: 50px !important;
    margin-bottom: 8px !important;
  }
  .auth-card .logo h1 {
    font-size: 1.3rem !important;
  }
  .auth-card .logo p {
    font-size: 0.8rem !important;
  }
  .auth-card .logo {
    margin-bottom: 15px;
  }
  .mnemonic-container {
    font-size: 0.72rem !important;
    padding: 8px !important;
    gap: 4px !important;
  }
  .qr-container {
    width: 140px !important;
    height: 140px !important;
    padding: 6px !important;
  }

  /* Chat screen: block layout with stacked panels */
  #chat-screen {
    display: block;
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    overflow: hidden;
  }
  .sidebar {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    z-index: 10;
    transition: transform 0.3s ease;
  }
  .chat-area {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    z-index: 5;
  }
  .crypto-panel {
    display: none !important;
  }
  
  #chat-screen.mobile-chat-active .sidebar {
    transform: translateX(-100%);
  }
  
  .btn-mobile-back {
    display: block !important;
  }
  
  .chat-header {
    padding: 10px 12px;
    gap: 5px;
  }
  
  #security-badge {
    display: none !important;
  }
  
  .chat-target-info {
    min-width: 0;
    flex: 1;
  }
  
  #chat-title {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 140px;
  }
  
  #call-active-banner {
    padding: 10px !important;
  }
  
  #remote-video {
    width: 100% !important;
    max-height: 50vh !important;
  }
  
  #local-video {
    width: 100px !important;
    height: 75px !important;
    bottom: 10px !important;
    right: 10px !important;
  }
  
  /* Input area compression */
  .chat-input-area {
    padding: 10px 8px !important;
    padding-bottom: max(10px, env(safe-area-inset-bottom, 24px)) !important;
  }
  #message-form {
    gap: 6px !important;
  }
  .btn-send, .btn-attach {
    width: 38px !important;
    height: 38px !important;
    font-size: 1.1rem !important;
    border-radius: 10px !important;
    flex-shrink: 0;
  }
  #message-input {
    padding: 10px 10px !important;
    font-size: 0.9rem !important;
    min-width: 0;
  }
  
  #sidebar-bottom-panel {
    padding-bottom: max(24px, env(safe-area-inset-bottom)) !important;
  }
  .select-timer {
    padding: 0 4px !important;
    font-size: 0.85rem !important;
    max-width: 65px !important;
    flex-shrink: 0;
  }
  .btn-mic {
    font-size: 1.2rem !important;
    padding: 0 4px !important;
    flex-shrink: 0;
  }

  /* Modal adaptation */
  .modal {
    max-width: calc(100vw - 20px) !important;
    max-height: 90vh !important;
    overflow-y: auto !important;
  }
}

.btn-mobile-back {
  display: none;
  background: none;
  border: none;
  color: var(--text-main);
  font-size: 1.4rem;
  margin-right: 12px;
  cursor: pointer;
  padding: 5px;
}
.delete-modal-btn-cancel:hover {
  color: var(--text-main);
}



/* --- DISCOVERY --- */
.discovery-tag {
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.08);
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 5px;
  color: var(--text-main);
}

.discovery-tag:hover {
  background: rgba(255,255,255,0.1);
}

.discovery-tag.selected {
  background: linear-gradient(135deg, var(--accent-purple), var(--accent-secondary));
  border-color: transparent;
  color: white;
  font-weight: 500;
}
