/* 
 * Key-Forge - Secure Messenger Styles
 * "No Wizard Needed, Just Quantum Grade Encryption"
 */

:root {
  /* Emerald Color Palette */
  --emerald-50: #ecfdf5;
  --emerald-100: #d1fae5;
  --emerald-200: #a7f3d0;
  --emerald-300: #6ee7b7;
  --emerald-400: #34d399;
  --emerald-500: #10b981;
  --emerald-600: #059669;
  --emerald-700: #047857;
  --emerald-800: #065f46;
  --emerald-900: #064e3b;
  
  /* Gem Accent Colors */
  --jade-50: #ecfdf5; /* Fix missing variable */
  --jade-400: #4ade80;
  --jade-500: #22c55e;
  --jade-600: #16a34a;
  
  /* Supporting Colors - Enhanced for WCAG AA */
  --slate-50: #f8fafc;
  --slate-100: #f1f5f9;
  --slate-200: #e2e8f0;
  --slate-300: #cbd5e0;
  --slate-400: #64748b; /* Enhanced from #94a3b8 for better contrast */
  --slate-500: #475569; /* Enhanced from #64748b */
  --slate-600: #334155; /* Enhanced from #475569 */
  --slate-700: #1e293b; /* Fix duplicate value */
  --slate-800: #1e293b;
  --slate-900: #0f172a;
  
  /* Typography - Modern Messaging App Stack */
  --font-system: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Inter', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-mono: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;

  /* Typography Scale - now handled by fluid type system below */

  /* Font Weights */
  --font-weight-normal: 400;
  --font-weight-medium: 500;
  --font-weight-semibold: 600;
  --font-weight-bold: 700;

  /* Line Heights */
  --line-height-tight: 1.3;
  --line-height-normal: 1.4;
  --line-height-relaxed: 1.5;
  
  /* Shadow definitions moved to refined elevation system below */
  --shadow-emerald: 0 10px 25px -5px rgba(16, 185, 129, 0.2), 0 4px 6px -2px rgba(16, 185, 129, 0.1);
  
  /* Gradients */
  --gradient-emerald: linear-gradient(135deg, var(--emerald-500) 0%, var(--jade-600) 100%);
  --gradient-emerald-light: linear-gradient(135deg, var(--emerald-400) 0%, var(--jade-500) 100%);
  --gradient-city: linear-gradient(135deg, var(--emerald-600) 0%, var(--emerald-800) 50%, var(--slate-800) 100%);

  /* Spacing Scale */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;

  /* Border Radius Scale */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-2xl: 24px;

  /* Enhanced Focus Ring */
  --ring-emerald: 0 0 0 4px rgba(16, 185, 129, 0.12);

  /* Semantic Color Tokens */
  --color-primary: var(--emerald-600);
  --color-primary-hover: var(--emerald-700);
  --color-secondary: var(--slate-500);
  --color-secondary-hover: var(--slate-600);
  --color-success: var(--jade-500);
  --color-success-hover: var(--jade-600);
  --color-surface: white;
  --color-on-surface: var(--slate-700);
  --color-text-muted: var(--slate-500);
  --color-border: var(--slate-200);
  --color-border-focus: var(--emerald-400);
  --color-error: #991b1b;

  /* Native theme support */
  color-scheme: light dark;
}

/* Reset and Base Styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: var(--font-system);
  background: var(--gradient-city);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--slate-800);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-normal);
  line-height: var(--line-height-normal);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* Gem-like patterns for background */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image: 
    radial-gradient(circle at 20% 30%, rgba(16, 185, 129, 0.1) 0%, transparent 50%),
    radial-gradient(circle at 80% 70%, rgba(52, 211, 153, 0.08) 0%, transparent 50%),
    radial-gradient(circle at 40% 80%, rgba(110, 231, 183, 0.06) 0%, transparent 50%);
  pointer-events: none;
  z-index: -1;
}

/* Main Application Container */
.app {
  width: 100%;
  max-width: 900px;
  height: 90vh;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(20px);
  border-radius: 20px;
  overflow: auto;
  box-shadow: var(--shadow-emerald);
  display: flex;
  flex-direction: column;
  border: 1px solid rgba(16, 185, 129, 0.2);
}

/* Logo Styling */
.logo {
  width: 120px;
  height: 120px;
  border-radius: 12px;
  margin-right: 16px;
}

/* Header Styles */
.header {
  background: var(--gradient-emerald);
  color: white;
  padding: 24px;
  text-align: center;
  position: sticky;
  top: 0;
  z-index: 10;
  overflow: hidden;
}

.header::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><polygon points="50,5 85,35 85,65 50,95 15,65 15,35" fill="none" stroke="rgba(255,255,255,0.1)" stroke-width="0.5"/></svg>');
  background-size: 60px 60px;
  opacity: 0.3;
}

.header h1 {
  font-size: var(--font-size-3xl);
  font-weight: var(--font-weight-bold);
  margin-bottom: 8px;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  position: relative;
  z-index: 1;
  line-height: var(--line-height-tight);
}

.header .tagline {
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-medium);
  opacity: 0.9;
  position: relative;
  z-index: 1;
  line-height: var(--line-height-normal);
}

/* Room Info Bar */
.room-info {
  background: var(--emerald-700);
  color: white;
  padding: 12px 24px;
  font-size: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
}

.pulse {
  width: 8px;
  height: 8px;
  background: var(--jade-400);
  border-radius: 50%;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.7; transform: scale(1.1); }
}

/* Setup Screen */
.setup-screen {
  padding: 48px;
  text-align: center;
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  overflow-y: auto;
}

.setup-screen h1 {
  color: var(--emerald-700);
  font-size: var(--font-size-3xl);
  font-weight: var(--font-weight-bold);
  margin-bottom: 12px;
  line-height: var(--line-height-tight);
}

.setup-screen .subtitle {
  color: var(--slate-600);
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-medium);
  margin-bottom: 40px;
  line-height: var(--line-height-normal);
}

.info-banner {
  background: linear-gradient(135deg, var(--emerald-50), var(--emerald-100));
  border: 2px solid var(--emerald-200);
  color: var(--emerald-800);
  padding: 20px;
  border-radius: 16px;
  margin-bottom: 32px;
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-medium);
  line-height: var(--line-height-relaxed);
  box-shadow: var(--shadow-md);
}

