/* ==========================================================================
   STEALTH SECURE CHAT - DESIGN SYSTEM
   Dark Void Cyber Aesthetic | Glassmorphism | Military-Grade Encryption UI
   ========================================================================== */

:root {
  --bg-primary: #07090e;
  --bg-secondary: #0d111a;
  --bg-card: rgba(16, 22, 34, 0.75);
  --bg-card-hover: rgba(22, 30, 46, 0.85);
  --border-color: rgba(255, 255, 255, 0.08);
  --border-glow: rgba(16, 185, 129, 0.3);

  --accent-emerald: #10b981;
  --accent-emerald-glow: rgba(16, 185, 129, 0.25);
  --accent-cyan: #06b6d4;
  --accent-amber: #f59e0b;
  --accent-crimson: #ef4444;
  --accent-crimson-glow: rgba(239, 68, 68, 0.3);

  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --text-dim: #64748b;

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-display: 'Outfit', var(--font-sans);
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

  --shadow-lg: 0 10px 30px -10px rgba(0, 0, 0, 0.7);
  --shadow-glow: 0 0 25px rgba(16, 185, 129, 0.2);
  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-primary);
  color: var(--text-main);
  min-height: 100vh;
  min-height: -webkit-fill-available;
  min-height: 100dvh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background-image: 
    radial-gradient(circle at 15% 15%, rgba(16, 185, 129, 0.05) 0%, transparent 40%),
    radial-gradient(circle at 85% 85%, rgba(6, 182, 212, 0.05) 0%, transparent 40%);
}

/* Scrollbars */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 999px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--accent-emerald);
}

/* Container */
.app-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
  position: relative;
  overflow: hidden;
}

/* ==========================================================================
   TOP SECURE HEADER
   ========================================================================== */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-color);
  z-index: 50;
}

.brand-wrapper {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-icon {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.2), rgba(6, 182, 212, 0.2));
  border: 1px solid var(--accent-emerald);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-emerald);
  font-size: 18px;
  box-shadow: 0 0 15px var(--accent-emerald-glow);
}

.brand-title {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-badge {
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(16, 185, 129, 0.15);
  color: var(--accent-emerald);
  border: 1px solid rgba(16, 185, 129, 0.3);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* Active Chat Header Info Group */
.chat-header-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-back-btn {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-main);
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
}

.header-back-btn:hover {
  background: rgba(239, 68, 68, 0.2);
  border-color: var(--accent-crimson);
  color: #fca5a5;
}

.chat-title-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.chat-room-title {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.01em;
}

.chat-peer-btn {
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.25);
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 0.72rem;
  color: #34d399;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  transition: var(--transition);
  font-family: var(--font-sans);
}

.chat-peer-btn:hover {
  background: rgba(16, 185, 129, 0.22);
  border-color: var(--accent-emerald);
  transform: translateY(-1px);
}

.chat-peer-status {
  font-size: 0.72rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 5px;
}

.status-indicator-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-emerald);
  box-shadow: 0 0 6px var(--accent-emerald);
}

.header-status-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* ==========================================================================
   SYMBOL DOCK & INTERACTIVE MINIMALIST CONTROLS
   ========================================================================== */
.symbol-dock {
  display: inline-flex;
  align-items: center;
  background: rgba(16, 22, 34, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.09);
  padding: 4px 6px;
  border-radius: 999px;
  gap: 4px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.actions-dock {
  background: rgba(22, 30, 46, 0.7);
  border-color: rgba(255, 255, 255, 0.08);
}

.dock-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  transition: all 0.18s cubic-bezier(0.4, 0, 0.2, 1);
  outline: none;
  user-select: none;
}

.dock-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.14);
  color: var(--text-main);
  transform: translateY(-1.5px);
}

.dock-btn:active, .dock-btn.active {
  background: rgba(16, 185, 129, 0.15);
  border-color: var(--accent-emerald);
  color: var(--accent-emerald);
  transform: translateY(0);
}

