/* ================================================================
   SonChat — Design System
   UI-UX Pro Max: Liquid Glass + Dark Cybersecurity
   
   Design System (from UI-UX Pro Max search.py):
   - Style: Liquid Glass + Dark Mode Cybersecurity hybrid
   - Colors: #2563EB primary, #3B82F6 secondary, #F97316 CTA
   - Background: #0F172A (slate-900) → #1E293B (slate-800)
   - Typography: Inter (technical, dark-mode-first)
   - Effects: backdrop-filter blur, morphing, fluid 400-600ms
   - Anti-patterns avoided: light mode, vibrant block colors
   ================================================================ */

/* ─── Custom Properties ─────────────────────────────────── */
:root {
  /* Colors — Messenger Blue palette (UI-UX Pro Max recommended) */
  --c-primary: #2563EB;
  --c-primary-l: #3B82F6;
  --c-primary-dim: rgba(37, 99, 235, 0.18);
  --c-primary-glow: rgba(59, 130, 246, 0.25);
  --c-cta: #F97316;

  /* Backgrounds — OLED Dark */
  --c-bg-base: #060C18;
  --c-bg-surface: #0F172A;
  --c-bg-elevated: #1E293B;
  --c-bg-overlay: rgba(15, 23, 42, 0.85);

  /* Liquid Glass */
  --glass-bg: rgba(255, 255, 255, 0.04);
  --glass-border: rgba(255, 255, 255, 0.09);
  --glass-blur: 20px;
  --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.05);

  /* Text */
  --c-text-primary: #F1F5F9;
  --c-text-secondary: #94A3B8;
  --c-text-muted: #475569;
  --c-text-accent: #60A5FA;

  /* States */
  --c-success: #22C55E;
  --c-danger: #EF4444;
  --c-warn: #F97316;

  /* Borders */
  --border: rgba(255, 255, 255, 0.08);
  --border-accent: rgba(59, 130, 246, 0.4);
  --border-focus: rgba(59, 130, 246, 0.7);

  /* Typography — Inter (UI-UX Pro Max: technical, dark-mode) */
  --font-sans: 'Inter', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

  /* Spacing scale */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;

  /* Border radius */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-xl: 24px;
  --radius-full: 9999px;

  /* Animation — Liquid Glass: 400-600ms curves */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --dur-fast: 150ms;
  --dur-base: 250ms;
  --dur-slow: 450ms;
  --dur-morph: 550ms;
}

/* ─── Reset ─────────────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: var(--font-sans);
  background: var(--c-bg-base);
  color: var(--c-text-primary);
  -webkit-font-smoothing: antialiased;
  line-height: 1.6;
}

/* Accessibility ─ focus ring */
:focus-visible {
  outline: 2px solid var(--c-primary-l);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* Visually hidden (accessible) */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Ensure [hidden] attribute works regardless of other display rules */
[hidden] {
  display: none !important;
}

/* ─── Views ─────────────────────────────────────────────── */
.view {
  height: 100vh;
  display: none;
}

.view.active {
  display: flex;
}

/* ─── Liquid Glass component ─────────────────────────────── */
.liquid-glass {
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur)) saturate(160%);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(160%);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
}

/* ================================================================
   AUTH VIEW
================================================================ */
#auth-view {
  align-items: center;
  justify-content: center;
  position: relative;
  background: var(--c-bg-base);
}

/* Animated mesh gradient background */
.bg-mesh {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.mesh-node {
  position: absolute;
  border-radius: 50%;
  mix-blend-mode: screen;
  filter: blur(100px);
  animation: mesh-drift var(--dur-morph, 10s) ease-in-out infinite alternate;
}

.n1 {
  width: 700px;
  height: 700px;
  background: radial-gradient(circle, rgba(37, 99, 235, 0.18) 0%, transparent 70%);
  top: -200px;
  left: -150px;
  animation-duration: 14s;
}

.n2 {
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, rgba(59, 130, 246, 0.12) 0%, transparent 70%);
  bottom: -100px;
  right: -100px;
  animation-duration: 18s;
  animation-delay: -5s;
}