.info-banner strong {
  color: var(--emerald-700);
}

/* Tabs */
.tabs {
  display: flex;
  margin-bottom: 32px;
  background: var(--slate-100);
  border-radius: 12px;
  padding: 4px;
  box-shadow: var(--shadow-sm);
}

.tab {
  flex: 1;
  padding: 12px 24px;
  background: transparent;
  border: none;
  cursor: pointer;
  font-weight: var(--font-weight-semibold);
  font-size: var(--font-size-base);
  font-family: var(--font-system);
  border-radius: 8px;
  transition-property: transform, box-shadow, background-color, color;
  transition-duration: 0.18s;
  transition-timing-function: cubic-bezier(0.2, 0.7, 0.2, 1);
  color: var(--slate-600);
  line-height: var(--line-height-normal);
  position: relative;
  overflow: hidden;
}

.tab:before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(16, 185, 129, 0.1), transparent);
  transition: left 0.4s ease;
}

.tab.active {
  background: var(--gradient-emerald);
  color: white;
  box-shadow: var(--shadow-md);
  transform: translateY(-1px) scale(1.02);
}

.tab:hover:not(.active) {
  background: var(--emerald-50);
  color: var(--emerald-700);
  transform: translateY(-1px);
}

.tab:hover:before {
  left: 100%;
}

.tab:active {
  transform: translateY(0) scale(0.98);
  transition: all 0.1s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Form Styles */
.setup-form {
  max-width: 400px;
  margin: 0 auto;
}

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

label {
  display: block;
  margin-bottom: 8px;
  font-weight: var(--font-weight-semibold);
  color: var(--slate-700);
  font-size: var(--font-size-sm);
  line-height: var(--line-height-normal);
}

input[type="text"],
input[type="password"],
textarea {
  width: 100%;
  padding: 14px 16px;
  border: 2px solid var(--slate-200);
  border-radius: 12px;
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-normal);
  line-height: var(--line-height-normal);
  transition-property: transform, box-shadow, border-color;
  transition-duration: 0.18s;
  transition-timing-function: cubic-bezier(0.2, 0.7, 0.2, 1);
  background: white;
  font-family: var(--font-system);
  color: var(--slate-700);
}

input:focus,
textarea:focus {
  outline: none;
  border-color: var(--emerald-400);
  box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.1);
  transform: translateY(-1px);
}

/* Note: Button styling now handled by .btn classes below */

/* Messages Area */
.messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  background: var(--slate-50);
  background-image:
    radial-gradient(circle at 25% 25%, rgba(16, 185, 129, 0.03) 0%, transparent 50%),
    radial-gradient(circle at 75% 75%, rgba(52, 211, 153, 0.02) 0%, transparent 50%);
  overscroll-behavior-y: contain;
  scrollbar-gutter: stable both-edges;
  content-visibility: auto;
  contain-intrinsic-size: 400px;
  scrollbar-width: thin;
  scrollbar-color: var(--slate-300) var(--slate-100);
}

.messages::-webkit-scrollbar {
  width: 10px;
}

.messages::-webkit-scrollbar-track {
  background: var(--slate-100);
}

.messages::-webkit-scrollbar-thumb {
  background: var(--slate-300);
  border-radius: 999px;
  border: 2px solid var(--slate-100);
}

.message {
  margin-bottom: 16px;
  padding: 16px 20px;
  border-radius: 16px;
  background: white;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--slate-200);
  animation: slideIn 0.3s ease-out;
  position: relative;
}

.message::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: var(--gradient-emerald);
  border-radius: 2px 0 0 2px;
}

.message.own {
  background: linear-gradient(135deg, var(--emerald-50), white);
  border-color: var(--emerald-200);
  margin-left: 20px;
}

.message.own::before {
  background: var(--gradient-emerald);
}

.message-header {
  font-weight: var(--font-weight-semibold);
  color: var(--slate-700);
  margin-bottom: 8px;
  font-size: var(--font-size-sm);
  line-height: var(--line-height-normal);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.message-content {
  color: var(--slate-700);
  overflow-wrap: anywhere;
  word-break: break-word;
  white-space: pre-wrap;
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-normal);
  line-height: var(--line-height-relaxed);
}

.encryption-badge {
  background: var(--gradient-emerald);
  color: white;
  font-size: var(--font-size-xs);
  padding: 4px 8px;
  border-radius: 6px;
  font-weight: var(--font-weight-semibold);
  font-family: var(--font-system);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  line-height: 1;
  box-shadow: var(--shadow-sm);
}

.message-encrypted {
  background: linear-gradient(135deg, #fef2f2, #fecaca);
  border-color: #f87171;
}

.message-encrypted .message-content {
  font-family: var(--font-mono);
  font-size: 12px;
  color: #7f1d1d; /* Better contrast */
}

/* Input Area */
.input-area {
  padding: 24px;
  background: white;
  border-top: 1px solid var(--slate-200);
  position: sticky;
  bottom: 0;
  z-index: 10;
}

.input-group {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
}

.input-group input[type="text"] {
  flex: 1;
  padding: 14px 16px;
  border: 2px solid var(--slate-200);
  border-radius: 12px;
  font-size: 16px;
  font-family: var(--font-system);
  font-weight: var(--font-weight-normal);
  line-height: var(--line-height-normal);
  transition: all 0.2s ease;
  background: white;
  min-height: 50px;
  height: auto;
  color: var(--slate-700);
  box-shadow: var(--shadow-sm);
  box-sizing: border-box;
}

.input-group input[type="text"]:focus {
  outline: none;
  border-color: var(--emerald-400);
  box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.1), var(--shadow-md);
  transform: translateY(-1px);
}

.input-group input[type="text"]::placeholder {
  color: var(--slate-400);
  font-weight: var(--font-weight-normal);
  opacity: 0.6;
}

/* Decrypt Area */
.decrypt-area {
  background: linear-gradient(135deg, var(--emerald-50), var(--jade-50));
  border: 2px solid var(--emerald-200);
  border-radius: 12px;
  padding: 16px;
  font-size: 14px;
  box-shadow: var(--shadow-sm);
}

.decrypt-area strong {
  color: var(--emerald-700);
}

/* Status Messages */
.status {
  padding: 12px 16px;
  margin: 12px 0;
  border-radius: 8px;
  text-align: center;
  font-weight: 600;
  animation: slideIn 0.3s ease-out;
}

