/* ==============================================================================
   CIPHERCORE E2EE CHAT APPLICATION STYLESHEET
   Aesthetics: Modern Cyber-Security, Glassmorphism, Stealth Dark Mode, Micro-animations
   Responsiveness: Mobile-First, Flexbox & CSS Grid, Fluid Typography
   Accessibility: High Contrast, Focus Indicators, WCAG AA Compliant
   ============================================================================== */

:root {
  /* Color Palette - Obsidian Stealth (Default) */
  --bg-base: #0a0d14;
  --bg-surface: #111726;
  --bg-surface-glass: rgba(17, 23, 38, 0.75);
  --bg-surface-elevated: #182033;
  --bg-surface-hover: #1e2942;
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-glow: rgba(0, 230, 153, 0.25);

  /* Primary Accent: Cryptographic Emerald / Neon Mint */
  --accent-primary: #00e699;
  --accent-primary-hover: #00ffaa;
  --accent-primary-glow: rgba(0, 230, 153, 0.35);
  --accent-secondary: #3b82f6;
  --accent-secondary-glow: rgba(59, 130, 246, 0.3);

  /* Security & Status Colors */
  --color-danger: #ff4757;
  --color-danger-glow: rgba(255, 71, 87, 0.35);
  --color-warning: #ffa502;
  --color-success: #2ed573;
  --color-info: #70a1ff;

  /* Typography Colors */
  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --text-subtle: #64748b;
  --text-inverted: #0a0d14;

  /* Fonts */
  --font-sans: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'SF Mono', Consolas, monospace;

  /* Geometry & Shadows */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-xl: 24px;
  --radius-full: 9999px;

  --shadow-glass: 0 8px 32px 0 rgba(0, 0, 0, 0.45);
  --shadow-glow: 0 0 20px var(--accent-primary-glow);
  --shadow-danger: 0 0 20px var(--color-danger-glow);

  --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-bounce: 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* Cyber Violet Theme */
[data-theme="violet"] {
  --bg-base: #0b0914;
  --bg-surface: #151128;
  --bg-surface-glass: rgba(21, 17, 40, 0.78);
  --bg-surface-elevated: #1e1939;
  --bg-surface-hover: #29224d;
  --accent-primary: #a855f7;
  --accent-primary-hover: #c084fc;
  --accent-primary-glow: rgba(168, 85, 247, 0.35);
  --border-glow: rgba(168, 85, 247, 0.3);
}

/* Electric Cyan Theme */
[data-theme="cyan"] {
  --bg-base: #061118;
  --bg-surface: #0c1e2b;
  --bg-surface-glass: rgba(12, 30, 43, 0.78);
  --bg-surface-elevated: #112a3d;
  --bg-surface-hover: #193a52;
  --accent-primary: #06b6d4;
  --accent-primary-hover: #22d3ee;
  --accent-primary-glow: rgba(6, 182, 212, 0.35);
  --border-glow: rgba(6, 182, 212, 0.3);
}

/* Reset & Base */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  width: 100%;
  height: 100%;
  font-family: var(--font-sans);
  background-color: var(--bg-base);
  color: var(--text-main);
  line-height: 1.5;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Background Cyber Grid Pattern */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image: 
    radial-gradient(circle at 50% 20%, rgba(0, 230, 153, 0.04) 0%, transparent 60%),
    linear-gradient(rgba(255, 255, 255, 0.02) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.02) 1px, transparent 1px);
  background-size: 100% 100%, 40px 40px, 40px 40px;
  pointer-events: none;
  z-index: 0;
}

/* Privacy Blur Effect when Tab Inactive / Screen Obscured */
body.privacy-blurred main {
  filter: blur(14px) brightness(0.7);
  pointer-events: none;
  transition: filter var(--transition-normal);
}

/* Top App Bar / HUD */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg-surface-glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-subtle);
  padding: 0.75rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand-section {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: inherit;
}