.n3 {
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, rgba(249, 115, 22, 0.07) 0%, transparent 70%);
  top: 30%;
  right: 15%;
  animation-duration: 22s;
  animation-delay: -9s;
}

.n4 {
  width: 300px;
  height: 300px;
  background: radial-gradient(circle, rgba(99, 102, 241, 0.09) 0%, transparent 70%);
  bottom: 20%;
  left: 25%;
  animation-duration: 16s;
  animation-delay: -3s;
}

@keyframes mesh-drift {
  0% {
    transform: translate(0, 0) scale(1);
  }

  100% {
    transform: translate(40px, 25px) scale(1.08);
  }
}

/* Scanlines overlay (dark tech aesthetic) */
.scanlines {
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(0deg,
      transparent,
      transparent 2px,
      rgba(0, 0, 0, 0.03) 2px,
      rgba(0, 0, 0, 0.03) 4px);
  pointer-events: none;
}

/* Auth layout */
.auth-wrap {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-5);
  width: 100%;
  max-width: 420px;
  padding: var(--space-4);
  animation: auth-in var(--dur-slow) var(--ease-spring) both;
}

@keyframes auth-in {
  from {
    opacity: 0;
    transform: translateY(24px) scale(0.96);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Brand */
.auth-brand {
  text-align: center;
}

.brand-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: var(--space-3);
  filter: drop-shadow(0 0 16px rgba(59, 130, 246, 0.5));
}

.brand-text {
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.5px;
  line-height: 1;
  margin-bottom: 6px;
}

.brand-son {
  color: var(--c-primary-l);
}

.brand-chat {
  color: var(--c-text-primary);
}

.brand-sub {
  font-size: 12px;
  font-family: var(--font-mono);
  color: var(--c-text-muted);
  letter-spacing: 0.5px;
}

/* Auth card */
.auth-card {
  width: 100%;
  border-radius: var(--radius-xl);
  padding: var(--space-5);
  overflow: hidden;
}

/* Tab bar */
.tab-bar {
  display: flex;
  position: relative;
  background: rgba(0, 0, 0, 0.3);
  border-radius: var(--radius-md);
  padding: 3px;
  margin-bottom: var(--space-5);
}

.tab {
  flex: 1;
  padding: 9px var(--space-3);
  border-radius: calc(var(--radius-md) - 3px);
  font-size: 14px;
  font-weight: 500;
  color: var(--c-text-muted);
  transition: color var(--dur-base) var(--ease-out);
  position: relative;
  z-index: 1;
  cursor: pointer;
  background: none;
  border: none;
}

.tab.active {
  color: var(--c-text-primary);
}

.tab:hover:not(.active) {
  color: var(--c-text-secondary);
}

/* Sliding indicator */
.tab-indicator {
  position: absolute;
  top: 3px;
  bottom: 3px;
  left: 3px;
  width: calc(50% - 3px);
  background: var(--c-bg-elevated);
  border-radius: calc(var(--radius-md) - 3px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  transition: transform var(--dur-base) var(--ease-out);
}

.tab-indicator.right {
  transform: translateX(100%);
}

/* Auth form */
.auth-form {
  display: none;
  flex-direction: column;
  gap: var(--space-4);
}

.auth-form.active {
  display: flex;
}

/* Field */
.field-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.field-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--c-text-secondary);
}

.field-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.field-icon {
  position: absolute;
  left: 13px;
  color: var(--c-text-muted);
  pointer-events: none;
  width: 16px;
  height: 16px;
  transition: color var(--dur-base) var(--ease-out);
}

.field-input {
  width: 100%;
  padding: 11px 14px 11px 40px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--c-text-primary);
  font-size: 14px;
  font-family: var(--font-sans);
  transition: border-color var(--dur-base) var(--ease-out), box-shadow var(--dur-base) var(--ease-out);
  outline: none;
}

.field-input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--c-primary-dim);
}

.field-input::placeholder {
  color: var(--c-text-muted);
}

.field-input:focus+.field-icon,
.field-wrap:focus-within .field-icon {
  color: var(--c-primary-l);
}