.status.success {
  background: var(--emerald-100);
  color: var(--emerald-800);
  border: 1px solid var(--emerald-300);
}

.status.error {
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fca5a5;
}


/* Typing Indicator */
.typing-indicator {
  color: var(--slate-500);
  font-style: italic;
  font-size: 13px;
  padding: 12px 16px;
  background: var(--slate-100);
  border-radius: 12px;
  margin-bottom: 12px;
  animation: fadeIn 0.3s ease-out;
}

/* Glass/Glow Effect Utility */
.glow-img {
  filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.25))
          drop-shadow(0 2px 6px rgba(255, 255, 255, 0.3));
  background: rgba(255, 255, 255, 0.15);
  padding: 8px;
  border-radius: 12px;
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

/* Logo Container and Elements */
.logo-container {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 16px;
}

.logo-text {
  height: 120px;
  width: auto;
}

.logo-icon {
  height: 120px;
  width: auto;
  /* Remove all frame/glow effects */
  filter: none;
  background: none;
  padding: 0;
  border-radius: 0;
  backdrop-filter: none;
  border: none;
}

/* Chat Header Logo (smaller) */
.chat-header {
  background: var(--gradient-emerald);
  color: white;
  padding: 16px 24px;
  position: sticky;
  top: 0;
  z-index: 10;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.chat-logo-container {
  display: flex;
  align-items: center;
  gap: 12px;
}

.chat-logo-icon {
  height: 60px;
  width: auto;
  /* Clean logo without effects */
  filter: none;
  background: none;
  padding: 0;
  border-radius: 0;
  backdrop-filter: none;
  border: none;
}

.chat-logo-text {
  height: 120px;
  width: auto;
}

/* Utility Classes */

.text-center {
  text-align: center;
}

.text-emerald {
  color: var(--color-primary);
}

.bg-emerald {
  background: var(--color-primary);
}

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

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes shimmer {
  0% {
    background-position: -200px 0;
  }
  100% {
    background-position: calc(200px + 100%) 0;
  }
}

/* Loading States */
.loading {
  background: linear-gradient(90deg, var(--slate-200) 25%, var(--slate-100) 50%, var(--slate-200) 75%);
  background-size: 200px 100%;
  animation: shimmer 1.5s infinite;
}

/* Button loading state - prevents conflict with global loading */
.btn.is-loading {
  background: linear-gradient(90deg, var(--slate-200) 25%, var(--slate-100) 50%, var(--slate-200) 75%);
  background-size: 200px 100%;
  animation: shimmer 1.5s infinite;
  pointer-events: none;
}

/* Responsive Design */
@media (max-width: 768px) {
  .app {
    height: 100svh;
    border-radius: 0;
    max-width: 100%;
  }

  .input-area {
    padding-bottom: calc(var(--space-4, 16px) + env(safe-area-inset-bottom));
  }

  .setup-screen {
    padding: 24px;
  }

  .setup-screen h1 {
    font-size: 2.2rem;
  }

  .messages {
    padding: 16px;
  }

  .input-area {
    padding: 16px;
  }

  .input-group {
    flex-direction: column;
    gap: 8px;
  }

  .message.own {
    margin-left: 0;
  }

  /* Mobile header optimizations */
  .logo-container {
    flex-direction: column;
    gap: 8px;
    margin-bottom: 12px;
  }

  .logo-icon {
    display: none; /* Hide animated logo on mobile */
  }

  .logo-text {
    height: 80px; /* Smaller on mobile */
  }

  .header {
    padding: 16px 12px;
    text-align: center;
  }

  .header h1 {
    font-size: 1.5rem;
    margin-bottom: 4px;
  }

  .header .tagline {
    font-size: 0.9rem;
  }

  /* Chat header mobile */
  .chat-header {
    padding: 12px 16px;
  }

  .chat-logo-container {
    gap: 8px;
  }

  .chat-logo-icon {
    display: none; /* Hide animated logo in chat */
  }

  .chat-logo-text {
    height: 60px; /* Smaller in chat */
  }

  .chat-room-title {
    margin-left: 8px;
  }

  .chat-room-title h1 {
    font-size: 1rem;
  }

  /* Room info responsive */
  .room-info {
    padding: 8px 16px;
    font-size: 13px;
  }

  .room-details {
    font-size: 12px;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
  }
}

@media (max-width: 480px) {
  .header {
    padding: 12px 8px;
  }

  .header h1 {
    font-size: 1.4rem;
  }

  .header .tagline {
    font-size: 0.85rem;
  }

  .tabs {
    flex-direction: column;
    gap: 4px;
  }

  .setup-form {
    max-width: 100%;
  }

  .logo-text {
    height: 60px; /* Even smaller on very small screens */
  }

  .chat-logo-text {
    height: 50px;
  }

  .chat-header {
    padding: 10px 12px;
  }

  .chat-room-title h1 {
    font-size: 0.9rem;
  }

  .room-info {
    padding: 6px 12px;
    font-size: 12px;
  }

  .room-details {
    font-size: 11px;
  }
}

/* Manual Dark Theme Control */
[data-theme="dark"] {
  --slate-50: #0f172a;
  --slate-100: #1e293b;
  --slate-200: #334155;
  --slate-300: #475569;
  --slate-400: #64748b;
  --slate-500: #94a3b8;
  --slate-600: #cbd5e0;
  --slate-700: #e2e8f0;
  --slate-800: #f1f5f9;
  --slate-900: #f8fafc;
}

[data-theme="dark"] body {
  background: linear-gradient(135deg, var(--emerald-900) 0%, var(--slate-900) 50%, #000 100%);
}

[data-theme="dark"] .app {
  background: rgba(15, 23, 42, 0.95);
  border-color: rgba(16, 185, 129, 0.3);
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
  :root {
    --slate-50: #0f172a;
    --slate-100: #1e293b;
    --slate-200: #334155;
    --slate-300: #475569;
    --slate-400: #64748b;
    --slate-500: #94a3b8;
    --slate-600: #cbd5e0;
    --slate-700: #e2e8f0;
    --slate-800: #f1f5f9;
    --slate-900: #f8fafc;
  }
  
  body {
    background: linear-gradient(135deg, var(--emerald-900) 0%, var(--slate-900) 50%, #000 100%);
  }
  
  .app {
    background: rgba(15, 23, 42, 0.95);
    border-color: rgba(16, 185, 129, 0.3);
  }
  
  .message {
    background: var(--slate-100);
    border-color: var(--slate-200);
  }
  
  .message.own {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.1), var(--slate-100));
  }
  
  input[type="text"],
  input[type="password"],
  textarea {
    background: var(--slate-100);
    border-color: var(--slate-200);
    color: var(--slate-700);
  }
}

/* Print Styles */
@media print {
  .app {
    box-shadow: none;
    border: 1px solid var(--slate-300);
  }
  
  .input-area,
  .header {
    display: none;
  }
  
  .messages {
    background: white;
  }
  
  .message {
    break-inside: avoid;
    box-shadow: none;
    border: 1px solid var(--slate-300);
  }
}

/* ARIA-based Tab States */
.tab[aria-selected="true"] {
  background: var(--gradient-emerald);
  color: white;
  box-shadow: var(--shadow-md);
  transform: translateY(-1px) scale(1.02);
}

.tab[aria-selected="false"]:hover {
  background: var(--emerald-50);
  color: var(--emerald-700);
  transform: translateY(-1px);
}

/* Enhanced Focus Styles for Accessibility */
:where(.btn, .tab, input, textarea):focus-visible {
  outline: 2px solid var(--emerald-500);
  outline-offset: 2px;
  box-shadow: var(--ring-emerald);
}

/* Premium selection colors */
::selection {
  background: var(--selection-bg, rgba(16, 185, 129, 0.22));
  color: inherit;
}

/* Native form theming */
input[type="checkbox"],
input[type="radio"],
progress {
  accent-color: var(--emerald-600);
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
  .app {
    border: 2px solid var(--slate-900);
  }
  
  .message {
    border: 2px solid var(--slate-400);
  }
  
  .btn {
    border: 2px solid var(--emerald-700);
  }
}

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

  .pulse {
    animation: none;
  }
}