.brand-shield {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, rgba(0, 230, 153, 0.2), rgba(0, 230, 153, 0.05));
  border: 1px solid var(--accent-primary);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-primary);
  font-size: 1.4rem;
  box-shadow: 0 0 15px var(--accent-primary-glow);
  animation: pulse-glow 3s infinite alternate ease-in-out;
}

@keyframes pulse-glow {
  0% { box-shadow: 0 0 10px var(--accent-primary-glow); }
  100% { box-shadow: 0 0 22px var(--accent-primary-glow); }
}

.brand-title {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.brand-badge {
  font-size: 0.65rem;
  text-transform: uppercase;
  font-weight: 800;
  letter-spacing: 0.08em;
  padding: 0.2rem 0.45rem;
  border-radius: var(--radius-full);
  background: rgba(0, 230, 153, 0.15);
  color: var(--accent-primary);
  border: 1px solid var(--accent-primary);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.6rem 1.1rem;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all var(--transition-fast);
  text-decoration: none;
  outline: none;
  user-select: none;
}

.btn:focus-visible {
  box-shadow: 0 0 0 3px var(--accent-primary-glow);
}

.btn-primary {
  background: var(--accent-primary);
  color: var(--text-inverted);
  border-color: var(--accent-primary);
  box-shadow: var(--shadow-glow);
}

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

.btn-secondary {
  background: var(--bg-surface-elevated);
  color: var(--text-main);
  border-color: var(--border-subtle);
}

.btn-secondary:hover {
  background: var(--bg-surface-hover);
  border-color: rgba(255, 255, 255, 0.2);
}

.btn-danger {
  background: rgba(255, 71, 87, 0.15);
  color: var(--color-danger);
  border-color: rgba(255, 71, 87, 0.35);
}

.btn-danger:hover {
  background: var(--color-danger);
  color: #fff;
  box-shadow: var(--shadow-danger);
}

.btn-icon {
  width: 38px;
  height: 38px;
  padding: 0;
  border-radius: var(--radius-md);
  font-size: 1.25rem;
  background: var(--bg-surface-elevated);
  color: var(--text-muted);
  border: 1px solid var(--border-subtle);
}

.btn-icon:hover {
  color: var(--text-main);
  background: var(--bg-surface-hover);
  border-color: rgba(255, 255, 255, 0.2);
}

.btn-icon.active {
  color: var(--accent-primary);
  border-color: var(--accent-primary);
  background: rgba(0, 230, 153, 0.1);
}

/* Panic Killswitch Button */
.btn-panic {
  background: linear-gradient(135deg, rgba(255, 71, 87, 0.25), rgba(255, 71, 87, 0.05));
  color: var(--color-danger);
  border: 1px solid rgba(255, 71, 87, 0.4);
  font-weight: 700;
  padding: 0.45rem 0.85rem;
  font-size: 0.82rem;
  animation: danger-glow 2.5s infinite alternate;
}

@keyframes danger-glow {
  0% { border-color: rgba(255, 71, 87, 0.3); }
  100% { border-color: rgba(255, 71, 87, 0.8); box-shadow: 0 0 12px var(--color-danger-glow); }
}

.btn-panic:hover {
  background: var(--color-danger);
  color: #ffffff;
}

/* Main Container Layout */
.app-container {
  position: relative;
  z-index: 1;
  max-width: 1400px;
  margin: 0 auto;
  min-height: calc(100vh - 65px);
  display: flex;
  flex-direction: column;
}

/* Views (SPA Switching) */
.view {
  display: none;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity var(--transition-normal), transform var(--transition-normal);
}

.view.active {
  display: flex;
  opacity: 1;
  transform: translateY(0);
  flex-direction: column;
  flex: 1;
}

/* ==============================================================================
   VIEW 1: LANDING & ROOM SETUP VIEW
   ============================================================================== */
.setup-view-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem 1.25rem;
  min-height: calc(100vh - 80px);
}

.hero-header {
  text-align: center;
  max-width: 680px;
  margin-bottom: 2rem;
}

.hero-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.85rem;
  border-radius: var(--radius-full);
  background: rgba(0, 230, 153, 0.08);
  border: 1px solid var(--border-glow);
  color: var(--accent-primary);
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 1.25rem;
}