.dock-btn.danger:hover {
  background: rgba(239, 68, 68, 0.15);
  border-color: rgba(239, 68, 68, 0.4);
  color: #f87171;
}

.dock-btn.fingerprint-btn {
  width: auto;
  border-radius: 999px;
  padding: 0 10px;
  gap: 6px;
}

.fp-mini-text {
  font-size: 0.8rem;
  letter-spacing: 2px;
  font-family: var(--font-mono);
}

.dock-dot {
  position: absolute;
  top: 7px;
  right: 7px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-dim);
}

.dock-dot.ok {
  background: var(--accent-emerald);
  box-shadow: 0 0 6px var(--accent-emerald);
}

.dock-dot.pulse-cyan {
  background: var(--accent-cyan);
  box-shadow: 0 0 6px var(--accent-cyan);
  animation: pulse-dot 1.8s infinite;
}

.dock-counter {
  position: absolute;
  top: 4px;
  right: 4px;
  min-width: 14px;
  height: 14px;
  border-radius: 999px;
  background: var(--accent-emerald);
  color: #042416;
  font-size: 0.62rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
  box-shadow: 0 0 6px var(--accent-emerald-glow);
}

.dock-badge-text {
  font-size: 0.65rem;
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--accent-amber);
  margin-left: 2px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-emerald);
  box-shadow: 0 0 8px var(--accent-emerald);
  animation: pulse-dot 2s infinite;
  position: absolute;
  top: 7px;
  right: 7px;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.85); }
}

.panic-btn-mini {
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.25), rgba(185, 28, 28, 0.4));
  border: 1px solid rgba(239, 68, 68, 0.5);
  color: #fca5a5;
  padding: 6px 14px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.76rem;
  letter-spacing: 0.05em;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 0 12px rgba(239, 68, 68, 0.2);
}

.panic-btn-mini:hover {
  background: linear-gradient(135deg, #ef4444, #dc2626);
  color: #fff;
  border-color: #ef4444;
  box-shadow: 0 0 20px rgba(239, 68, 68, 0.5);
  transform: translateY(-1px);
}

/* Micro-Tooltip on Hover */
[data-tooltip] {
  position: relative;
}

[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  top: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%) translateY(-4px) scale(0.95);
  background: rgba(13, 17, 26, 0.96);
  color: #f1f5f9;
  font-size: 0.72rem;
  font-weight: 500;
  font-family: var(--font-sans);
  white-space: nowrap;
  padding: 5px 10px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.5);
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.15s ease, transform 0.15s ease;
  z-index: 1000;
}

[data-tooltip]:hover::after {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0) scale(1);
}

/* Interactive Floating Popover Card */
.symbol-popover-card {
  position: fixed;
  background: rgba(13, 17, 26, 0.96);
  backdrop-filter: blur(25px);
  border: 1px solid rgba(16, 185, 129, 0.35);
  border-radius: 14px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.75), 0 0 25px rgba(16, 185, 129, 0.15);
  padding: 18px 20px;
  min-width: 290px;
  max-width: 360px;
  z-index: 1100;
  animation: popoverFadeIn 0.18s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

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

.popover-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding-bottom: 10px;
}

.popover-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.popover-icon {
  font-size: 1.25rem;
}

.popover-title-row h4 {
  font-family: var(--font-display);
  font-size: 0.98rem;
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: -0.01em;
}

.popover-close-btn {
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 1rem;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  transition: var(--transition);
}

.popover-close-btn:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
}

.popover-body {
  font-size: 0.83rem;
  line-height: 1.5;
  color: var(--text-muted);
}

.popover-body strong {
  color: var(--text-main);
}

.popover-interactive-area {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 6px 0;
}

.popover-option-btn {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-main);
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 0.78rem;
  font-family: var(--font-mono);
  cursor: pointer;
  transition: var(--transition);
}

.popover-option-btn:hover {
  background: rgba(16, 185, 129, 0.15);
  border-color: var(--accent-emerald);
  color: var(--accent-emerald);
}