/* ============================================
   Additional CSS Classes for Inline Styles
   ============================================ */

/* Badge Styles */
.badge {
  display: inline-block;
  background: var(--gradient-emerald);
  color: white;
  padding: 8px 16px;
  border-radius: 20px;
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
  font-family: var(--font-system);
  line-height: 1;
  box-shadow: var(--shadow-sm);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Header and Logo Styles */
.header-logo-container {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 20px;
}

.keyforge-logo {
  height: 120px;
  width: auto;
  margin-left: 8px;
}

h1.keyforge-logo-fallback {
  margin: 0;
  color: var(--emerald-700);
  font-size: 1.5rem;
}

.chat-header-logo {
  height: 100px;
  margin-left: 8px;
}

/* Card and Container Styles */
.verification-card {
  max-width: 400px;
  margin: 0 auto;
}

.verification-text {
  text-align: center;
  color: var(--slate-600);
  margin-bottom: 25px;
}

.security-check-title {
  text-align: center;
  margin-bottom: 20px;
}

/* Shield Icon Styles */
.shield-icon {
  width: 120px;
  height: 120px;
  vertical-align: middle;
  margin-right: 12px;
}

/* Chat Header Specific Styles */
.chat-header-content {
  display: flex;
  align-items: center;
}

.chat-room-title {
  margin-left: 12px;
}

.chat-room-title h1 {
  font-size: 1.2rem;
}

/* Clickable Room ID */
.room-id-clickable {
  cursor: pointer;
  color: var(--emerald-600);
  text-decoration: underline;
  font-weight: var(--font-weight-semibold);
  background-color: rgba(16, 185, 129, 0.1);
  padding: 2px 6px;
  border-radius: 4px;
  transition: all 0.2s ease;
}

.room-id-clickable:hover {
  color: var(--emerald-700);
  background-color: rgba(16, 185, 129, 0.2);
  transform: translateY(-1px);
}

/* Message Timestamp */
.message-timestamp {
  color: var(--slate-500);
  font-weight: normal;
  margin-left: 8px;
}

/* Status Badge Variants */
.encryption-badge.sending {
  background: #f59e0b;
}

.encryption-badge.encrypted {
  background: #dc2626;
  color: white;
  font-size: 10px;
  padding: 4px 8px;
  border-radius: 6px;
}

.encrypted-text {
  color: var(--color-error);
  font-weight: normal;
  margin-left: 8px;
}


/* Container Classes to Replace Complex Inline Styles */
.flex-center {
  display: flex;
  align-items: center;
  justify-content: center;
}

.flex-center-mb {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 20px;
}

.flex-align-center {
  display: flex;
  align-items: center;
}

.ml-3 {
  margin-left: 12px;
}

/* ============================================
   Additional Utility Classes
   ============================================ */

/* Generic image sizing classes */
.img-lg {
  width: 120px;
  height: 120px;
  margin-left: 8px;
}

.img-md {
  width: 80px;
  height: 80px;
}

.img-inline {
  vertical-align: middle;
  margin-right: 12px;
}

/* Heading utilities */
.h3-center {
  text-align: center;
  margin-bottom: 20px;
}

/* Text styling variants */
.text-muted {
  color: var(--slate-500);
  font-weight: normal;
  margin-left: 8px;
}

.text-error {
  color: var(--color-error);
  font-weight: normal;
  margin-left: 8px;
}

.text-gray {
  color: var(--slate-600);
}

.mb-6 {
  margin-bottom: 25px;
}

/* Button variants - standardized */
.btn {
  padding: 7px 14px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: calc(var(--font-size-base) * 0.85);
  font-weight: var(--font-weight-semibold);
  font-family: var(--font-system);
  line-height: var(--line-height-normal);
  transition-property: transform, box-shadow, background-color, opacity;
  transition-duration: 0.18s;
  transition-timing-function: cubic-bezier(0.2, 0.7, 0.2, 1);
  touch-action: manipulation;
  will-change: transform;
  box-shadow: var(--shadow-md), 0 0 0 0 transparent;
  min-width: 60px;
  width: auto;
  min-height: 25px;
  height: auto;
  margin: 2.5px;
  position: relative;
  overflow: hidden;
}

.btn:hover {
  transform: translateY(-2px) scale(1.02);
  opacity: 0.95;
}

.btn:active {
  transform: translateY(0) scale(0.98);
  transition: all 0.1s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: var(--shadow-sm), 0 0 0 2px rgba(16, 185, 129, 0.2);
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.btn-primary {
  background: var(--gradient-emerald);
  color: white;
}

.btn-success {
  background: var(--jade-500);
  color: white;
}

.btn-success:hover {
  background: var(--jade-600);
}

.btn-secondary {
  background: var(--slate-500);
  color: white;
}

.btn-secondary:hover {
  background: var(--slate-600);
}

/* Card variations */
.card-centered {
  max-width: 400px;
  margin: 0 auto;
}

/* NoScript styling */
.noscript-message {
  margin-top: 10px;
  color: var(--slate-700);
  text-align: center;
}

/* Message Grouping */
.message + .message {
  margin-top: 10px;
}

.message[data-same-author="true"] {
  border-top-left-radius: 10px;
  border-top-right-radius: 10px;
  margin-top: 6px;
}

.message.own[data-same-author="true"] {
  border-top-right-radius: 10px;
}

/* Container queries for responsive components */
.app {
  container-type: inline-size;
}

@container (max-width: 560px) {
  .tabs {
    flex-direction: column;
    gap: 6px;
  }

  .message {
    padding: 14px 16px;
  }

  .input-group {
    gap: 8px;
    flex-direction: column;
  }
}

/* =========================================================
   EMERALD CITY — Unified Upgrade Patch (append-only)
   ========================================================= */

/* ---------- 1) Tokens: fluid type, spacing, easing, shadows ---------- */
:root {
  /* Fluid type system - override earlier fixed values */
  --font-size-xs: clamp(0.75rem, 0.70rem + 0.25vw, 0.813rem);
  --font-size-sm: clamp(0.875rem, 0.85rem + 0.25vw, 0.938rem);
  --font-size-base: clamp(1rem, 0.95rem + 0.25vw, 1.063rem);
  --font-size-md: var(--font-size-base);
  --font-size-lg: clamp(1.125rem, 1.05rem + 0.50vw, 1.25rem);
  --font-size-xl: clamp(1.25rem, 1.15rem + 0.50vw, 1.50rem);
  --font-size-2xl: clamp(1.5rem, 1.35rem + 0.75vw, 1.875rem);
  --font-size-3xl: clamp(1.875rem, 1.65rem + 1vw, 2.25rem);

  /* Letter-spacing */
  --letter-spacing-tight: -0.025em;
  --letter-spacing-normal: 0;
  --letter-spacing-wide: 0.025em;

  /* Premium easing */
  --ease-out-expo: cubic-bezier(0.19, 1, 0.22, 1);
  --ease-out-back: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-spring: cubic-bezier(0.68, -0.55, 0.265, 1.55);

  /* Refined elevation system - replaces earlier shadows */
  --shadow-xs: 0 1px 3px rgba(0,0,0,0.04);
  --shadow-sm: 0 2px 4px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);
  --shadow-xl: 0 16px 48px rgba(0,0,0,0.16);

  /* Rings / selection */
  --ring-emerald: 0 0 0 4px rgba(16,185,129,0.12);
  --selection-bg: rgba(16,185,129,0.22);

  /* Spacing system - consolidates with earlier definitions */

  /* Contrast tweaks + bug fixes */
  --slate-400: #6b7280;           /* better AA */
  --slate-500: #4b5563;           /* better AA */
  --slate-700: #1e293b;           /* fix duplicate earlier value */
  --color-text-muted: var(--slate-400);
  --jade-50: #ecfdf5;             /* missing token used in .decrypt-area */

  /* Native theming */
  color-scheme: light dark;
}

/* Smooth scroll UX */
html { scroll-behavior: smooth; }

/* Utilities: consolidate + no !important (edit original to fully remove it) */
.text-center { text-align: center; }
.hidden { display: none; } /* if earlier used !important, prefer [hidden] attr going forward */

/* Selection + accent polish */
::selection { background: var(--selection-bg); color: inherit; }
input[type="checkbox"], input[type="radio"], progress { accent-color: var(--emerald-600); }

/* ---------- 2) App chrome: glass + subtle noise ---------- */
.app {
  position: relative; /* for ::after overlay */
  background: rgba(255,255,255,0.85);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  box-shadow: var(--shadow-lg);
}
.app::after {
  content: '';
  position: absolute;
  inset: 0;
  opacity: 0.03;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='100' height='100'%3E%3Cfilter id='n'%3E%3CfeTurbulence baseFrequency='0.9'/%3E%3C/filter%3E%3Crect width='100' height='100' filter='url(%23n)' opacity='0.5'/%3E%3C/svg%3E");
  pointer-events: none;
}

/* Sticky bars (native app feel) */
.header { position: sticky; top: 0; z-index: 10; }
.input-area { position: sticky; bottom: 0; z-index: 10; }
.chat-header { position: sticky; top: 0; z-index: 10; }

/* iOS safe areas + 100svh */
@media (max-width: 768px) {
  .app { height: 100svh; padding-top: env(safe-area-inset-top); padding-bottom: env(safe-area-inset-bottom); }
  .input-area { padding-bottom: calc(var(--space-4) + env(safe-area-inset-bottom)); }
}

/* ---------- 3) Typography application ---------- */
.header h1 { letter-spacing: var(--letter-spacing-tight); }
.header .tagline, label, .features h3 { letter-spacing: var(--letter-spacing-normal); }
.badge, .encryption-badge { letter-spacing: 0.05em; }

/* ---------- 4) Tabs & inputs: targeted transitions ---------- */
.tab,
.btn,
input[type="text"],
input[type="password"],
textarea {
  transition-property: transform, box-shadow, background-color, color, border-color, opacity;
  transition-duration: .18s;
  transition-timing-function: var(--ease-out-expo);
}

/* ARIA-first tabs */
.tab[aria-selected="true"] {
  background: var(--gradient-emerald);
  color: #fff;
  box-shadow: var(--shadow-md);
  transform: translateY(-1px) scale(1.02);
}
.tab[aria-selected="false"]:hover {
  background: var(--emerald-50);
  color: var(--emerald-700);
}

/* Buttons: micro-interactions + mobile haptics */
.btn {
  touch-action: manipulation;
  -webkit-tap-highlight-color: rgba(16,185,129,0.1);
  will-change: transform;
}
.btn:before {
  transform: translateX(-100%);
  transition: transform 0.5s var(--ease-out-expo);
}
.btn:hover:before { transform: translateX(100%); }

/* Consistent focus rings */
:where(.btn, .tab, input, textarea):focus-visible {
  outline: 2px solid var(--emerald-500);
  outline-offset: 2px;
  box-shadow: var(--ring-emerald);
}

/* ---------- 5) Messages: elevation, grouping, stagger ---------- */
.messages {
  overscroll-behavior-y: contain;
  scrollbar-gutter: stable both-edges;
  content-visibility: auto;
  contain: layout style paint;
  will-change: scroll-position;
  /* premium scrollbars */
  scrollbar-width: thin;
  scrollbar-color: var(--slate-300) var(--slate-100);
}
.messages::-webkit-scrollbar { width: 10px; }
.messages::-webkit-scrollbar-track { background: var(--slate-100); }
.messages::-webkit-scrollbar-thumb {
  background: var(--slate-300);
  border-radius: 999px;
  border: 2px solid var(--slate-100);
}

.message {
  border: none;                     /* cleaner than borders */
  box-shadow: var(--shadow-xs);
  transition: box-shadow 0.2s var(--ease-out-expo), transform .18s var(--ease-out-expo);
  contain: layout style;
  animation: messageSlide 0.4s var(--ease-out-back) backwards;
  animation-delay: calc(var(--message-index, 0) * 0.05s); /* set via JS */
}
.message:hover { box-shadow: var(--shadow-sm); }

.message-content {
  overflow-wrap: anywhere;
  word-break: break-word;
  white-space: pre-wrap;
}

/* Grouping (stacked bubbles) */
.message-group { margin-bottom: 2px; }
.message-group .message:first-child { border-radius: 16px 16px 4px 4px; }
.message-group .message:last-child  { border-radius: 4px 4px 16px 16px; }
.message-group .message:not(:first-child):not(:last-child) { border-radius: 4px; }

/* Tighter grouping for programmatic same-author chains */
.message + .message { margin-top: 10px; }
.message[data-same-author="true"] { border-top-left-radius: 10px; border-top-right-radius: 10px; margin-top: 6px; }
.message.own[data-same-author="true"] { border-top-right-radius: 10px; }

/* Mobile width ceiling + own alignment */
@media (max-width: 768px) {
  .message { max-width: 85%; }
  .message.own { margin-left: auto; margin-right: 0; }
}

/* Encrypted text legibility */
.message-encrypted .message-content { color: #7f1d1d; }

/* Meta + reactions shells (hook via JS) */
.message-meta {
  display: flex; align-items: center; gap: 8px; margin-top: 6px;
  font-size: var(--font-size-xs); color: var(--color-text-muted);
}
.message-reactions { display: inline-flex; gap: 6px; margin-top: 6px; }
.message-reactions .reaction {
  padding: 4px 8px; border-radius: 999px; background: var(--slate-100);
  font-size: var(--font-size-xs); box-shadow: var(--shadow-xs);
}

/* Typing dots */
.typing-dots { display: inline-flex; gap: 4px; }
.typing-dots span {
  width: 8px; height: 8px; background: var(--slate-400);
  border-radius: 50%; animation: typingDot 1.4s infinite;
}
.typing-dots span:nth-child(2) { animation-delay: .2s; }
.typing-dots span:nth-child(3) { animation-delay: .4s; }

@keyframes typingDot {
  0%, 60%, 100% { transform: translateY(0); opacity: .5; }
  30% { transform: translateY(-10px); opacity: 1; }
}

@keyframes messageSlide {
  from { opacity: 0; transform: translateY(20px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ---------- 6) Input area: modern affordances ---------- */
.input-area {
  display: flex; align-items: center; gap: 8px;
  padding: 16px;
  background: white;
  border-top: 1px solid var(--slate-100);
}
.input-wrapper {
  flex: 1; display: flex; align-items: center;
  background: var(--slate-50);
  border-radius: 24px; padding: 4px;
  transition: background .2s var(--ease-out-expo), box-shadow .2s var(--ease-out-expo);
}
.input-wrapper:focus-within { background: #fff; box-shadow: 0 0 0 2px var(--emerald-500); }
.input-wrapper input {
  flex: 1; border: none; background: transparent;
  padding: 10px 12px; font-size: var(--font-size-base); color: var(--slate-700);
}
.input-actions { display: flex; gap: 4px; }
.input-action-btn {
  width: 36px; height: 36px; border-radius: 50%;
  display: grid; place-items: center;
  background: transparent;
  transition: transform .18s var(--ease-out-expo), background .18s var(--ease-out-expo);
}
.input-action-btn:hover { background: var(--slate-100); transform: scale(1.1); }

/* ---------- 7) Container queries: tighter small layouts ---------- */
.app { container-type: inline-size; }
@container (max-width: 560px) {
  .tabs { flex-direction: column; gap: 6px; }
  .message { padding: 14px 16px; }
  .input-group { gap: 8px; flex-direction: column; }
}

/* ---------- 8) Accessibility: forced colors ---------- */
@media (forced-colors: active) {
  .btn, .message, .app { border: 1px solid CanvasText; box-shadow: none; }
  .tab[aria-selected="true"] { outline: 2px solid Highlight; }
}

/* ---------- 9) Dark theme (pref + manual override) ---------- */
@media (prefers-color-scheme: dark) {
  :root {
    --slate-50: #0f172a; --slate-100: #1e293b; --slate-200: #334155;
    --slate-300: #475569; --slate-400: #64748b; --slate-500: #94a3b8;
    --slate-600: #cbd5e0; --slate-700: #e2e8f0; --slate-800: #f1f5f9; --slate-900: #f8fafc;
  }
  body { background: linear-gradient(135deg, var(--emerald-900) 0%, var(--slate-900) 50%, #000 100%); }
  .app { background: rgba(15,23,42,0.95); border-color: rgba(16,185,129,0.3); }
  .message { background: var(--slate-100); }
  input[type="text"], input[type="password"], textarea {
    background: var(--slate-100); border-color: var(--slate-200); color: var(--slate-700);
  }
}
/* Manual override (theme toggle) */
[data-theme="dark"] {
  --slate-50: #0f172a; --slate-100: #1e293b; --slate-200: #334155;
  --slate-300: #475569; --slate-400: #64748b; --slate-500: #94a3b8;
  --slate-600: #cbd5e0; --slate-700: #e2e8f0; --slate-800: #f1f5f9; --slate-900: #f8fafc;
}
[data-theme="dark"] body {
  background: linear-gradient(135deg, var(--emerald-900) 0%, var(--slate-900) 50%, #000 100%);
}
[data-theme="dark"] .app {
  background: rgba(15,23,42,0.95); border-color: rgba(16,185,129,0.3);
}

/* ---------- 10) Reduced motion & perf fallbacks ---------- */
@media (prefers-reduced-motion: reduce) {
  *,:before,:after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  .pulse { animation: none; }
  .app { backdrop-filter: none; -webkit-backdrop-filter: none; }
}

/* ===== Composer layout: stable vertical stack ===== */
.input-area {
  /* override previous row flex */
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 12px;
  padding: 16px;
  background: white;
  border-top: 1px solid var(--slate-100);
}

/* Input spans full card width */
.input-area .input-wrapper,
.input-area input[type="text"] {
  width: 100%;
}

/* Buttons row (Send / Refresh / Share) */
.composer-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;            /* wrap if space is tight, but remain one row logically */
  align-items: center;
}

/* Nice grow on wide screens without stretching too much */
.composer-actions .btn { flex: 0 0 auto; }

/* EMRLD Chain (a.k.a. decrypt/info card) sits at the bottom, full width */
.input-area .decrypt-area,
.input-area .info-banner {
  order: 3;
  align-self: stretch;
}

/* Keep it comfy on small screens; input already full-width */
@media (max-width: 768px) {
  .composer-actions { justify-content: flex-start; }
}

/* Optional: on large viewports, keep stack order but let the buttons row and info card breathe */
@container (min-width: 900px) {
  .composer-actions { gap: 16px; }
}

/* Responsive grid layout - consolidated with main .grid definition below */
@media (min-width: 880px) {
  .grid {
    grid-template-columns: 1fr 1fr; /* desktop: 2 cols */
  }
  .grid > .card:nth-child(3) {
    grid-column: 1 / -1;
    justify-self: center;
    max-width: 720px;
    width: 100%;
  }
}

/* Consolidated grid centering - removed duplicate .grid definition above */
.grid {
  display: grid;
  gap: 24px;
  grid-template-columns: 1fr;
  justify-items: center;
}

.grid > .card {
  width: 100%;
  max-width: 520px;
  align-self: start;
  overflow: visible;
}

/* features card can be a bit wider */
.features-card{
  max-width:760px;
  margin-bottom:32px;
}

/* --- Make sure cards never clip content --- */
.card {
  background: #fff;
  border: 1px solid var(--slate-200);
  border-radius: 16px;
  padding: 24px;
  box-shadow: var(--shadow-sm);
  overflow: visible;                       /* <- prevents "cut off" */
  align-self: start;                       /* grow by content, not row height */
}

/* ---- Features list: centered block + SVG bullets ---- */
.features{ text-align:center; }
.features h3{ margin-bottom:12px; }

.features ul{
  list-style:none;
  padding:0;
  margin:12px auto 0;
  display:inline-block;              /* centers the whole list */
  text-align:left;                   /* but keep text left inside */
  max-width:42rem;
}

.features li{
  display:flex;
  align-items:flex-start;
  gap:12px;
  padding:8px 0;
  line-height:var(--line-height-relaxed);
}

.features li::before{
  content:"";
  flex:0 0 18px;
  width:18px;
  height:18px;
  margin-top:3px;                    /* align with first line of text */
  background:url("/logo_ani01.svg") no-repeat center / contain;
}

/* remove any old checkmark bullet styling */
.features li::marker{ content:none; }

:root {
  color-scheme: light !important;
}

.message .encryption-badge {
  font-size: 0.25rem;   /* much smaller text */
  padding: 1px 3px;     /* shrink badge box */
  border-radius: 3px;   /* smaller rounded corners */
  transform: scale(0.75); /* 75% of original size */
  transform-origin: left center; /* keeps alignment neat */
}

.btn-invite {
  background-color: #d97706;   /* dusky orange */
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 10px 18px;
  font-weight: 600;
  transition: background-color 0.2s ease, transform 0.1s ease;
}

.btn-invite:hover {
  background-color: #b45309;   /* deeper shade */
  transform: translateY(-1px);
}

.btn-invite:active {
  background-color: #92400e;   /* pressed shade */
  transform: translateY(0);
}

/* ===== CONTRAST + SELECTOR FIX PATCH (append at end) ===== */

/* 1) ID/class mismatch: your HTML uses #setupScreen, CSS styles .setup-screen */
#setupScreen {
  padding: 48px;
  text-align: center;
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  overflow-y: auto;
}
#setupScreen .subtitle {
  color: var(--slate-600);
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-medium);
  margin-bottom: 40px;
  line-height: var(--line-height-normal);
}

/* 2) Make headings/labels/list copy darker for AA+ legibility */
#setupScreen .card h3 {                 /* "Start a Secure Chat" / "Join Existing Room" */
  color: var(--slate-900);
  font-weight: var(--font-weight-bold);
  letter-spacing: var(--letter-spacing-tight);
}

/* "Room Name", "Room Password", "Your Name" (both Create/Join) */
#setupScreen .form-group label {
  color: var(--slate-800);
  font-weight: var(--font-weight-semibold);
}

/* Placeholders: a touch darker so they’re readable but still secondary */
#setupScreen input::placeholder,
#setupScreen textarea::placeholder {
  color: var(--slate-400);
  opacity: 0.6;
}

/* 3) Features card: "Key-forge Security" heading + list items */
.features-card .features h3 {
  color: var(--slate-900);
  font-weight: var(--font-weight-bold);
}
.features-card .features li {
  color: var(--slate-800);
  font-weight: var(--font-weight-normal);
  line-height: var(--line-height-relaxed);
}

/* Make the svg-bullet feel a bit stronger next to darker text */
.features-card .features li::before {
  opacity: 0.9;
}

/* 4) Dark theme: tokens already flip, but these ensure excellent contrast */
@media (prefers-color-scheme: dark) {
  #setupScreen .card h3,
  .features-card .features h3 { color: var(--slate-800); }
  #setupScreen .form-group label,
  .features-card .features li { color: var(--slate-700); }
  #setupScreen input::placeholder,
  #setupScreen textarea::placeholder { color: var(--slate-400); opacity: 0.6; }
}

/* If you’re using data-theme="dark" toggles */
[data-theme="dark"] #setupScreen .card h3,
[data-theme="dark"] .features-card .features h3 { color: var(--slate-800); }
[data-theme="dark"] #setupScreen .form-group label,
[data-theme="dark"] .features-card .features li { color: var(--slate-700); }
[data-theme="dark"] #setupScreen input::placeholder,
[data-theme="dark"] #setupScreen textarea::placeholder { color: var(--slate-400); opacity: 0.6; }

/* === Auth visibility fix === */
#verificationScreen.hidden,
#setupScreen.hidden,
#chatScreen.hidden {
  display: none;
}