.hero-title {
  font-size: clamp(2rem, 4vw, 3rem);
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.03em;
  margin-bottom: 1rem;
  background: linear-gradient(135deg, #ffffff 40%, var(--text-muted) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.hero-highlight {
  background: linear-gradient(135deg, var(--accent-primary) 0%, #38ef7d 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.hero-desc {
  font-size: 1rem;
  color: var(--text-muted);
  line-height: 1.6;
}

/* Card Styling */
.glass-card {
  width: 100%;
  max-width: 580px;
  background: var(--bg-surface-glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: 2rem;
  box-shadow: var(--shadow-glass);
}

/* Tab Navigation inside Card */
.card-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--bg-base);
  padding: 0.35rem;
  border-radius: var(--radius-md);
  margin-bottom: 1.5rem;
  border: 1px solid var(--border-subtle);
}

.tab-btn {
  padding: 0.65rem 1rem;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.9rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: all var(--transition-fast);
}

.tab-btn.active {
  background: var(--bg-surface-elevated);
  color: var(--accent-primary);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

/* Form Elements */
.form-group {
  margin-bottom: 1.25rem;
}

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

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

.form-input-icon {
  position: absolute;
  left: 1rem;
  color: var(--text-subtle);
  font-size: 1.2rem;
  pointer-events: none;
}

.form-input {
  width: 100%;
  padding: 0.75rem 1rem 0.75rem 2.75rem;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-main);
  font-size: 0.95rem;
  font-family: inherit;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-input.mono {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  letter-spacing: 0.04em;
}

.form-input:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px var(--accent-primary-glow);
}

.form-action-btn {
  position: absolute;
  right: 0.5rem;
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 0.4rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  font-size: 1.1rem;
}

.form-action-btn:hover {
  color: var(--accent-primary);
  background: rgba(255, 255, 255, 0.05);
}

/* Password Generator Meter */
.password-generator-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 0.5rem;
  padding: 0.4rem 0.6rem;
  background: var(--bg-base);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  font-size: 0.75rem;
}

.entropy-meter {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.entropy-dots {
  display: flex;
  gap: 3px;
}

.entropy-dot {
  width: 12px;
  height: 4px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.1);
}

.entropy-dot.active-low { background: var(--color-danger); }
.entropy-dot.active-med { background: var(--color-warning); }
.entropy-dot.active-high { background: var(--accent-primary); box-shadow: 0 0 6px var(--accent-primary-glow); }

.generator-controls {
  display: flex;
  gap: 0.5rem;
}

.generator-btn {
  background: transparent;
  border: none;
  color: var(--accent-primary);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.75rem;
  font-weight: 600;
}

.generator-btn:hover {
  text-decoration: underline;
}

/* Security Features List in Card */
.security-guarantees-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border-subtle);
}

.guarantee-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.guarantee-item i {
  color: var(--accent-primary);
  font-size: 1.1rem;
}

/* ==============================================================================
   VIEW 2: ACTIVE CHATROOM & P2P MESH INTERFACE
   ============================================================================== */
.chat-layout {
  display: flex;
  height: calc(100vh - 65px);
  position: relative;
  overflow: hidden;
}

/* Sidebar: Connected Peers & Security Stats */
.chat-sidebar {
  width: 320px;
  background: var(--bg-surface);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  transition: transform var(--transition-normal);
  z-index: 20;
}

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

.room-meta {
  overflow: hidden;
}

.room-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-subtle);
  font-weight: 700;
}

.room-id-display {
  font-family: var(--font-mono);
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.sidebar-section-title {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-subtle);
  padding: 1rem 1.25rem 0.5rem;
  font-weight: 700;
}

.peer-list {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem 0.75rem;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.peer-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem;
  border-radius: var(--radius-md);
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  transition: background var(--transition-fast);
}

.peer-avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, #1e2942, #334155);
  border: 1px solid var(--accent-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--accent-primary);
  flex-shrink: 0;
  position: relative;
}