.popover-option-btn.active {
  background: var(--accent-emerald);
  border-color: var(--accent-emerald);
  color: #042416;
  font-weight: 700;
}

.popover-footer {
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding-top: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--text-dim);
}

.popover-status-badge {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.68rem;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(16, 185, 129, 0.15);
  color: var(--accent-emerald);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

/* Minimalist Channel Start Pill */
.channel-start-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 18px auto;
  padding: 6px 16px;
  border-radius: 999px;
  background: rgba(16, 185, 129, 0.08);
  border: 1px solid rgba(16, 185, 129, 0.22);
  color: #34d399;
  font-size: 0.76rem;
  font-family: var(--font-mono);
  user-select: none;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

/* Floating Toast */
.stealth-toast {
  position: fixed;
  top: 72px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(16, 185, 129, 0.95);
  backdrop-filter: blur(8px);
  color: #032515;
  padding: 8px 18px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.8rem;
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.5), 0 0 15px rgba(16, 185, 129, 0.4);
  z-index: 2000;
  animation: toastIn 0.22s cubic-bezier(0.16, 1, 0.3, 1);
  pointer-events: none;
}

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

/* Real-Time Security Warning Alert Banner */
.security-alert-banner {
  background: linear-gradient(90deg, rgba(239, 68, 68, 0.95), rgba(185, 28, 28, 0.95));
  color: #fff;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 2px solid #f87171;
  box-shadow: 0 4px 20px rgba(239, 68, 68, 0.4);
  animation: slideDownAlert 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 90;
}

