/* ============================================================
   WolfPack Messenger - Styles
   WolfTech CyberSecurity Dark Theme
   ============================================================ */

/* ---------- Design Tokens ---------- */
:root {
  --primary: #2D8CCA;
  --primary-hover: #2479b3;
  --primary-light: rgba(45, 140, 202, 0.1);
  --primary-faded: rgba(45, 140, 202, 0.25);
  --bg-body: #1a1a1a;
  --bg-dark: #222222;
  --bg-card: #2a2a2a;
  --bg-input: #333333;
  --bg-hover: #353535;
  --text-primary: #FFFFFF;
  --text-secondary: rgba(255, 255, 255, 0.6);
  --text-muted: rgba(255, 255, 255, 0.4);
  --border: #3a3a3a;
  --border-light: #444444;
  --success: #4CAF50;
  --success-light: rgba(76, 175, 80, 0.15);
  --error: #f44336;
  --error-light: rgba(244, 67, 54, 0.15);
  --warning: #FFC107;
  --warning-light: rgba(255, 193, 7, 0.15);
  --info: #2D8CCA;
  --info-light: rgba(45, 140, 202, 0.15);
  --radius: 8px;
  --radius-sm: 4px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-full: 9999px;
  --font: "Inter Tight", -apple-system, "system-ui", "Segoe UI", Roboto, sans-serif;
  --font-mono: "SF Mono", "Fira Code", "Cascadia Code", "Consolas", monospace;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.4);
  --shadow-xl: 0 16px 48px rgba(0, 0, 0, 0.5);
  --transition: 0.2s ease;
  --transition-slow: 0.3s ease;
  --sidebar-width: 280px;
  --header-height: 60px;
  --input-height: 44px;
  --z-sidebar: 100;
  --z-header: 200;
  --z-modal: 1000;
  --z-toast: 1100;
  --z-offline: 900;
}

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

html {
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-primary);
  background-color: var(--bg-body);
  overflow: hidden;
  height: 100vh;
  width: 100vw;
}

a {
  color: var(--primary);
  text-decoration: none;
  transition: color var(--transition);
}

a:hover {
  color: var(--primary-hover);
  text-decoration: underline;
}

a:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

img {
  max-width: 100%;
  display: block;
}

ul, ol {
  list-style: none;
}

input, button, textarea, select {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  border: none;
  background: none;
}

/* ---------- Scrollbar Styles ---------- */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.25);
}

/* Firefox scrollbar */
* {
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.15) transparent;
}

/* ---------- Selection ---------- */
::selection {
  background: var(--primary-faded);
  color: var(--text-primary);
}

/* ---------- Focus Styles ---------- */
:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

:focus:not(:focus-visible) {
  outline: none;
}

/* ---------- #app Container ---------- */
#app {
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  position: relative;
}

/* ---------- Page System ---------- */
.page {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: none;
  opacity: 0;
  transition: opacity var(--transition-slow);
}

.page.active {
  display: flex;
  flex-direction: column;
  opacity: 1;
  animation: pageFadeIn 0.4s ease forwards;
}

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

/* ============================================================
   LANDING PAGE
   ============================================================ */
.landing-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 32px;
  background: var(--bg-dark);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

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

.logo {
  width: 40px;
  height: 40px;
}

.logo-container h1 {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.3px;
  color: var(--text-primary);
}

.landing-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
  text-align: center;
  gap: 40px;
}

.tagline {
  font-size: 36px;
  font-weight: 700;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, var(--text-primary), var(--primary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: taglineIn 0.8s ease forwards;
}

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

.landing-actions {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  justify-content: center;
  animation: actionsIn 0.8s ease 0.2s both;
}

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

.landing-features {
  display: flex;
  flex-direction: column;
  gap: 8px;
  color: var(--text-secondary);
  font-size: 15px;
  animation: featuresIn 0.8s ease 0.4s both;
}

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

.landing-features p {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.landing-features p::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  background: var(--primary);
  border-radius: 50%;
  flex-shrink: 0;
}

.landing-zero-knowledge {
  max-width: 520px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  text-align: left;
  animation: featuresIn 0.8s ease 0.5s both;
}

.landing-zero-knowledge h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 8px;
  letter-spacing: 0.02em;
}

.landing-zero-knowledge p {
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-secondary);
}

.landing-footer {
  color: var(--text-muted);
  font-size: 13px;
  animation: featuresIn 0.8s ease 0.6s both;
}

.landing-footer a {
  color: var(--primary);
  font-weight: 500;
}

/* ============================================================
   SETUP PAGE
   ============================================================ */