.peer-status-dot {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--color-success);
  border: 2px solid var(--bg-surface-elevated);
}

.peer-info {
  flex: 1;
  overflow: hidden;
}

.peer-name {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.peer-fingerprint {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-subtle);
}

/* Ephemeral Message Timer Control */
.ephemeral-timer-selector {
  padding: 0.75rem 1.25rem;
  background: var(--bg-base);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.timer-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-weight: 600;
}

.timer-select {
  background: var(--bg-surface-elevated);
  color: var(--accent-primary);
  border: 1px solid var(--border-subtle);
  padding: 0.35rem 0.65rem;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 600;
  outline: none;
  cursor: pointer;
}

/* Chat Main Pane */
.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg-base);
  position: relative;
  overflow: hidden;
}

/* Chat Header */
.chat-top-banner {
  padding: 0.75rem 1.5rem;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.security-indicator {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.verified-lock-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: rgba(0, 230, 153, 0.1);
  border: 1px solid var(--accent-primary);
  color: var(--accent-primary);
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.25rem 0.6rem;
  border-radius: var(--radius-full);
}

.chat-banner-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Message Feed Area */
.messages-container {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  scroll-behavior: smooth;
}

.chat-welcome-notice {
  text-align: center;
  margin: 1rem auto;
  max-width: 500px;
  background: var(--bg-surface-glass);
  border: 1px solid var(--border-subtle);
  padding: 1rem 1.5rem;
  border-radius: var(--radius-lg);
  font-size: 0.85rem;
  color: var(--text-muted);
}

.chat-welcome-notice i {
  color: var(--accent-primary);
  font-size: 1.5rem;
  margin-bottom: 0.5rem;
  display: block;
}

/* Message Bubbles */
.message-row {
  display: flex;
  flex-direction: column;
  max-width: 75%;
  position: relative;
  animation: message-in 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

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

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

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

.message-meta-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.75rem;
  color: var(--text-subtle);
  margin-bottom: 0.25rem;
  padding: 0 0.5rem;
}

.message-author {
  font-weight: 600;
  color: var(--text-muted);
}

.message-bubble {
  padding: 0.85rem 1.15rem;
  border-radius: var(--radius-lg);
  font-size: 0.95rem;
  line-height: 1.5;
  word-break: break-word;
  position: relative;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}

.message-row.outgoing .message-bubble {
  background: linear-gradient(135deg, #009966, #006644);
  color: #ffffff;
  border-bottom-right-radius: 4px;
}

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

.message-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.4rem;
  font-size: 0.7rem;
  margin-top: 0.35rem;
  opacity: 0.8;
}

/* Self-Destruct Timer Progress Bar */
.burn-timer-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 3px;
  background: var(--color-warning);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  transition: width 1s linear;
  box-shadow: 0 0 6px var(--color-warning);
}

/* Encrypted File / Media Card in Chat */
.file-attachment-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 0.75rem;
  border-radius: var(--radius-md);
  margin-top: 0.4rem;
}

.file-icon-box {
  width: 44px;
  height: 44px;
  background: var(--bg-surface-hover);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  color: var(--accent-primary);
  flex-shrink: 0;
}

.file-details {
  flex: 1;
  overflow: hidden;
}