/* Key gen notice */
.keygen-notice {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 9px 12px;
  background: rgba(37, 99, 235, 0.08);
  border: 1px solid rgba(59, 130, 246, 0.2);
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-family: var(--font-mono);
  color: var(--c-text-accent);
}

.keygen-notice svg {
  color: var(--c-primary-l);
  flex-shrink: 0;
}

.keygen-progress {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.keygen-track {
  height: 3px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.keygen-fill {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--c-primary), var(--c-primary-l));
  border-radius: var(--radius-full);
  animation: key-fill 2.2s var(--ease-out) forwards;
}

@keyframes key-fill {
  0% {
    width: 0;
  }

  40% {
    width: 45%;
  }

  75% {
    width: 78%;
  }

  100% {
    width: 98%;
  }
}

.keygen-text {
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--c-text-muted);
}

/* Form error */
.form-error {
  padding: 10px 14px;
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--c-danger);
}

/* Buttons */
.btn-primary {
  width: 100%;
  padding: 12px;
  background: var(--c-primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-md);
  font-size: 15px;
  font-weight: 600;
  font-family: var(--font-sans);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  transition: background var(--dur-fast), transform var(--dur-fast), box-shadow var(--dur-base);
  position: relative;
  overflow: hidden;
}

.btn-primary::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.1), transparent);
  pointer-events: none;
}

.btn-primary:hover {
  background: var(--c-primary-l);
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(37, 99, 235, 0.4);
}

.btn-primary:active {
  transform: translateY(0);
  box-shadow: none;
}

.btn-primary:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-secondary {
  padding: 8px 16px;
  background: var(--c-bg-elevated);
  color: var(--c-text-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--dur-fast), border-color var(--dur-fast);
}

.btn-secondary:hover {
  background: rgba(59, 130, 246, 0.1);
  border-color: var(--border-accent);
  color: var(--c-primary-l);
}

/* Spinner */
.btn-spin {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Icon button */
.icon-btn {
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--c-text-secondary);
  transition: background var(--dur-fast), color var(--dur-fast);
  cursor: pointer;
  background: none;
  border: none;
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.07);
  color: var(--c-text-primary);
}

/* Auth footer */
.auth-footer {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--c-text-muted);
  text-align: center;
}

.auth-footer svg {
  color: var(--c-text-muted);
  flex-shrink: 0;
}

/* ================================================================
   CHAT VIEW
================================================================ */
#chat-view {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ─── Sidebar ─────────────────────────────────────────────── */
.sidebar {
  width: 272px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: var(--c-bg-surface);
  border-right: 1px solid var(--border);
  overflow: hidden;
}

.sidebar-top {
  padding: var(--space-4) var(--space-4) var(--space-3);
  border-bottom: 1px solid var(--border);
}

.sidebar-brand {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: var(--space-4);
}

/* User chip */
.user-chip {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
}

.user-chip-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--c-primary), var(--c-primary-l));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.user-chip-info {
  flex: 1;
  min-width: 0;
}

.user-chip-name {
  font-size: 14px;
  font-weight: 600;
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-chip-status {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--c-success);
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--c-success);
  animation: dot-pulse 2.4s ease-in-out infinite;
}

@keyframes dot-pulse {

  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }

  50% {
    opacity: 0.5;
    transform: scale(0.85);
  }
}

/* Search box */
.search-box {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 10px;
  color: var(--c-text-muted);
  pointer-events: none;
}

.search-box input {
  width: 100%;
  padding: 8px 12px 8px 32px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--c-text-primary);
  font-size: 13px;
  font-family: var(--font-sans);
  outline: none;
  transition: border-color var(--dur-fast);
}

.search-box input:focus {
  border-color: var(--border-accent);
}

.search-box input::placeholder {
  color: var(--c-text-muted);
}

/* Contact list */
.sidebar-section-label {
  padding: 12px var(--space-4) 4px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--c-text-muted);
  font-family: var(--font-mono);
}

.contact-list {
  flex: 1;
  overflow-y: auto;
  list-style: none;
  padding: 4px 8px;
}

.contact-empty {
  padding: var(--space-5) var(--space-4);
  text-align: center;
  font-size: 13px;
  color: var(--c-text-muted);
  font-style: italic;
}