#setup-page {
  align-items: center;
  justify-content: center;
  background: var(--bg-body);
}

.setup-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  margin-bottom: 32px;
}

.logo-small {
  width: 48px;
  height: 48px;
}

.setup-header h2 {
  font-size: 22px;
  font-weight: 600;
  color: var(--text-primary);
  text-align: center;
}

.setup-content {
  width: 100%;
  max-width: 440px;
  padding: 0 24px;
}

.setup-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px;
  animation: cardIn 0.3s ease forwards;
}

@keyframes cardIn {
  from {
    opacity: 0;
    transform: scale(0.97);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.setup-card .form-group {
  margin-bottom: 20px;
}

.setup-card label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.setup-card .hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 6px;
  line-height: 1.4;
}

/* Recovery Passphrase Display */
.recovery-container {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
}

.recovery-warning {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 16px;
  background: var(--warning-light);
  border: 1px solid rgba(255, 193, 7, 0.3);
  border-radius: var(--radius);
  margin-bottom: 20px;
  font-size: 13px;
  color: var(--warning);
  line-height: 1.4;
}

.recovery-warning-icon {
  font-size: 18px;
  flex-shrink: 0;
  line-height: 1;
}

.recovery-words {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 20px;
}

.recovery-word {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-family: var(--font-mono);
  font-size: 13px;
  text-align: center;
  color: var(--text-primary);
  user-select: all;
}

.recovery-word .word-number {
  color: var(--text-muted);
  font-size: 10px;
  display: block;
  margin-bottom: 2px;
}

.recovery-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* Restore Flow */
.restore-options {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.restore-option {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all var(--transition);
}

.restore-option:hover {
  border-color: var(--primary);
  background: var(--primary-light);
}

.restore-option-icon {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--primary-light);
  border-radius: var(--radius);
  font-size: 20px;
  flex-shrink: 0;
}

.restore-option-text h4 {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 2px;
}

.restore-option-text p {
  font-size: 12px;
  color: var(--text-muted);
}

/* File Upload Area */
.file-upload-area {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 32px 24px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
}

.file-upload-area:hover,
.file-upload-area.drag-over {
  border-color: var(--primary);
  background: var(--primary-light);
}

.file-upload-area input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.file-upload-area .upload-icon {
  font-size: 32px;
  margin-bottom: 8px;
  color: var(--text-muted);
}

.file-upload-area p {
  font-size: 13px;
  color: var(--text-secondary);
}

.file-upload-area .file-name {
  color: var(--primary);
  font-weight: 500;
  margin-top: 8px;
}

/* ============================================================
   CHAT PAGE - LAYOUT
   ============================================================ */
.chat-layout {
  display: flex;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

/* ---------- Sidebar ---------- */
.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--bg-dark);
  border-right: 1px solid var(--border);
  z-index: var(--z-sidebar);
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  height: var(--header-height);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 8px;
}

.logo-tiny {
  width: 28px;
  height: 28px;
}

.brand-name {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.sidebar-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-muted);
}

.status-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-online {
  background: var(--success);
  box-shadow: 0 0 6px rgba(76, 175, 80, 0.5);
}

.status-offline {
  background: #666;
}

.status-connecting {
  background: var(--warning);
  animation: statusPulse 1.5s ease infinite;
}

@keyframes statusPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.sidebar-search {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.input-search {
  width: 100%;
  height: 36px;
  padding: 0 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  color: var(--text-primary);
  font-size: 13px;
  transition: border-color var(--transition);
}

.input-search::placeholder {
  color: var(--text-muted);
}

.input-search:focus {
  outline: none;
  border-color: var(--primary);
}

/* ---------- Contact List ---------- */
.contact-list {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
}

.contact-list-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  gap: 8px;
}

.contact-list-empty-icon {
  font-size: 32px;
  opacity: 0.5;
  margin-bottom: 4px;
}

.contact-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  cursor: pointer;
  transition: background var(--transition);
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  position: relative;
}

.contact-item:hover {
  background: var(--bg-hover);
}

.contact-item.active {
  background: var(--primary-light);
  border-left: 3px solid var(--primary);
  padding-left: 13px;
}

.contact-item.pending {
  background: rgba(45, 140, 202, 0.08);
  border-left: 3px solid var(--warning);
  padding-left: 13px;
}

.contact-pending-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
  margin-left: auto;
}

.contact-pending-actions .btn-small {
  padding: 4px 12px;
  font-size: 12px;
  border-radius: var(--radius);
}

.pending-preview {
  color: var(--warning);
  font-weight: 500;
}