.file-name {
  font-weight: 600;
  font-size: 0.85rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-size {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.file-download-btn {
  background: var(--accent-primary);
  color: var(--text-inverted);
  border: none;
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

/* Image Preview in Chat */
.chat-image-preview-wrapper {
  margin-top: 0.4rem;
  border-radius: var(--radius-md);
  overflow: hidden;
  max-width: 320px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: #000;
  cursor: pointer;
  position: relative;
}

.chat-image-preview {
  width: 100%;
  height: auto;
  max-height: 280px;
  object-fit: cover;
  display: block;
  transition: transform var(--transition-fast);
}

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

.image-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(0, 0, 0, 0.65);
  color: var(--accent-primary);
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-full);
  font-size: 0.7rem;
  font-weight: 700;
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

/* Voice Note Interactive Audio Player Card */
.voice-note-card {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  background: rgba(10, 15, 26, 0.75);
  border: 1px solid rgba(0, 230, 153, 0.35);
  padding: 0.85rem 1.1rem;
  border-radius: var(--radius-md);
  margin-top: 0.4rem;
  min-width: 270px;
  max-width: 360px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.voice-note-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.78rem;
  color: var(--accent-primary);
  font-weight: 700;
  letter-spacing: 0.02em;
}

.voice-duration-tag {
  background: rgba(0, 230, 153, 0.15);
  border: 1px solid rgba(0, 230, 153, 0.3);
  padding: 0.15rem 0.45rem;
  border-radius: var(--radius-full);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: #00e699;
}

.voice-player-body {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-md);
  padding: 0.5rem 0.75rem;
}

.voice-play-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--accent-primary);
  color: var(--text-inverted);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  cursor: pointer;
  flex-shrink: 0;
  box-shadow: 0 0 12px var(--accent-primary-glow);
  transition: transform var(--transition-fast), background var(--transition-fast);
}

.voice-play-btn:hover {
  transform: scale(1.08);
  background: #00ffaa;
}

.voice-play-btn:active {
  transform: scale(0.95);
}

.voice-waveform-track {
  flex: 1;
  position: relative;
  height: 30px;
  display: flex;
  align-items: center;
  cursor: pointer;
  overflow: hidden;
  user-select: none;
}

.voice-waveform-progress {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 0%;
  background: rgba(0, 230, 153, 0.22);
  border-right: 2px solid #00e699;
  border-radius: 4px;
  pointer-events: none;
  transition: width 0.08s linear;
}

.voice-waveform-bars {
  display: flex;
  align-items: center;
  gap: 2.5px;
  width: 100%;
  height: 100%;
}

.voice-waveform-bars span {
  flex: 1;
  background: rgba(255, 255, 255, 0.25);
  border-radius: 2px;
  min-height: 4px;
  transition: height 0.15s ease, background 0.15s ease;
}

.voice-waveform-bars.playing span {
  background: var(--accent-primary);
  animation: soundwave 0.8s infinite alternate ease-in-out;
}

@keyframes soundwave {
  0% { opacity: 0.5; }
  100% { opacity: 1; filter: brightness(1.25); }
}

.voice-time-display {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-muted);
  min-width: 32px;
  text-align: right;
  flex-shrink: 0;
}

.voice-footer-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.72rem;
  padding-top: 0.2rem;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.voice-save-btn {
  color: var(--text-subtle);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.2rem 0.45rem;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.04);
  font-size: 0.72rem;
  transition: color var(--transition-fast), background var(--transition-fast);
}

.voice-save-btn:hover {
  color: var(--accent-primary);
  background: rgba(0, 230, 153, 0.1);
}

/* Clickable Links & Link Previews */
.message-bubble a.chat-link {
  color: #38bdf8;
  text-decoration: underline;
  word-break: break-all;
  font-weight: 500;
}

.message-bubble a.chat-link:hover {
  color: #7dd3fc;
}

.link-preview-card {
  margin-top: 0.5rem;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(56, 189, 248, 0.3);
  border-radius: var(--radius-md);
  padding: 0.6rem 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  text-decoration: none;
  color: inherit;
  transition: background var(--transition-fast), border-color var(--transition-fast);
}

.link-preview-card:hover {
  background: rgba(56, 189, 248, 0.12);
  border-color: #38bdf8;
}

.link-preview-icon {
  font-size: 1.5rem;
  color: #38bdf8;
  flex-shrink: 0;
}

.link-preview-meta {
  flex: 1;
  overflow: hidden;
}

.link-preview-domain {
  font-size: 0.7rem;
  text-transform: uppercase;
  font-weight: 700;
  color: #7dd3fc;
  letter-spacing: 0.05em;
}