@keyframes slideDownAlert {
  from { transform: translateY(-100%); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.alert-content {
  display: flex;
  align-items: center;
  gap: 14px;
}

.alert-icon {
  font-size: 1.5rem;
  animation: pulse-dot 1s infinite;
}

.alert-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 0.85rem;
}

.alert-text strong {
  font-family: var(--font-display);
  font-size: 0.95rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.alert-close-btn {
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: #fff;
  padding: 6px 12px;
  border-radius: 6px;
  font-weight: 600;
  font-size: 0.78rem;
  cursor: pointer;
  transition: var(--transition);
}

.alert-close-btn:hover {
  background: rgba(0, 0, 0, 0.6);
  border-color: #fff;
}

/* ==========================================================================
   LOBBY / KEY GENERATION SCREEN
   ========================================================================== */
.screen-lobby {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  position: relative;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.lobby-card {
  width: 100%;
  max-width: 520px;
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  padding: 36px;
  box-shadow: var(--shadow-lg);
  position: relative;
  overflow: hidden;
}

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

.lobby-header-clean {
  text-align: center;
  margin-bottom: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.lobby-shield-icon {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.16), rgba(6, 182, 212, 0.12));
  border: 1px solid rgba(16, 185, 129, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-emerald);
  margin-bottom: 12px;
  box-shadow: 0 0 20px rgba(16, 185, 129, 0.2);
}

.lobby-header-clean h2 {
  font-family: var(--font-display);
  font-size: 1.65rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  background: linear-gradient(135deg, #ffffff, #cbd5e1);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 4px;
}

.lobby-header-clean p {
  color: var(--text-dim);
  font-size: 0.8rem;
  font-family: var(--font-mono);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

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

.lobby-header h2 {
  font-family: var(--font-display);
  font-size: 1.65rem;
  font-weight: 700;
  margin-bottom: 6px;
  background: linear-gradient(135deg, #fff, #94a3b8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.lobby-header p {
  color: var(--text-muted);
  font-size: 0.85rem;
  line-height: 1.4;
}

.form-group {
  margin-bottom: 18px;
}

.form-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.label-action {
  color: var(--accent-cyan);
  font-size: 0.75rem;
  cursor: pointer;
  text-decoration: underline;
  background: none;
  border: none;
}

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

.input-field {
  width: 100%;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 12px 14px;
  color: #fff;
  font-size: 0.95rem;
  font-family: var(--font-mono);
  transition: var(--transition);
}

.input-field:focus {
  outline: none;
  border-color: var(--accent-emerald);
  box-shadow: 0 0 15px var(--accent-emerald-glow);
}

.input-field::placeholder {
  color: var(--text-dim);
  font-family: var(--font-sans);
}

.input-addon-btn {
  position: absolute;
  right: 8px;
  background: rgba(255, 255, 255, 0.08);
  border: none;
  color: var(--text-muted);
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 0.75rem;
  cursor: pointer;
  transition: var(--transition);
}

.input-addon-btn:hover {
  background: var(--accent-emerald);
  color: #000;
}

.join-btn {
  width: 100%;
  background: linear-gradient(135deg, var(--accent-emerald), #059669);
  color: #061e14;
  border: none;
  border-radius: 12px;
  padding: 14px;
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: var(--transition);
  box-shadow: 0 4px 20px var(--accent-emerald-glow);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.join-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 25px rgba(16, 185, 129, 0.4);
  color: #000;
}

/* Network Access Callout */
.network-info-box {
  margin-top: 24px;
  padding: 14px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px dashed var(--border-color);
  border-radius: 12px;
  font-size: 0.82rem;
}

.network-info-header {
  font-weight: 600;
  color: var(--accent-cyan);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.ip-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-family: var(--font-mono);
  color: var(--text-muted);
}

.ip-tag {
  background: rgba(255, 255, 255, 0.05);
  padding: 3px 8px;
  border-radius: 4px;
  display: inline-block;
  cursor: pointer;
  user-select: all;
  transition: var(--transition);
}

.ip-tag:hover {
  color: var(--accent-emerald);
}

/* ==========================================================================
   SECURE CHAT SCREEN
   ========================================================================== */
.screen-chat {
  flex: 1;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}


/* Chat Messages Container */
.messages-viewport {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.welcome-notice {
  text-align: center;
  max-width: 600px;
  margin: 10px auto 20px;
  background: rgba(16, 185, 129, 0.05);
  border: 1px solid rgba(16, 185, 129, 0.2);
  border-radius: 12px;
  padding: 16px 20px;
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.6;
}

.welcome-notice strong {
  color: var(--accent-emerald);
}

/* Message Rows */
.msg-row {
  display: flex;
  flex-direction: column;
  max-width: 75%;
  animation: fadeInMsg 0.25s ease-out;
}

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

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

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

.msg-meta {
  font-size: 0.72rem;
  color: var(--text-dim);
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.msg-bubble {
  padding: 12px 16px;
  border-radius: 16px;
  position: relative;
  line-height: 1.5;
  font-size: 0.95rem;
  word-break: break-word;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.msg-bubble-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  position: relative;
}

.msg-row.outgoing .msg-bubble-wrap {
  flex-direction: row-reverse;
}

.msg-reply-btn {
  opacity: 0;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--text-muted);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: opacity 0.15s ease, transform 0.15s ease, background 0.15s ease;
  flex-shrink: 0;
}

.msg-row:hover .msg-reply-btn {
  opacity: 1;
}

.msg-reply-btn:hover {
  background: rgba(16, 185, 129, 0.2);
  border-color: var(--accent-emerald);
  color: var(--accent-emerald);
  transform: scale(1.08);
}

@media (hover: none) {
  .msg-reply-btn {
    opacity: 0.7;
  }
}

.msg-reply-quote {
  background: rgba(0, 0, 0, 0.28);
  border-left: 3px solid var(--accent-emerald);
  border-radius: 6px;
  padding: 5px 10px;
  margin-bottom: 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 0.76rem;
}

.quote-author {
  font-weight: 700;
  color: #34d399;
}

.quote-snippet {
  color: rgba(255, 255, 255, 0.75);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 260px;
}

.msg-row.outgoing .msg-bubble {
  background: linear-gradient(135deg, #065f46, #047857);
  color: #fff;
  border-bottom-right-radius: 4px;
  border: 1px solid rgba(16, 185, 129, 0.4);
}

.msg-row.incoming .msg-bubble {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  color: var(--text-main);
  border-bottom-left-radius: 4px;
  border: 1px solid var(--border-color);
}

/* In-Memory Photo Attachments in Messages */
.msg-image-wrap {
  margin-bottom: 8px;
  border-radius: 10px;
  overflow: hidden;
  max-width: 320px;
  cursor: pointer;
  position: relative;
}

.msg-image-thumb {
  width: 100%;
  max-height: 240px;
  object-fit: cover;
  display: block;
  border-radius: 10px;
  transition: transform 0.2s ease, filter 0.2s ease;
}

.msg-image-thumb:hover {
  transform: scale(1.02);
  filter: brightness(1.08);
}

/* Raw Ciphertext Card (Proof of Zero Knowledge) */
.raw-cipher-preview {
  margin-top: 6px;
  padding: 8px 10px;
  background: rgba(0, 0, 0, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--accent-cyan);
  max-width: 100%;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

.cipher-badge {
  color: var(--text-dim);
  font-size: 0.65rem;
  text-transform: uppercase;
  margin-bottom: 2px;
}

/* Burn Countdown Bar */
.burn-timer-bar {
  height: 3px;
  width: 100%;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 2px;
  margin-top: 8px;
  overflow: hidden;
}

.burn-progress {
  height: 100%;
  background: var(--accent-amber);
  width: 100%;
  transition: width 1s linear;
}

/* Decryption Error Bubble */
.msg-bubble.decrypt-error {
  background: rgba(239, 68, 68, 0.15) !important;
  border: 1px solid var(--accent-crimson) !important;
  color: #fca5a5 !important;
}

/* Typing Indicator */
.typing-bar {
  padding: 4px 24px;
  font-size: 0.78rem;
  color: var(--text-muted);
  font-style: italic;
  min-height: 24px;
}

/* Replying To Message Banner */
.replying-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 24px;
  background: rgba(16, 22, 34, 0.95);
  border-top: 1px solid rgba(16, 185, 129, 0.3);
  border-left: 3px solid var(--accent-emerald);
  margin: 0;
  animation: slideUpReply 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.replying-left {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow: hidden;
}

.replying-text-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow: hidden;
}

.replying-label {
  font-size: 0.72rem;
  color: var(--accent-emerald);
}

.replying-snippet {
  font-size: 0.78rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 60vw;
}

.reply-cancel-btn {
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 1rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  transition: var(--transition);
}

.reply-cancel-btn:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
}

/* Active Peers List Modal */
.peers-modal {
  position: fixed;
  inset: 0;
  z-index: 2500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: popoverFadeIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.peers-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
}

.peers-dialog {
  position: relative;
  z-index: 2501;
  background: var(--bg-card);
  backdrop-filter: blur(25px);
  border: 1px solid rgba(16, 185, 129, 0.35);
  border-radius: 16px;
  width: 100%;
  max-width: 360px;
  padding: 18px 20px;
  box-shadow: var(--shadow-lg), 0 0 25px rgba(16, 185, 129, 0.15);
}

.peers-dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding-bottom: 10px;
  margin-bottom: 12px;
}

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

.peers-header-left h4 {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-main);
}

.peers-list-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 240px;
  overflow-y: auto;
}

.peer-item-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 10px;
}

.peer-name-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--text-main);
}

.peer-badge-you {
  font-size: 0.65rem;
  padding: 2px 6px;
  background: rgba(16, 185, 129, 0.2);
  color: var(--accent-emerald);
  border: 1px solid rgba(16, 185, 129, 0.3);
  border-radius: 999px;
  font-weight: 700;
}

/* Chat Input Bar */
.chat-input-area {
  padding: 16px 24px;
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  border-top: 1px solid var(--border-color);
  display: flex;
  gap: 12px;
  align-items: center;
}

.chat-input-box {
  flex: 1;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 12px 18px;
  color: #fff;
  font-size: 0.95rem;
  font-family: var(--font-sans);
  transition: var(--transition);
}

.chat-input-box:focus {
  outline: none;
  border-color: var(--accent-emerald);
  box-shadow: 0 0 15px var(--accent-emerald-glow);
}

.send-msg-btn {
  background: var(--accent-emerald);
  color: #000;
  border: none;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  cursor: pointer;
  transition: var(--transition);
  box-shadow: 0 0 15px var(--accent-emerald-glow);
}

.send-msg-btn:hover {
  transform: scale(1.05);
  background: #34d399;
}

/* Photo Attachment Button */
.chat-attach-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
  flex-shrink: 0;
}