.contact-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 600;
  color: #fff;
  flex-shrink: 0;
  position: relative;
  text-transform: uppercase;
}

.contact-avatar .avatar-status {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 2px solid var(--bg-dark);
}

.contact-details {
  flex: 1;
  min-width: 0;
}

.contact-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.contact-preview {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

.contact-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  flex-shrink: 0;
}

.contact-time {
  font-size: 11px;
  color: var(--text-muted);
}

.contact-unread {
  min-width: 18px;
  height: 18px;
  border-radius: var(--radius-full);
  background: var(--primary);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
}

/* ---------- Sidebar Actions ---------- */
.sidebar-actions {
  padding: 12px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
}

/* ============================================================
   CHAT AREA
   ============================================================ */
.chat-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--bg-body);
  position: relative;
}

/* Empty State */
.chat-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: var(--text-muted);
  gap: 12px;
  padding: 24px;
}

.chat-empty-logo {
  width: 72px;
  height: 72px;
  opacity: 0.3;
  margin-bottom: 8px;
}

.chat-empty h3 {
  font-size: 20px;
  font-weight: 600;
  color: var(--text-secondary);
}

.chat-empty p {
  font-size: 14px;
}

/* Active Chat */
.chat-active {
  display: flex;
  flex-direction: column;
  height: 100%;
}

/* Chat Header */
.chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px;
  height: var(--header-height);
  min-height: var(--header-height);
  border-bottom: 1px solid var(--border);
  background: var(--bg-dark);
  flex-shrink: 0;
  z-index: var(--z-header);
}

.chat-back-btn {
  display: none;
}

.chat-contact-info {
  flex: 1;
  min-width: 0;
}

.chat-contact-info h3 {
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.contact-status {
  font-size: 12px;
  color: var(--text-muted);
}

.contact-status.online {
  color: var(--success);
}

.chat-header-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

/* ---------- Messages ---------- */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.message-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-width: 75%;
}

.message-group.sent {
  align-self: flex-end;
  align-items: flex-end;
}

.message-group.received {
  align-self: flex-start;
  align-items: flex-start;
}

.message-bubble {
  padding: 8px 14px;
  border-radius: var(--radius-lg);
  font-size: 14px;
  line-height: 1.45;
  word-wrap: break-word;
  overflow-wrap: break-word;
  position: relative;
  animation: messageIn 0.2s ease forwards;
}

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

.message-bubble.sent {
  background: var(--primary);
  color: #fff;
  border-bottom-right-radius: var(--radius-sm);
}

.message-bubble.received {
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-bottom-left-radius: var(--radius-sm);
}

.message-meta {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
  padding: 0 4px;
}

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

.message-time {
  color: var(--text-muted);
}

.message-status {
  display: inline-flex;
  align-items: center;
  font-size: 13px;
  line-height: 1;
}

.message-status.sent-status {
  color: var(--text-muted);
}

.message-status.delivered-status {
  color: var(--text-muted);
}

.message-status.read-status {
  color: var(--primary);
}

/* Date divider */
.message-date-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 16px 0 12px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
}

.message-date-divider::before,
.message-date-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* System message */
.system-message {
  text-align: center;
  color: var(--text-muted);
  font-size: 12px;
  padding: 8px 16px;
  font-style: italic;
}

/* ---------- Chat Input Area ---------- */
.chat-input-area {
  flex-shrink: 0;
  border-top: 1px solid var(--border);
  background: var(--bg-dark);
}

.typing-indicator {
  padding: 6px 20px;
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

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

.typing-dots span {
  width: 5px;
  height: 5px;
  background: var(--text-muted);
  border-radius: 50%;
  animation: typingBounce 1.4s ease infinite;
}

.typing-dots span:nth-child(2) {
  animation-delay: 0.2s;
}

.typing-dots span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-4px); }
}

.offline-banner {
  padding: 8px 20px;
  background: var(--warning-light);
  color: var(--warning);
  font-size: 12px;
  text-align: center;
  border-bottom: 1px solid rgba(255, 193, 7, 0.2);
}

.message-form {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
}

.input-message {
  flex: 1;
  height: var(--input-height);
  padding: 0 16px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  color: var(--text-primary);
  font-size: 14px;
  transition: border-color var(--transition);
}

.input-message::placeholder {
  color: var(--text-muted);
}

.input-message:focus {
  outline: none;
  border-color: var(--primary);
}

.btn-send {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  flex-shrink: 0;
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--font);
  font-size: 14px;
  font-weight: 500;
  padding: 10px 20px;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
  user-select: none;
  text-decoration: none;
  line-height: 1;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