.link-preview-url {
  font-size: 0.82rem;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Full-Featured Emoji Picker Popover */
.chat-input-area {
  position: relative;
  padding: 0.85rem 1.25rem;
  background: var(--bg-surface);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.emoji-picker-popover {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 1.25rem;
  width: 370px;
  max-width: calc(100vw - 2.5rem);
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-glow);
  border-radius: var(--radius-lg);
  box-shadow: 0 16px 45px rgba(0, 0, 0, 0.65), 0 0 25px var(--accent-primary-glow);
  z-index: 250;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  animation: emoji-pop 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes emoji-pop {
  from { opacity: 0; transform: translateY(10px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.emoji-picker-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.65rem 0.85rem 0.5rem;
  border-bottom: 1px solid var(--border-subtle);
}

.emoji-search-box {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--bg-base);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  padding: 0.35rem 0.75rem;
  color: var(--text-muted);
}

.emoji-search-box input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-main);
  font-size: 0.82rem;
  font-family: inherit;
}

.emoji-search-box button {
  background: transparent;
  border: none;
  color: var(--text-subtle);
  cursor: pointer;
  font-size: 0.95rem;
}

.btn-close-emoji {
  background: transparent;
  border: none;
  color: var(--text-subtle);
  font-size: 1.25rem;
  cursor: pointer;
  padding: 0.2rem;
  display: flex;
  align-items: center;
  border-radius: var(--radius-sm);
  transition: color var(--transition-fast);
}

.btn-close-emoji:hover {
  color: var(--color-danger);
}

.emoji-category-tabs {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.4rem 0.65rem;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  overflow-x: auto;
  scrollbar-width: none;
}

.emoji-category-tabs::-webkit-scrollbar {
  display: none;
}

.emoji-tab-btn {
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.25rem 0.45rem;
  font-size: 1.1rem;
  cursor: pointer;
  transition: background var(--transition-fast), transform var(--transition-fast);
  user-select: none;
}

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

.emoji-tab-btn.active {
  background: var(--accent-primary-glow);
  box-shadow: 0 0 10px var(--accent-primary-glow);
}

.emoji-grid-container {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 0.25rem;
  padding: 0.65rem 0.75rem;
  max-height: 220px;
  overflow-y: auto;
  scrollbar-width: thin;
}

.emoji-item-btn {
  background: transparent;
  border: none;
  font-size: 1.35rem;
  line-height: 1;
  padding: 0.35rem 0.2rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform var(--transition-fast), background var(--transition-fast);
  user-select: none;
}

.emoji-item-btn:hover {
  background: var(--bg-surface-hover);
  transform: scale(1.3);
}

.emoji-picker-footer {
  padding: 0.4rem 0.85rem;
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.72rem;
  color: var(--text-subtle);
}

.typing-indicator-bar {
  font-size: 0.75rem;
  color: var(--accent-primary);
  display: flex;
  align-items: center;
  gap: 0.35rem;
  min-height: 18px;
  padding-left: 0.5rem;
}

.input-controls-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.chat-input {
  flex: 1;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  padding: 0.75rem 1.15rem;
  border-radius: var(--radius-full);
  color: var(--text-main);
  font-size: 0.95rem;
  font-family: inherit;
  outline: none;
  transition: border-color var(--transition-fast);
}

.chat-input:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px var(--accent-primary-glow);
}

/* Audio Recording Bar Overlay with Live Soundwave Visualizer */
.recording-bar {
  flex: 1;
  background: rgba(255, 71, 87, 0.12);
  border: 1px solid var(--color-danger);
  border-radius: var(--radius-full);
  padding: 0.5rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  animation: pulse-danger 1.5s infinite alternate;
}

@keyframes pulse-danger {
  0% { box-shadow: 0 0 4px var(--color-danger-glow); }
  100% { box-shadow: 0 0 14px var(--color-danger-glow); }
}

.recording-duration {
  font-family: var(--font-mono);
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--color-danger);
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-shrink: 0;
}

.recording-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-danger);
  animation: blink 1s infinite;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.2; }
}

.recording-audio-meter {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  overflow: hidden;
}

.voice-waveform-visualizer {
  display: flex;
  align-items: center;
  gap: 3px;
  height: 22px;
}