.chat-attach-btn:hover {
  background: rgba(6, 182, 212, 0.15);
  border-color: var(--accent-cyan);
  color: var(--accent-cyan);
  transform: scale(1.05);
}

/* In-Memory Pending Image Preview Pill */
.image-preview-container {
  padding: 10px 24px 0 24px;
  background: var(--bg-card);
  backdrop-filter: blur(16px);
}

.image-preview-card {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  background: rgba(13, 17, 26, 0.95);
  border: 1px solid rgba(6, 182, 212, 0.4);
  border-radius: 12px;
  padding: 6px 12px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
  animation: popoverFadeIn 0.2s ease-out;
}

.preview-thumbnail {
  width: 40px;
  height: 40px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

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

.preview-name {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-main);
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.preview-size {
  font-size: 0.7rem;
  font-family: var(--font-mono);
  color: var(--accent-cyan);
}

.preview-cancel-btn {
  background: transparent;
  border: none;
  color: var(--accent-crimson);
  font-size: 1rem;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition: var(--transition);
}

.preview-cancel-btn:hover {
  background: rgba(239, 68, 68, 0.2);
}

/* Rendered Message Images */
.msg-image-wrap {
  margin-top: 8px;
  border-radius: 10px;
  overflow: hidden;
  max-width: 320px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  cursor: pointer;
  position: relative;
}

.chat-image-preview {
  display: block;
  width: 100%;
  max-height: 260px;
  object-fit: cover;
  border-radius: 8px;
  transition: transform 0.2s ease, filter 0.2s ease;
}

.chat-image-preview:hover {
  transform: scale(1.02);
  filter: brightness(1.08);
}

/* Zero-Knowledge Image Lightbox Modal */
.image-lightbox-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 5000;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: popoverFadeIn 0.2s ease-out;
}