.contact-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 9px var(--space-3);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background var(--dur-fast);
  position: relative;
}

.contact-item:hover {
  background: rgba(255, 255, 255, 0.05);
}

.contact-item.active {
  background: var(--c-primary-dim);
  border: 1px solid rgba(59, 130, 246, 0.25);
}

.contact-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--c-bg-elevated);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
  color: var(--c-text-secondary);
  flex-shrink: 0;
  position: relative;
}

.contact-item.online .contact-avatar::after {
  content: '';
  position: absolute;
  bottom: 1px;
  right: 1px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--c-success);
  border: 2px solid var(--c-bg-surface);
}

.contact-info {
  flex: 1;
  min-width: 0;
}

.contact-name {
  font-size: 14px;
  font-weight: 500;
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.contact-badge {
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--c-text-muted);
}

.contact-item.online .contact-badge {
  color: var(--c-success);
}

/* Unread indicator */
.unread-dot {
  width: 8px;
  height: 8px;
  background: var(--c-primary-l);
  border-radius: 50%;
  box-shadow: 0 0 10px var(--c-primary-glow);
  flex-shrink: 0;
  margin-left: auto;
  animation: unread-pulse 2s infinite;
}

@keyframes unread-pulse {
  0% {
    transform: scale(1);
    box-shadow: 0 0 0 0 var(--c-primary-glow);
  }

  70% {
    transform: scale(1.1);
    box-shadow: 0 0 10px 4px rgba(59, 130, 246, 0);
  }

  100% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(59, 130, 246, 0);
  }
}

/* Lock badge */
.sidebar-lock-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: var(--space-3) var(--space-4);
  border-top: 1px solid var(--border);
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--c-primary-l);
}

.sidebar-lock-badge svg {
  color: var(--c-primary-l);
  flex-shrink: 0;
}

/* ─── Main chat area ──────────────────────────────────────── */
.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--c-bg-surface);
  background-image: radial-gradient(ellipse at 80% 50%, rgba(37, 99, 235, 0.04) 0%, transparent 60%);
}

/* Empty state */
.empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-4);
  padding: var(--space-6);
}

.empty-icon {
  opacity: 0.75;
}

.empty-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--c-text-secondary);
}

.empty-desc {
  font-size: 14px;
  color: var(--c-text-muted);
  text-align: center;
  line-height: 1.8;
  font-family: var(--font-mono);
}

/* Chat window */
.chat-window {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* Chat header */
.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px var(--space-5);
  background: var(--c-bg-elevated);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.chat-header-left {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.chat-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--c-bg-surface);
  border: 1.5px solid var(--border-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 600;
  color: var(--c-text-primary);
}

.chat-header-name {
  font-size: 15px;
  font-weight: 600;
  display: block;
}

.chat-header-enc {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--c-primary-l);
}

.chat-header-enc svg {
  color: var(--c-primary-l);
}

/* Messages */
.messages-scroll {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-5);
  display: flex;
  flex-direction: column;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.messages-scroll::-webkit-scrollbar {
  width: 4px;
}

.messages-scroll::-webkit-scrollbar-track {
  background: transparent;
}

.messages-scroll::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: var(--radius-full);
}

.messages-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Message bubbles */
.message-wrap {
  display: flex;
  flex-direction: column;
  animation: msg-in var(--dur-slow) var(--ease-spring) both;
}

@keyframes msg-in {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.97);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.message-wrap.self {
  align-items: flex-end;
}

.message-wrap.other {
  align-items: flex-start;
}

.message-bubble {
  max-width: 68%;
  padding: 10px 15px;
  border-radius: var(--radius-lg);
  font-size: 14.5px;
  line-height: 1.55;
  word-break: break-word;
  position: relative;
}

.message-wrap.self .message-bubble {
  background: var(--c-primary-dim);
  border: 1px solid rgba(59, 130, 246, 0.3);
  border-bottom-right-radius: 4px;
  /* Liquid Glass effect on self bubble */
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.message-wrap.other .message-bubble {
  background: var(--glass-bg);
  backdrop-filter: blur(8px) saturate(140%);
  -webkit-backdrop-filter: blur(8px) saturate(140%);
  border: 1px solid var(--glass-border);
  border-bottom-left-radius: 4px;
}

.message-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--c-text-muted);
}