.voice-waveform-visualizer .v-bar {
  width: 3px;
  height: 20%;
  background: rgba(255, 71, 87, 0.6);
  border-radius: 2px;
  transition: height 0.08s ease, background 0.15s ease;
}

.voice-waveform-visualizer .v-bar.active {
  background: #00e699;
  box-shadow: 0 0 6px rgba(0, 230, 153, 0.6);
}

.voice-live-status {
  font-size: 0.75rem;
  font-family: var(--font-mono);
  color: var(--text-subtle);
  white-space: nowrap;
}

/* ==============================================================================
   MODALS (Safety Numbers, Threat Model, Decoy Screen)
   ============================================================================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(5, 8, 15, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
}

.modal-backdrop.active {
  display: flex;
}

.modal-card {
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: 2rem;
  box-shadow: var(--shadow-glass);
  position: relative;
  animation: modal-pop 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

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

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

.modal-title {
  font-size: 1.25rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Safety Number Blocks Display */
.safety-number-box {
  background: var(--bg-base);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  margin: 1.25rem 0;
  text-align: center;
}

.safety-digits-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.75rem;
  font-family: var(--font-mono);
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--accent-primary);
}

.safety-block {
  background: var(--bg-surface-elevated);
  padding: 0.5rem;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.qr-code-wrapper {
  display: flex;
  justify-content: center;
  margin: 1.5rem 0;
}

.qr-code-box {
  padding: 1rem;
  background: #ffffff;
  border-radius: var(--radius-md);
  display: inline-block;
}

/* ==============================================================================
   DECOY MODE / CAMOUFLAGE CALCULATOR
   ============================================================================== */
.decoy-screen {
  position: fixed;
  inset: 0;
  background: #202124;
  z-index: 99999;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.decoy-screen.active {
  display: flex;
}

.calculator-wrapper {
  width: 100%;
  max-width: 320px;
  background: #202124;
  border-radius: 12px;
  padding: 1.25rem;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
  border: 1px solid #3c4043;
}

.calc-display {
  width: 100%;
  height: 70px;
  background: #2d2e30;
  border-radius: 8px;
  padding: 1rem;
  text-align: right;
  font-size: 2rem;
  color: #fff;
  font-family: monospace;
  overflow: hidden;
  margin-bottom: 1rem;
  border: none;
}

.calc-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.6rem;
}

.calc-btn {
  padding: 1rem 0;
  font-size: 1.2rem;
  font-weight: 600;
  border-radius: 50%;
  border: none;
  background: #3c4043;
  color: #fff;
  cursor: pointer;
  transition: background 0.1s;
}

.calc-btn:hover {
  background: #5f6368;
}

.calc-btn.operator {
  background: #f29900;
  color: #fff;
}

.calc-btn.action {
  background: #5f6368;
}

/* Image Lightbox Modal */
.image-lightbox-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.92);
  backdrop-filter: blur(12px);
  z-index: 100000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.image-lightbox-backdrop.active {
  display: flex;
}

.lightbox-img {
  max-width: 90vw;
  max-height: 85vh;
  object-fit: contain;
  border-radius: var(--radius-md);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.8);
  border: 1px solid var(--border-subtle);
}

.lightbox-close-btn {
  position: absolute;
  top: 20px;
  right: 20px;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  border: none;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  font-size: 1.5rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition-fast);
}

.lightbox-close-btn:hover {
  background: var(--color-danger);
}

/* ==============================================================================
   RESPONSIVENESS (Mobile, Tablet, Desktop)
   ============================================================================== */