.lightbox-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.88);
  backdrop-filter: blur(16px);
}

.lightbox-dialog {
  position: relative;
  z-index: 5001;
  max-width: 90vw;
  max-height: 85vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lightbox-dialog img {
  max-width: 90vw;
  max-height: 85vh;
  object-fit: contain;
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.9), 0 0 30px rgba(16, 185, 129, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.lightbox-close-btn {
  position: absolute;
  top: -40px;
  right: 0;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #fff;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  cursor: pointer;
  transition: var(--transition);
}

.lightbox-close-btn:hover {
  background: #ef4444;
  border-color: #ef4444;
}

/* WIPE Button Special Glow */
.wipe-btn {
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.35), rgba(185, 28, 28, 0.5));
  border: 1px solid #ef4444;
  color: #fee2e2;
  font-weight: 800;
  letter-spacing: 0.08em;
  box-shadow: 0 0 15px rgba(239, 68, 68, 0.3);
}

.wipe-btn:hover {
  background: linear-gradient(135deg, #ef4444, #b91c1c);
  color: #fff;
  box-shadow: 0 0 25px rgba(239, 68, 68, 0.6);
}

/* ==========================================================================
   CAMOUFLAGE / DECOY SCREEN (PANIC MODE)
   ========================================================================== */
.decoy-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: #ffffff;
  color: #202124;
  z-index: 9999;
  display: none;
  flex-direction: column;
  padding: 40px 20px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

.decoy-search-box {
  max-width: 584px;
  margin: 100px auto 0;
  text-align: center;
}

.decoy-logo {
  font-size: 3rem;
  font-weight: 500;
  color: #4285f4;
  margin-bottom: 24px;
  letter-spacing: -1px;
}

.decoy-input {
  width: 100%;
  padding: 12px 20px;
  border-radius: 24px;
  border: 1px solid #dfe1e5;
  font-size: 1rem;
  box-shadow: 0 1px 6px rgba(32,33,36,0.28);
  outline: none;
}

.decoy-hint {
  margin-top: 40px;
  font-size: 0.75rem;
  color: #70757a;
}

/* Share Modal / QR View */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(8px);
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-content {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 24px;
  max-width: 440px;
  width: 100%;
  text-align: center;
}

.qr-canvas-holder {
  background: #fff;
  padding: 16px;
  border-radius: 12px;
  margin: 16px auto;
  display: inline-block;
}

/* ==========================================================================
   ACTIVE PEERS MODAL & CHAT HEADER DETAILS
   ========================================================================== */
.chat-header-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-back-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 9px;
  color: #94a3b8;
  cursor: pointer;
  transition: all 0.15s ease;
}