.message-wrap.self .message-meta {
  flex-direction: row-reverse;
}

.enc-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 1px 7px;
  background: rgba(37, 99, 235, 0.12);
  border: 1px solid rgba(59, 130, 246, 0.25);
  border-radius: var(--radius-full);
  font-size: 10px;
  color: var(--c-primary-l);
  font-family: var(--font-mono);
}

.enc-badge svg {
  width: 9px;
  height: 9px;
}

/* Self-destruct badge */
.destruct-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 1px 7px;
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.25);
  border-radius: var(--radius-full);
  font-size: 10px;
  color: var(--c-danger);
  font-family: var(--font-mono);
  transition: opacity var(--dur-fast);
}

.destruct-badge.urgent {
  animation: destruct-pulse 0.8s ease-in-out infinite;
}

@keyframes destruct-pulse {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.4;
  }
}

/* File message */
.message-file {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 10px 14px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: border-color var(--dur-fast), background var(--dur-fast);
  text-decoration: none;
  max-width: 260px;
}

.message-file:hover {
  border-color: var(--border-accent);
  background: rgba(37, 99, 235, 0.08);
}

.message-file svg {
  color: var(--c-primary-l);
  flex-shrink: 0;
}

.message-file-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.message-file-name {
  font-size: 13px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.message-file-size {
  font-size: 11px;
  color: var(--c-text-muted);
  font-family: var(--font-mono);
}

/* Typing indicator */
.typing-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 6px 0;
  font-size: 13px;
  font-family: var(--font-mono);
  color: var(--c-text-muted);
}

.typing-dots {
  display: flex;
  gap: 3px;
  align-items: center;
}

.typing-dots span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--c-text-muted);
  animation: typing-bounce 1.4s ease-in-out infinite;
}

.typing-dots span:nth-child(2) {
  animation-delay: 0.2s;
}

.typing-dots span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes typing-bounce {

  0%,
  80%,
  100% {
    transform: scale(0.75);
    opacity: 0.5;
  }

  40% {
    transform: scale(1.1);
    opacity: 1;
  }
}

/* ─── Input area ──────────────────────────────────────────── */
.input-area {
  padding: var(--space-3) var(--space-4) var(--space-4);
  background: var(--c-bg-elevated);
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  flex-shrink: 0;
}

/* Self-destruct row */
.destruct-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: 12px;
  font-family: var(--font-mono);
  color: var(--c-text-secondary);
}

.toggle-wrap {
  position: relative;
  display: inline-flex;
  cursor: pointer;
}

.toggle-wrap input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-track {
  display: block;
  width: 34px;
  height: 18px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  transition: background var(--dur-base), border-color var(--dur-base);
  position: relative;
}

.toggle-track::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--c-text-muted);
  transition: transform var(--dur-base) var(--ease-out), background var(--dur-base);
}

.toggle-wrap input:checked+.toggle-track {
  background: rgba(239, 68, 68, 0.2);
  border-color: rgba(239, 68, 68, 0.4);
}

.toggle-wrap input:checked+.toggle-track::after {
  transform: translateX(16px);
  background: var(--c-danger);
}

.destruct-label {
  color: var(--c-text-secondary);
}

.destruct-select {
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--c-danger);
  font-size: 12px;
  font-family: var(--font-mono);
  padding: 2px 6px;
  cursor: pointer;
  outline: none;
}

/* File preview bar */
.file-preview-bar {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 7px 12px;
  background: rgba(37, 99, 235, 0.08);
  border: 1px solid rgba(59, 130, 246, 0.2);
  border-radius: var(--radius-md);
  font-size: 13px;
}

.file-preview-bar svg {
  color: var(--c-primary-l);
  flex-shrink: 0;
}

.file-preview-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
}

.file-preview-size {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--c-text-muted);
}

.file-cancel-btn {
  width: 26px;
  height: 26px;
  flex-shrink: 0;
}