.btn:active:not(:disabled) {
  transform: scale(0.97);
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
}

.btn-secondary {
  background: transparent;
  color: var(--primary);
  border: 1px solid var(--primary);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--primary-light);
}

.btn-outline {
  background: transparent;
  color: var(--text-primary);
  border: 1px solid var(--border);
}

.btn-outline:hover:not(:disabled) {
  border-color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.05);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}

.btn-ghost:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
}

.btn-danger {
  background: var(--error);
  color: #fff;
}

.btn-danger:hover:not(:disabled) {
  background: #d32f2f;
}

.btn-danger-outline {
  background: transparent;
  color: var(--error);
  border: 1px solid var(--error);
}

.btn-danger-outline:hover:not(:disabled) {
  background: var(--error-light);
}

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: var(--radius);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  font-size: 18px;
}

.btn-icon:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
}

.btn-large {
  padding: 14px 32px;
  font-size: 15px;
  border-radius: var(--radius-lg);
}

.btn-small {
  padding: 6px 12px;
  font-size: 12px;
}

.btn-full {
  width: 100%;
}

/* ============================================================
   INPUTS
   ============================================================ */
.input,
.textarea {
  width: 100%;
  height: var(--input-height);
  padding: 0 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: 14px;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.input:focus,
.textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.input::placeholder,
.textarea::placeholder {
  color: var(--text-muted);
}

.input.error {
  border-color: var(--error);
}

.textarea {
  height: auto;
  min-height: 100px;
  padding: 12px 14px;
  resize: vertical;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.5;
}

.input-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.input-error-text {
  font-size: 12px;
  color: var(--error);
  margin-top: 4px;
}

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

/* Copy-able fields */
.copy-field {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  cursor: pointer;
  transition: all var(--transition);
  word-break: break-all;
}

.copy-field:hover {
  border-color: var(--primary);
}

.copy-field .copy-text {
  flex: 1;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
}

.copy-field .copy-btn-inline {
  color: var(--primary);
  font-size: 12px;
  font-weight: 500;
  flex-shrink: 0;
  white-space: nowrap;
}

/* ============================================================
   MODAL
   ============================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: overlayIn 0.2s ease forwards;
}

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

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 440px;
  max-height: 85vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-xl);
  animation: modalIn 0.25s ease forwards;
}

@keyframes modalIn {
  from {
    opacity: 0;
    transform: scale(0.95) translateY(8px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.modal-header h3 {
  font-size: 16px;
  font-weight: 600;
}

.modal-close-btn {
  font-size: 22px;
  color: var(--text-muted);
}

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

.modal-body {
  padding: 24px;
  overflow-y: auto;
}

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

.modal-body .form-group:last-child {
  margin-bottom: 0;
}

.modal-footer {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

/* Settings Modal Sections */
.settings-section {
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
}

.settings-section:first-child {
  padding-top: 0;
}

.settings-section:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.settings-section-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  gap: 12px;
}

.settings-row label {
  font-size: 13px;
  color: var(--text-secondary);
}

/* Contact Info Modal */
.contact-info-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}

.contact-info-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  font-weight: 600;
  color: #fff;
  text-transform: uppercase;
}

.contact-info-name {
  font-size: 18px;
  font-weight: 600;
}

.contact-info-status {
  font-size: 13px;
  color: var(--text-muted);
}

.fingerprint-display {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-secondary);
  background: var(--bg-input);
  padding: 10px 14px;
  border-radius: var(--radius);
  word-break: break-all;
  text-align: center;
  letter-spacing: 1px;
  line-height: 1.6;
}

/* ============================================================
   TOASTS
   ============================================================ */
.toast-container {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  max-width: 360px;
  width: 100%;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  font-size: 13px;
  line-height: 1.4;
  color: var(--text-primary);
  pointer-events: all;
  animation: toastIn 0.3s ease forwards;
  cursor: pointer;
  transition: opacity var(--transition);
}

.toast:hover {
  opacity: 0.9;
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateX(100%) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateX(0) scale(1);
  }
}

@keyframes toastOut {
  from {
    opacity: 1;
    transform: translateX(0) scale(1);
  }
  to {
    opacity: 0;
    transform: translateX(100%) scale(0.95);
  }
}

.toast.removing {
  animation: toastOut 0.3s ease forwards;
}

.toast-icon {
  font-size: 16px;
  flex-shrink: 0;
  line-height: 1;
  margin-top: 1px;
}

.toast.success {
  border-left: 3px solid var(--success);
}