.header-back-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.chat-title-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.chat-room-title {
  font-family: var(--font-mono);
  font-size: 0.88rem;
  font-weight: 700;
  color: #f1f5f9;
  letter-spacing: -0.01em;
}

.chat-peer-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: #34d399;
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  width: fit-content;
}

.chat-peer-btn:hover {
  background: rgba(16, 185, 129, 0.22);
  border-color: #34d399;
}

.status-indicator-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 6px #10b981;
}

/* Active Peers Modal */
.peers-modal {
  position: fixed;
  inset: 0;
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.peers-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(3, 7, 18, 0.8);
  backdrop-filter: blur(8px);
}

.peers-dialog {
  position: relative;
  z-index: 1000;
  width: 100%;
  max-width: 380px;
  background: rgba(15, 23, 42, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 16px;
  padding: 20px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.7);
  animation: modalFadePop 0.2s ease-out;
}

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

.peers-dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

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

.peers-header-left h4 {
  font-family: var(--font-display, inherit);
  font-size: 0.95rem;
  font-weight: 700;
  color: #f8fafc;
  margin: 0;
}

.peers-list-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 280px;
  overflow-y: auto;
}

.peer-item-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 10px;
}

.peer-name-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.88rem;
  color: #f1f5f9;
}

.peer-badge-you {
  font-size: 0.68rem;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(16, 185, 129, 0.18);
  border: 1px solid rgba(16, 185, 129, 0.4);
  color: #34d399;
  letter-spacing: 0.05em;
}

/* ==========================================================================
   MOBILE & TOUCH OPTIMIZATIONS
   ========================================================================== */

/* Disable sticky hover tooltips on touch devices */
@media (hover: none) {
  [data-tooltip]::after {
    display: none !important;
  }
}

@media (max-width: 768px) {
  .site-header {
    padding: 10px 16px;
  }
  .msg-row {
    max-width: 85%;
  }
  .lobby-card {
    padding: 28px 20px;
  }
}