/* Only show panels when NOT hidden */
#setupScreen:not(.hidden),
#chatScreen:not(.hidden) {
  display: flex;
  flex-direction: column;
}

/* Keep layout styles on the element, not its visibility */
#setupScreen {
  padding: 48px;
  text-align: center;
  flex: 1;
  justify-content: flex-start;
  overflow-y: auto;
}

:root {
  color-scheme: light !important;
}

@media (prefers-color-scheme: dark) {
  body,
  .app {
    background: #ffffff !important;
    color: #000000 !important;
  }
}

/* Frosted header card for setup screen */
#setupScreen .header {
  background: rgba(255, 255, 255, 0.55);  /* lighter translucent white */
  backdrop-filter: blur(14px) saturate(180%);
  -webkit-backdrop-filter: blur(14px) saturate(180%);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  box-shadow: var(--shadow-md);
  color: var(--slate-800);
  border: 1px solid rgba(255, 255, 255, 0.25);
}

/* Subtitle muted for readability */
#setupScreen .header .subtitle {
  color: var(--slate-700);
}

/* Logo text pops a little */
#setupScreen .header .logo-text {
  filter: drop-shadow(0 2px 3px rgba(0,0,0,0.12));
}

/* Frosted info-banner */
.info-banner {
  background: rgba(255, 255, 255, 0.55);  /* translucent white */
  backdrop-filter: blur(14px) saturate(180%);
  -webkit-backdrop-filter: blur(14px) saturate(180%);
  border-radius: var(--radius-lg);
  padding: var(--space-5) var(--space-6);
  margin: var(--space-6) 0;
  text-align: center;
  font-weight: var(--font-weight-medium);
  color: var(--slate-800);
  box-shadow: var(--shadow-sm);
  border: 1px solid rgba(255, 255, 255, 0.25);
}