.toast.success .toast-icon {
  color: var(--success);
}

.toast.error {
  border-left: 3px solid var(--error);
}

.toast.error .toast-icon {
  color: var(--error);
}

.toast.warning {
  border-left: 3px solid var(--warning);
}

.toast.warning .toast-icon {
  color: var(--warning);
}

.toast.info {
  border-left: 3px solid var(--info);
}

.toast.info .toast-icon {
  color: var(--info);
}

.toast-message {
  flex: 1;
}

/* ============================================================
   OFFLINE INDICATOR
   ============================================================ */
.offline-indicator {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 10px 16px;
  background: var(--warning);
  color: #000;
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  z-index: var(--z-offline);
  animation: slideUp 0.3s ease forwards;
}

@keyframes slideUp {
  from {
    transform: translateY(100%);
  }
  to {
    transform: translateY(0);
  }
}

/* ============================================================
   LOADING SPINNER
   ============================================================ */
.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.spinner-small {
  width: 18px;
  height: 18px;
  border-width: 2px;
}

.spinner-large {
  width: 48px;
  height: 48px;
  border-width: 4px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 40px;
  text-align: center;
}

.loading-state p {
  color: var(--text-secondary);
  font-size: 14px;
}

/* ============================================================
   PWA STANDALONE ADJUSTMENTS
   ============================================================ */
@media (display-mode: standalone) {
  .landing-header {
    padding-top: env(safe-area-inset-top, 20px);
  }

  .sidebar-header {
    padding-top: max(14px, env(safe-area-inset-top, 14px));
  }

  .chat-header {
    padding-top: env(safe-area-inset-top, 0);
  }

  .offline-indicator {
    padding-bottom: max(10px, env(safe-area-inset-bottom, 10px));
  }

  .message-form {
    padding-bottom: max(12px, env(safe-area-inset-bottom, 12px));
  }
}

/* ============================================================
   RESPONSIVE - MOBILE (<768px)
   ============================================================ */
@media (max-width: 767px) {
  .sidebar {
    position: absolute;
    width: 100%;
    min-width: 100%;
    height: 100%;
    z-index: var(--z-sidebar);
    transform: translateX(0);
    transition: transform var(--transition-slow);
  }

  .sidebar.hidden {
    transform: translateX(-100%);
  }

  .chat-area {
    position: absolute;
    width: 100%;
    height: 100%;
  }

  .chat-back-btn {
    display: inline-flex;
  }

  .chat-layout {
    position: relative;
  }

  .landing-actions {
    flex-direction: column;
    width: 100%;
    max-width: 320px;
  }

  .landing-actions .btn {
    width: 100%;
  }

  .tagline {
    font-size: 28px;
  }

  .modal {
    max-width: 100%;
    max-height: 90vh;
    border-radius: var(--radius-lg);
  }

  .modal-overlay {
    padding: 16px;
  }

  .recovery-words {
    grid-template-columns: repeat(2, 1fr);
  }

  .message-group {
    max-width: 85%;
  }

  .toast-container {
    top: 8px;
    right: 8px;
    left: 8px;
    max-width: none;
  }

  .copy-field .copy-text {
    font-size: 11px;
  }
}

/* Small mobile (<400px) */
@media (max-width: 399px) {
  .tagline {
    font-size: 24px;
  }

  .landing-main {
    gap: 28px;
    padding: 24px 16px;
  }

  .recovery-words {
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
  }

  .recovery-word {
    padding: 6px 8px;
    font-size: 12px;
  }
}

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

/* High contrast mode */
@media (prefers-contrast: high) {
  :root {
    --border: #555555;
    --text-secondary: rgba(255, 255, 255, 0.8);
    --text-muted: rgba(255, 255, 255, 0.6);
  }
}

/* Screen reader only */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* ============================================================
   UTILITIES
   ============================================================ */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }
.text-primary { color: var(--text-primary); }
.text-secondary { color: var(--text-secondary); }
.text-muted { color: var(--text-muted); }
.text-error { color: var(--error); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.font-mono { font-family: var(--font-mono); }
.font-bold { font-weight: 700; }
.font-semibold { font-weight: 600; }
.font-medium { font-weight: 500; }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-8 { margin-bottom: 8px; }
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.d-flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.w-full { width: 100%; }
.hidden { display: none !important; }
.truncate {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ============================================================
   BLOCKED USERS LIST
   ============================================================ */
.blocked-users-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.blocked-user-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: var(--bg-dark);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.blocked-user-name {
  font-size: 14px;
  color: var(--text-primary);
}