@media (max-width: 640px) {
  .site-header {
    padding: max(8px, env(safe-area-inset-top, 0px)) 10px 8px 10px;
    gap: 8px;
  }

  .brand-wrapper {
    gap: 8px;
  }

  .brand-icon {
    width: 30px;
    height: 30px;
    border-radius: 8px;
  }

  .brand-title {
    font-size: 1.05rem;
  }

  .symbol-dock {
    padding: 2px 4px;
    gap: 3px;
    border-radius: 8px;
    max-width: 58vw;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .symbol-dock::-webkit-scrollbar {
    display: none;
  }

  .dock-btn {
    width: 34px;
    height: 34px;
    min-width: 34px;
    border-radius: 7px;
  }

  .dock-btn svg {
    width: 15px;
    height: 15px;
  }

  .fingerprint-btn {
    padding: 0 6px;
    height: 34px;
  }

  .fp-mini-text {
    font-size: 0.72rem;
    letter-spacing: 1px;
  }

  .panic-btn-mini {
    padding: 6px 10px;
    font-size: 0.72rem;
    gap: 4px;
    border-radius: 8px;
  }

  .panic-btn-mini svg {
    width: 13px;
    height: 13px;
  }

  /* Lobby on Mobile */
  .screen-lobby {
    padding: 16px 12px;
  }

  .lobby-card {
    padding: 24px 16px;
    border-radius: 16px;
    max-width: 100%;
  }

  .lobby-shield-icon {
    width: 46px;
    height: 46px;
    border-radius: 14px;
    margin-bottom: 10px;
  }

  .lobby-shield-icon svg {
    width: 22px;
    height: 22px;
  }

  .lobby-header-clean h2 {
    font-size: 1.45rem;
  }

  .lobby-header-clean p {
    font-size: 0.75rem;
  }

  .form-group {
    margin-bottom: 16px;
  }

  .form-label {
    font-size: 0.82rem;
    margin-bottom: 6px;
  }

  .label-action {
    font-size: 0.8rem;
    padding: 2px 4px;
  }

  /* CRITICAL: font-size 16px prevents iOS Safari from auto-zooming viewport */
  .input-field {
    font-size: 16px !important;
    padding: 12px 14px;
    min-height: 48px;
    border-radius: 10px;
  }

  .input-addon-btn {
    min-height: 34px;
    padding: 6px 10px;
    font-size: 0.8rem;
    right: 6px;
  }

  .join-btn {
    min-height: 52px;
    font-size: 1.05rem;
    border-radius: 12px;
    margin-top: 4px;
  }

  /* Chat Header on Mobile */
  .chat-header-info {
    gap: 8px;
  }

  .header-back-btn {
    width: 32px;
    height: 32px;
    border-radius: 8px;
  }

  .chat-room-title {
    font-size: 0.95rem;
    max-width: 130px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .chat-peer-status {
    font-size: 0.68rem;
  }

  /* Chat Screen on Mobile */
  .messages-viewport {
    padding: 12px 10px;
    gap: 12px;
  }

  .msg-row {
    max-width: 88%;
  }

  .msg-bubble {
    padding: 10px 14px;
    font-size: 0.94rem;
    border-radius: 14px;
  }

  .msg-meta {
    font-size: 0.68rem;
    gap: 6px;
  }

  .chat-input-area {
    padding: 8px 10px max(10px, env(safe-area-inset-bottom, 0px)) 10px;
    gap: 8px;
  }

  .chat-input-box {
    font-size: 16px !important; /* Prevents iOS Safari auto-zoom */
    padding: 10px 14px;
    min-height: 46px;
    border-radius: 10px;
  }

  .chat-attach-btn,
  .send-msg-btn {
    width: 46px;
    height: 46px;
    min-width: 46px;
    min-height: 46px;
    border-radius: 10px;
  }

  /* Interactive Popover Modal on Mobile */
  .symbol-popover-card {
    left: 10px !important;
    right: 10px !important;
    width: auto !important;
    max-width: calc(100vw - 20px) !important;
    top: auto !important;
    bottom: 74px !important;
    padding: 14px 16px;
    border-radius: 14px;
  }

  /* Replying Banner on Mobile */
  .replying-banner {
    padding: 6px 12px;
  }

  .replying-snippet {
    max-width: 65vw;
  }

  /* Peers Dialog on Mobile */
  .peers-dialog {
    max-width: calc(100vw - 28px);
    padding: 16px 14px;
  }

  .image-lightbox-modal {
    padding: 12px;
  }

  .lightbox-dialog img {
    max-width: 95vw;
    max-height: 80vh;
  }
}