/* Input row */
.input-row {
  display: flex;
  align-items: flex-end;
  gap: var(--space-2);
}

.attach-btn {
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  color: var(--c-text-muted);
  transition: border-color var(--dur-fast), color var(--dur-fast), background var(--dur-fast);
}

.attach-btn:hover {
  border-color: var(--border-accent);
  color: var(--c-primary-l);
  background: var(--c-primary-dim);
}

.msg-input-wrap {
  flex: 1;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: border-color var(--dur-fast), box-shadow var(--dur-fast);
}

.msg-input-wrap:focus-within {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--c-primary-dim);
}

.msg-input {
  width: 100%;
  padding: 10px 14px;
  background: none;
  color: var(--c-text-primary);
  font-size: 14px;
  font-family: var(--font-sans);
  resize: none;
  outline: none;
  border: none;
  max-height: 130px;
  overflow-y: auto;
  line-height: 1.55;
  scrollbar-width: thin;
}

.msg-input::placeholder {
  color: var(--c-text-muted);
}

.send-btn {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  background: var(--c-primary);
  border: none;
  border-radius: var(--radius-md);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background var(--dur-fast), transform var(--dur-fast), box-shadow var(--dur-base);
}

.send-btn:hover {
  background: var(--c-primary-l);
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.4);
}

.send-btn:active {
  transform: translateY(0);
  box-shadow: none;
}

/* ─── Modal ───────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(6, 12, 24, 0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
  animation: overlay-in var(--dur-base) var(--ease-out);
}

@keyframes overlay-in {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

.modal {
  width: min(480px, 92vw);
  border-radius: var(--radius-xl);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.6);
  animation: modal-in var(--dur-slow) var(--ease-spring);
}

@keyframes modal-in {
  from {
    opacity: 0;
    transform: scale(0.92);
  }

  to {
    opacity: 1;
    transform: scale(1);
  }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-5) var(--space-5) 0;
}

.modal-title {
  font-size: 16px;
  font-weight: 600;
}

.modal-body {
  padding: var(--space-4) var(--space-5) var(--space-5);
}

.modal-desc {
  font-size: 13px;
  color: var(--c-text-secondary);
  margin-bottom: var(--space-3);
  font-family: var(--font-mono);
}

.key-block {
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  font-size: 10px;
  font-family: var(--font-mono);
  color: var(--c-primary-l);
  word-break: break-all;
  max-height: 200px;
  overflow-y: auto;
  white-space: pre-wrap;
  margin-bottom: var(--space-4);
  line-height: 1.6;
}

/* ─── Toast stack ─────────────────────────────────────────── */
.toast-stack {
  position: fixed;
  bottom: var(--space-5);
  right: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  z-index: 9999;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 16px;
  background: var(--c-bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 13px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  animation: toast-in var(--dur-base) var(--ease-spring);
  min-width: 220px;
  max-width: 340px;
}

.toast.success {
  border-color: rgba(34, 197, 94, 0.3);
}

.toast.error {
  border-color: rgba(239, 68, 68, 0.3);
}

.toast.info {
  border-color: rgba(59, 130, 246, 0.3);
}

.toast-icon-success {
  color: var(--c-success);
  flex-shrink: 0;
}

.toast-icon-error {
  color: var(--c-danger);
  flex-shrink: 0;
}

.toast-icon-info {
  color: var(--c-primary-l);
  flex-shrink: 0;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateX(18px);
  }

  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.toast.hiding {
  animation: toast-out var(--dur-base) var(--ease-out) forwards;
}

@keyframes toast-out {
  from {
    opacity: 1;
    transform: translateX(0);
    max-height: 80px;
  }

  to {
    opacity: 0;
    transform: translateX(18px);
    max-height: 0;
    padding: 0;
    margin: 0;
  }
}

/* ─── Date separator ──────────────────────────────────────── */
.date-sep {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 6px 0;
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--c-text-muted);
}

.date-sep::before,
.date-sep::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ─── Scrollbars ─────────────────────────────────────────── */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

*::-webkit-scrollbar {
  width: 4px;
}

*::-webkit-scrollbar-track {
  background: transparent;
}

*::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: var(--radius-full);
}