/* Strong text */
.info-banner strong {
  font-weight: var(--font-weight-semibold);
  color: var(--emerald-800);
}

/* Subtext */
.info-banner br + * {
  color: var(--slate-600);
  font-size: var(--font-size-sm);
}

/* Frosted tabs bar */
.tabs {
  background: rgba(255, 255, 255, 0.55);   /* translucent white */
  backdrop-filter: blur(14px) saturate(180%);
  -webkit-backdrop-filter: blur(14px) saturate(180%);
  border-radius: var(--radius-lg);
  padding: var(--space-3) var(--space-4);
  margin: var(--space-6) 0;
  display: flex;
  gap: var(--space-2);
  justify-content: center;
  box-shadow: var(--shadow-sm);
  border: 1px solid rgba(255, 255, 255, 0.25);
}

/* Tabs themselves (Forge / Join) */
.tabs .tab {
  background: transparent; /* let frosted panel show through */
  border: none;
  color: var(--slate-700);
  font-weight: var(--font-weight-medium);
  padding: var(--space-2) var(--space-5);
  border-radius: var(--radius-md);
  transition: background 0.2s ease, color 0.2s ease;
}

/* Active tab pops */
.tabs .tab.active {
  background: var(--emerald-500);
  color: white;
  box-shadow: var(--shadow-emerald);
}