@media (max-width: 900px) {
  .chat-sidebar {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    transform: translateX(-100%);
    box-shadow: 10px 0 30px rgba(0,0,0,0.7);
    z-index: 99;
  }

  .chat-sidebar.open {
    transform: translateX(0);
  }

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

@media (min-width: 901px) {
  .mobile-menu-btn {
    display: none !important;
  }
}

@media (max-width: 768px) {
  .app-header {
    padding: 0.5rem 0.75rem;
    gap: 0.5rem;
  }

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

  .brand-badge {
    display: none;
  }

  .user-pill-badge {
    padding: 0.25rem 0.5rem;
  }

  #user-badge-id {
    display: none !important;
  }

  .identity-banner {
    padding: 0.5rem 0.75rem;
  }

  .url-chip-group {
    flex-direction: column;
    gap: 0.5rem;
  }

  .hero-title {
    font-size: 1.85rem;
  }

  .glass-card {
    padding: 1.25rem;
  }

  .safety-digits-grid {
    grid-template-columns: repeat(2, 1fr);
    font-size: 1rem;
  }

  .message-row {
    max-width: 92%;
  }

  .chat-top-banner {
    padding: 0.5rem 0.75rem;
  }

  .messages-container {
    padding: 0.75rem;
  }

  .chat-input-area {
    padding: 0.5rem 0.75rem;
  }
}

@media (max-width: 480px) {
  .header-actions {
    gap: 0.25rem;
  }

  .btn-panic {
    padding: 0.35rem 0.5rem;
    font-size: 0.75rem;
  }

  .btn-icon {
    width: 34px;
    height: 34px;
  }
}

/* ==============================================================================
   SYSTEM PIN LOCK & INTERACTIVE NUMPAD STYLES
   ============================================================================== */
.pin-overlay-card {
  border: 1px solid var(--border-glow);
  box-shadow: 0 0 40px rgba(0, 230, 153, 0.12), var(--shadow-glass);
}

.pin-shield-icon {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: rgba(0, 230, 153, 0.12);
  border: 2px solid var(--accent-primary);
  color: var(--accent-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  margin: 0 auto 0.85rem;
  box-shadow: 0 0 20px var(--accent-primary-glow);
  animation: pulse-glow 2.5s infinite ease-in-out;
}

@keyframes pulse-glow {
  0%, 100% { transform: scale(1); box-shadow: 0 0 15px var(--accent-primary-glow); }
  50% { transform: scale(1.05); box-shadow: 0 0 25px var(--accent-primary-glow); }
}

.pin-dots-row {
  display: flex;
  justify-content: center;
  gap: 1rem;
  margin: 0.75rem auto 1rem;
}

.pin-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid var(--text-subtle);
  background: transparent;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.pin-dot.filled {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
  box-shadow: 0 0 12px var(--accent-primary-glow);
  transform: scale(1.15);
}

.pin-dot.error {
  background: var(--color-danger);
  border-color: var(--color-danger);
  box-shadow: 0 0 15px var(--color-danger-glow);
}

.pin-dots-row.shake {
  animation: pin-shake 0.4s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

@keyframes pin-shake {
  10%, 90% { transform: translate3d(-2px, 0, 0); }
  20%, 80% { transform: translate3d(4px, 0, 0); }
  30%, 50%, 70% { transform: translate3d(-6px, 0, 0); }
  40%, 60% { transform: translate3d(6px, 0, 0); }
}

.pin-stealth-input {
  width: 140px;
  margin: 0 auto 1rem;
  text-align: center;
  font-size: 1.6rem;
  letter-spacing: 0.35em;
  padding: 0.35rem 0.5rem;
  border-radius: var(--radius-sm);
  background: var(--bg-base);
  border: 1px solid var(--border-subtle);
}

.pin-numpad-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.65rem;
  max-width: 260px;
  margin: 0 auto;
}

.numpad-btn {
  height: 52px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface-elevated);
  color: var(--text-main);
  font-family: var(--font-mono);
  font-size: 1.25rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition-fast), border-color var(--transition-fast), transform var(--transition-fast);
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.numpad-btn:hover {
  background: var(--bg-surface-hover);
  border-color: var(--accent-primary);
  color: var(--accent-primary);
  transform: translateY(-1px);
}

.numpad-btn:active {
  transform: scale(0.95);
  background: var(--accent-primary-glow);
}

.numpad-btn.numpad-action {
  background: var(--bg-base);
  color: var(--text-muted);
  font-size: 1rem;
}

.numpad-btn.numpad-action:hover {
  color: var(--color-danger);
  border-color: rgba(255, 71, 87, 0.4);
}