/* Hover state */
.tabs .tab:hover {
  background: rgba(255, 255, 255, 0.35);
  color: var(--emerald-800);
}

/* === Frosted Glass Patch for Header, Info Banner & Tabs === */

/* Frosted header card */
#setupScreen .header {
  background: rgba(255, 255, 255, 0.35);   /* lighter translucent white */
  backdrop-filter: blur(14px) saturate(180%);
  -webkit-backdrop-filter: blur(14px) saturate(180%);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  box-shadow: var(--shadow-md);
  color: var(--slate-800);
  border: 1px solid rgba(255, 255, 255, 0.18);
}

/* Frosted info-banner */
.info-banner {
  background: rgba(255, 255, 255, 0.35);
  backdrop-filter: blur(14px) saturate(180%);
  -webkit-backdrop-filter: blur(14px) saturate(180%);
  border-radius: var(--radius-lg);
  padding: var(--space-5) var(--space-6);
  margin: var(--space-6) 0;
  text-align: center;
  font-weight: var(--font-weight-medium);
  color: var(--slate-800);
  box-shadow: var(--shadow-sm);
  border: 1px solid rgba(255, 255, 255, 0.18);
}

/* Frosted tabs bar */
.tabs {
  background: rgba(255, 255, 255, 0.35);
  backdrop-filter: blur(14px) saturate(180%);
  -webkit-backdrop-filter: blur(14px) saturate(180%);
  border-radius: var(--radius-lg);
  padding: var(--space-3) var(--space-4);
  margin: var(--space-6) 0;
  display: flex;
  gap: var(--space-2);
  justify-content: center;
  box-shadow: var(--shadow-sm);
  border: 1px solid rgba(255, 255, 255, 0.18);
}

/* Tabs */
.tabs .tab {
  background: rgba(255, 255, 255, 0.2);  /* subtle frosted pill */
  border: none;
  color: var(--slate-700);
  font-weight: var(--font-weight-medium);
  padding: var(--space-2) var(--space-5);
  border-radius: var(--radius-md);
  transition: background 0.2s ease, color 0.2s ease;
}

/* Active tab */
.tabs .tab.active,
.tab[aria-selected="true"] {
  background: var(--emerald-500);
  color: #fff;
  box-shadow: var(--shadow-emerald);
}

/* Hover tab */
.tabs .tab:hover:not(.active):not([aria-selected="true"]) {
  background: rgba(255, 255, 255, 0.35);
  color: var(--emerald-800);
}
