/* pq-crypto-chat — application theme */

:root {
  --app-font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --app-font-mono: 'JetBrains Mono', ui-monospace, 'Cascadia Code', monospace;
  --app-primary: #2563eb;
  --app-primary-hover: #1d4ed8;
  --app-primary-subtle: #eff6ff;
  --app-accent: #0d9488;
  --app-slate-950: #020617;
  --app-slate-900: #0f172a;
  --app-slate-800: #1e293b;
  --app-slate-700: #334155;
  --app-slate-600: #475569;
  --app-slate-500: #64748b;
  --app-slate-400: #94a3b8;
  --app-slate-300: #cbd5e1;
  --app-slate-200: #e2e8f0;
  --app-slate-100: #f1f5f9;
  --app-slate-50: #f8fafc;
  --app-surface: #ffffff;
  --app-surface-alt: #f8f9fa;
  --app-border: #e2e8f0;
  --app-text-muted: #64748b;
  --app-alert-warning-bg: #fffbeb;
  --app-alert-warning-text: #92400e;
  --app-alert-success-bg: #ecfdf5;
  --app-alert-success-text: #065f46;
  --app-alert-danger-bg: #fef2f2;
  --app-alert-danger-text: #991b1b;
  --app-radius: 0.5rem;
  --app-radius-lg: 0.75rem;
  --app-radius-xl: 1rem;
  --app-nav-height: 3.5rem;
  --bs-primary: var(--app-primary);
  --bs-primary-rgb: 37, 99, 235;
  --bs-body-font-family: var(--app-font);
  --bs-body-bg: var(--app-slate-50);
  --bs-body-color: var(--app-slate-800);
  --bs-border-color: var(--app-border);
  --bs-secondary-color: var(--app-text-muted);
  --bs-link-color: var(--app-primary);
  --bs-link-hover-color: var(--app-primary-hover);
}

[data-theme='dark'] {
  color-scheme: dark;
  --app-primary: #60a5fa;
  --app-primary-hover: #93c5fd;
  --app-primary-subtle: #1e3a5f;
  --app-slate-50: #0f172a;
  --app-slate-100: #334155;
  --app-surface: #1e293b;
  --app-surface-alt: #0f172a;
  --app-border: #475569;
  --app-text-muted: #94a3b8;
  --app-text-strong: #f1f5f9;
  --app-alert-warning-bg: #422006;
  --app-alert-warning-text: #fde68a;
  --app-alert-success-bg: #052e16;
  --app-alert-success-text: #86efac;
  --app-alert-danger-bg: #450a0a;
  --app-alert-danger-text: #fca5a5;
  --bs-primary-rgb: 96, 165, 250;
  --bs-body-bg: #020617;
  --bs-body-color: #e2e8f0;
  --bs-border-color: var(--app-border);
  --bs-secondary-color: var(--app-text-muted);
  --bs-link-color: var(--app-primary);
  --bs-link-hover-color: var(--app-primary-hover);
}

[data-theme='dark'] body {
  background: var(--bs-body-bg);
  color: var(--bs-body-color);
}

[data-theme='dark'] .chat-header #peerName,
[data-theme='dark'] .app-auth-header h1,
[data-theme='dark'] .app-feature-card h3,
[data-theme='dark'] #contactsList .list-group-item,
[data-theme='dark'] .app-hwkey-panel h2,
[data-theme='dark'] .modal-content,
[data-theme='dark'] #emptyState h2 {
  color: var(--app-text-strong);
}

[data-theme='dark'] #contactsList .list-group-item.active {
  color: var(--app-primary-hover);
}

[data-theme='dark'] .messages-area .bubble.in {
  background: var(--app-surface-alt);
  color: var(--bs-body-color);
  border-color: var(--app-border);
}

[data-theme='dark'] .messages-area .bubble.in .bubble-delete:hover,
[data-theme='dark'] .messages-area .bubble.in .bubble-delete:focus {
  background: var(--app-slate-100);
}

[data-theme='dark'] .composer-area .form-control,
[data-theme='dark'] .app-auth-card .form-control,
[data-theme='dark'] .form-select {
  background: var(--app-surface-alt);
  color: var(--bs-body-color);
  border-color: var(--app-border);
}

[data-theme='dark'] .composer-area .form-control::placeholder,
[data-theme='dark'] .app-auth-card .form-control::placeholder {
  color: var(--app-text-muted);
}

[data-theme='dark'] .btn-outline-secondary {
  color: var(--bs-body-color);
  border-color: var(--app-border);
}

[data-theme='dark'] .btn-outline-secondary:hover {
  background: var(--app-slate-100);
  color: var(--app-text-strong);
  border-color: var(--app-border);
}

[data-theme='dark'] .btn-close {
  filter: invert(1) grayscale(100%);
}

html, body {
  height: 100%;
}

body {
  display: flex;
  flex-direction: column;
  background: var(--app-slate-50);
  color: var(--app-slate-800);
  -webkit-font-smoothing: antialiased;
}

/* Navbar */

.app-navbar {
  min-height: var(--app-nav-height);
  background: var(--app-slate-900);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.app-navbar-inner {
  padding-left: 1.25rem;
  padding-right: 1.25rem;
}

.app-navbar-actions {
  gap: 0.5rem;
}

@media (min-width: 768px) {
  .app-navbar-actions {
    gap: 0.75rem;
  }
}

.app-navbar .navbar-brand {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  font-weight: 600;
  font-size: 1.05rem;
  letter-spacing: -0.02em;
  color: #fff;
}

.app-brand-title {
  line-height: 1.2;
}

.app-brand-version {
  font-size: 0.68rem;
  font-weight: 500;
  font-family: var(--app-font-mono);
  letter-spacing: 0.03em;
  color: var(--app-slate-400);
  align-self: flex-end;
  margin-bottom: 0.12rem;
  margin-inline-start: -0.2rem;
}

.app-navbar .navbar-brand:hover {
  color: #fff;
}

.app-brand-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0.3rem;
  border-radius: var(--app-radius);
  background: #fff;
  flex-shrink: 0;
}

.app-brand-logo {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.app-navbar .nav-link {
  color: var(--app-slate-400);
  font-size: 0.9rem;
  font-weight: 500;
  padding: 0.375rem 0.75rem;
  border-radius: var(--app-radius);
}

.app-navbar .nav-link:hover,
.app-navbar .nav-link.active {
  color: #fff;
  background: rgba(255, 255, 255, 0.06);
}

.app-user-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.25rem 0.75rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--app-slate-200);
  font-size: 0.85rem;
  font-weight: 500;
}

.app-user-badge::before {
  content: '';
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: #22c55e;
}

.app-btn-ghost {
  color: #fff;
  border: 1px solid #fff;
  font-size: 0.85rem;
  font-weight: 500;
  padding: 0.3rem 0.875rem;
  border-radius: var(--app-radius);
}

.app-btn-ghost:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
  border-color: #fff;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.125rem;
  height: 2.125rem;
  padding: 0;
  line-height: 1;
}

.theme-toggle-icon {
  font-size: 1.05rem;
  pointer-events: none;
}

/* Main layout */

.app-main {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.app-main--default {
  padding: 2rem 0 3rem;
}

.app-main--chat {
  padding: 0;
  overflow: hidden;
  min-height: 0;
}

body[data-page='chat'] {
  overflow: hidden;
}

body[data-page='chat'] .app-main--chat {
  /* dvh tracks iOS Safari's collapsing toolbar; vh fallback for older browsers */
  height: calc(100vh - var(--app-nav-height));
  max-height: calc(100vh - var(--app-nav-height));
  height: calc(100dvh - var(--app-nav-height));
  max-height: calc(100dvh - var(--app-nav-height));
}

body[data-page='chat'] main {
  min-height: 0;
}

/* Landing page */

.app-hero {
  position: relative;
  overflow: hidden;
  padding: 4rem 0 3.5rem;
  background: linear-gradient(160deg, var(--app-slate-900) 0%, #1e3a5f 55%, var(--app-slate-800) 100%);
  border-radius: var(--app-radius-xl);
  color: #fff;
}

.app-hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 50% at 50% -20%, rgba(37, 99, 235, 0.35), transparent),
    radial-gradient(ellipse 60% 40% at 100% 100%, rgba(13, 148, 136, 0.2), transparent);
  pointer-events: none;
}

.app-hero-inner {
  position: relative;
  max-width: 42rem;
  margin: 0 auto;
  text-align: center;
  padding: 0 1.5rem;
}

.app-hero-logo {
  display: flex;
  justify-content: center;
  margin-bottom: 1.5rem;
}

.app-hero-logo img {
  height: 3.25rem;
  width: auto;
  padding: 0.5rem 0.875rem;
  background: #fff;
  border-radius: var(--app-radius-lg);
}

.app-hero-eyebrow {
  display: inline-block;
  margin-bottom: 1rem;
  padding: 0.25rem 0.75rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--app-slate-200);
}

.app-hero h1 {
  font-size: clamp(2rem, 5vw, 2.75rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.15;
  margin-bottom: 1.25rem;
}

.app-hero .lead {
  font-size: 1.1rem;
  line-height: 1.65;
  color: var(--app-slate-300);
  margin-bottom: 2rem;
}

.app-hero code {
  padding: 0.1rem 0.4rem;
  border-radius: 0.25rem;
  background: rgba(255, 255, 255, 0.1);
  color: #bfdbfe;
  font-size: 0.9em;
}

.app-feature-grid {
  margin-top: 2.5rem;
}

.app-feature-card {
  height: 100%;
  padding: 1.5rem;
  background: var(--app-surface);
  border: 1px solid var(--app-border);
  border-radius: var(--app-radius-lg);
}

.app-feature-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  margin-bottom: 1rem;
  border-radius: var(--app-radius);
  background: var(--app-primary-subtle);
  color: var(--app-primary);
}

.app-feature-card h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: var(--app-slate-900);
}

.app-feature-card p {
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--app-slate-600);
  margin: 0;
}

/* Auth pages */

.app-auth-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - var(--app-nav-height) - 4rem);
  padding: 1.5rem 0;
}

.app-auth-card {
  width: 100%;
  max-width: 28rem;
  background: var(--app-surface);
  border: 1px solid var(--app-border);
  border-radius: var(--app-radius-xl);
  padding: 2rem;
}

.app-invites-card {
  max-width: 42rem;
}

.app-invite-highlight .form-control {
  font-family: var(--bs-font-monospace);
  font-size: 0.8rem;
}

.app-invites-table code {
  font-size: 0.75rem;
}

.app-auth-header {
  margin-bottom: 1.75rem;
}

.app-auth-header h1 {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 0.375rem;
  color: var(--app-slate-900);
}

.app-auth-header p {
  font-size: 0.9rem;
  color: var(--app-slate-500);
  margin: 0;
}

.app-form-hint {
  display: block;
  font-size: 0.8rem;
  color: var(--app-slate-500);
  margin-top: 0.25rem;
}

.app-form-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--app-slate-700);
  margin-bottom: 0.375rem;
}

.app-auth-card .form-control {
  border-color: var(--app-border);
  border-radius: var(--app-radius);
  padding: 0.625rem 0.875rem;
  font-size: 0.95rem;
}

.app-auth-card .form-control:focus {
  border-color: var(--app-primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.app-auth-divider {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin: 1.25rem 0;
  color: var(--app-slate-400);
  font-size: 0.8rem;
}

.app-auth-divider::before,
.app-auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--app-border);
}

.app-hwkey-panel {
  padding: 1rem;
  background: var(--app-slate-50);
  border: 1px solid var(--app-border);
  border-radius: var(--app-radius-lg);
}

.app-hwkey-panel h2 {
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: var(--app-slate-800);
}

.app-auth-footer {
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--app-border);
  text-align: center;
  font-size: 0.9rem;
  color: var(--app-slate-500);
}

/* Status alerts (chat) */

.app-status-bar {
  flex-shrink: 0;
  padding: 0.75rem 1rem 0;
  background: var(--app-slate-50);
}

.app-status-bar .alert {
  margin-bottom: 0.75rem;
  border: none;
  border-radius: var(--app-radius-lg);
  font-size: 0.9rem;
}

.app-status-bar .alert-warning {
  background: var(--app-alert-warning-bg);
  color: var(--app-alert-warning-text);
}

.app-status-bar .alert-success {
  background: var(--app-alert-success-bg);
  color: var(--app-alert-success-text);
}

.app-status-bar .alert-danger {
  background: var(--app-alert-danger-bg);
  color: var(--app-alert-danger-text);
}

/* Chat layout */

.chat-shell {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--app-surface);
  border-top: 1px solid var(--app-border);
}

.chat-card {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.chat-card > .row {
  flex: 1;
  min-height: 0;
  height: 100%;
}

.chat-card > .row > [class*='col-'] {
  min-height: 0;
}

.contacts-col {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--app-slate-50);
  border-right: 1px solid var(--app-border);
}

.contacts-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.contacts-header {
  flex-shrink: 0;
  padding: 1rem 1.125rem;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--app-text-muted);
  border-bottom: 1px solid var(--app-border);
  background: var(--app-surface);
}

#contactsList {
  flex: 0 1 auto;
  overflow-y: visible;
  min-height: 0;
}

#contactsList .list-group-item {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.75rem 1.125rem;
  border: none;
  border-bottom: 1px solid var(--app-border);
  background: transparent;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--app-slate-800);
  transition: background 0.12s ease;
}

#contactsList .contact-label {
  flex: 1;
  min-width: 0;
}

#contactsList .list-group-item:hover:not(.disabled) {
  background: var(--app-slate-100);
}

#contactsList .unread-badge,
#groupsList .unread-badge {
  background: var(--app-primary);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 600;
  min-width: 1.35rem;
  flex-shrink: 0;
}

#contactsList .list-group-item.active {
  background: var(--app-primary-subtle);
  color: var(--app-primary-hover);
  border-left: 3px solid var(--app-primary);
  padding-left: calc(1.125rem - 3px);
}

#contactsList .list-group-item.disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

#contactsList .list-group-item.text-secondary {
  color: var(--app-slate-500);
  font-weight: 400;
  cursor: default;
}

#groupsList .list-group-item[data-group-id] {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.75rem 1.125rem;
  border: none;
  border-bottom: 1px solid var(--app-border);
  background: transparent;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--app-slate-800);
  transition: background 0.12s ease;
}

#groupsList .group-label {
  flex: 1;
  min-width: 0;
}

#groupsList .list-group-item[data-group-id]:hover {
  background: var(--app-slate-100);
}

#groupsList .list-group-item[data-group-id].active {
  background: var(--app-primary-subtle);
  color: var(--app-primary-hover);
  border-left: 3px solid var(--app-primary);
  padding-left: calc(1.125rem - 3px);
}

#groupsList .list-group-item.text-secondary {
  color: var(--app-slate-500);
  font-weight: 400;
  cursor: default;
}

.avatar-with-level {
  position: relative;
  display: inline-block;
  flex-shrink: 0;
  overflow: hidden;
  border-radius: var(--app-radius);
}

.avatar-with-level--sm {
  width: 28px;
  height: 28px;
}

.avatar-with-level--md {
  width: 40px;
  height: 40px;
}

#contactsList .avatar-with-level {
  flex-shrink: 0;
}

.avatar-with-level img {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  object-fit: cover;
}

.security-level-badge {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 1;
  font-size: 0.72rem;
  font-weight: 800;
  line-height: 1;
  text-align: center;
  padding: 0;
  background: none;
  border: none;
  color: #fff;
  -webkit-text-stroke: 0.75px #000;
  paint-order: stroke fill;
  text-shadow: 0 0 3px #000, 0 0 6px rgba(0, 0, 0, 0.5);
  pointer-events: none;
}

.security-level-badge.level-1,
.security-level-badge.level-2,
.security-level-badge.level-3 {
  background: transparent;
}

.self-fingerprint-section {
  flex-shrink: 0;
  padding: 0.875rem 1.125rem;
  border-top: 1px solid var(--app-border);
  background: var(--app-surface);
}

.self-fingerprint-section .label {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--app-slate-500);
}

.chat-col {
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%;
  overflow: hidden;
  background: var(--app-surface);
}

.chat-header {
  flex-shrink: 0;
  padding: 0.875rem 1.25rem;
  border-bottom: 1px solid var(--app-border);
  background: var(--app-surface);
}

.chat-header #peerName {
  font-size: 1rem;
  font-weight: 600;
  color: var(--app-slate-900);
  letter-spacing: -0.01em;
}

.call-bar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.625rem 1.25rem;
  border-top: 1px solid var(--app-border);
  background: var(--app-surface-alt);
}

.call-panel {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  border-bottom: 1px solid var(--app-border);
  background: var(--app-surface);
}

.call-panel--global {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 1040;
  border-bottom: none;
  border-top: 1px solid var(--app-border);
  box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.08);
}

.call-panel .call-bar {
  border-top: 1px solid var(--app-border);
  border-bottom: none;
}

.call-video-stage {
  position: relative;
  background: #1a1d21;
  min-height: 180px;
  max-height: min(42vh, 360px);
  overflow: hidden;
}

.call-remote-video {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 180px;
  max-height: min(42vh, 360px);
  object-fit: contain;
  background: #1a1d21;
}

.call-remote-video.d-none {
  display: none;
}

.call-local-video {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  width: 140px;
  max-height: 105px;
  object-fit: cover;
  border: 2px solid var(--app-border);
  border-radius: 0.375rem;
  background: #000;
  z-index: 2;
}

.call-local-video.d-none {
  display: none;
}

.call-camera-select {
  max-width: 11rem;
  min-width: 8rem;
}

.call-bar-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  flex-shrink: 0;
  justify-content: flex-end;
}

.call-bar-info {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
  min-width: 0;
}

.call-bar-timer {
  color: var(--app-slate-600, #6c757d);
}

.bubble.system {
  align-self: center;
  max-width: 90%;
  background: transparent;
  border: none;
  padding: 0.25rem 0;
}

.bubble.system .bubble-text {
  font-size: 0.8125rem;
}

.messages-area {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
  min-height: 0;
  background:
    linear-gradient(180deg, var(--app-slate-50) 0%, var(--app-surface) 8rem);
}

#emptyState {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  text-align: center;
  padding: 2rem;
  color: var(--app-slate-500);
}

#emptyState .empty-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 3.5rem;
  height: 3.5rem;
  margin-bottom: 1rem;
  border-radius: 50%;
  background: var(--app-slate-100);
  color: var(--app-slate-400);
}

#emptyState h2 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--app-slate-700);
  margin-bottom: 0.375rem;
}

#emptyState p {
  font-size: 0.875rem;
  max-width: 18rem;
  margin: 0;
  line-height: 1.5;
}

.messages-area .bubble {
  position: relative;
  max-width: min(75%, 32rem);
  padding: 0.625rem 0.875rem;
  padding-top: 1.5rem;
  border-radius: 1rem;
  word-break: break-word;
  white-space: pre-wrap;
  font-size: 0.925rem;
  line-height: 1.5;
}

.bubble-delete {
  position: absolute;
  top: 0.25rem;
  right: 0.35rem;
  width: 1.25rem;
  height: 1.25rem;
  padding: 0;
  border: none;
  border-radius: 0.25rem;
  background: transparent;
  color: inherit;
  font-size: 1rem;
  line-height: 1;
  opacity: 0;
  cursor: pointer;
}

.bubble:hover .bubble-delete,
.bubble:focus-within .bubble-delete {
  opacity: 0.55;
}

.bubble-delete:hover,
.bubble-delete:focus {
  opacity: 1;
}

.messages-area .bubble.out .bubble-delete:hover,
.messages-area .bubble.out .bubble-delete:focus {
  background: rgba(255, 255, 255, 0.15);
}

.messages-area .bubble.in .bubble-delete:hover,
.messages-area .bubble.in .bubble-delete:focus {
  background: var(--app-slate-100);
}

.messages-area .bubble.out {
  align-self: flex-end;
  background: var(--app-primary);
  color: #fff;
  border-bottom-right-radius: 0.25rem;
}

.messages-area .bubble.in {
  align-self: flex-start;
  background: var(--app-surface);
  color: var(--app-slate-800);
  border: 1px solid var(--app-border);
  border-bottom-left-radius: 0.25rem;
}

.messages-area .bubble .meta {
  font-size: 0.7rem;
  opacity: 0.75;
  margin-top: 0.25rem;
}

.composer-area {
  flex-shrink: 0;
  border-top: 1px solid var(--app-border);
  padding: 0.875rem 1.25rem;
  background: var(--app-surface);
}

.composer-area .form-control {
  border-radius: var(--app-radius-lg);
  border-color: var(--app-border);
  padding: 0.625rem 1rem;
  font-size: 0.95rem;
}

.composer-area .form-control:focus {
  border-color: var(--app-primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.composer-area .btn-primary {
  border-radius: var(--app-radius-lg);
  padding: 0.625rem 1.25rem;
  font-weight: 600;
  font-size: 0.9rem;
}

.composer-area #attachBtn {
  border-radius: var(--app-radius-lg) 0 0 var(--app-radius-lg);
}

.attachment-preview {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--app-border);
  border-radius: var(--app-radius);
  background: var(--app-slate-50);
  font-size: 0.875rem;
}

.attachment-preview-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attachment-upload-progress {
  margin-bottom: 0.5rem;
}

.attachment-upload-progress .progress {
  height: 0.375rem;
  border-radius: var(--app-radius);
}

.messages-area .bubble-body {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.messages-area .bubble-text a {
  text-decoration: underline;
  word-break: break-all;
}

.messages-area .bubble.out .bubble-text a {
  color: #fff;
}

.messages-area .bubble.in .bubble-text a {
  color: var(--app-primary);
}

.messages-area .bubble-sender {
  font-weight: 600;
  margin-bottom: 0.15rem;
}

.bubble-attachments {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.attachment-block {
  max-width: 100%;
}

.attachment-thumb {
  display: block;
  max-width: min(100%, 16rem);
  max-height: 12rem;
  border-radius: var(--app-radius);
  cursor: pointer;
  object-fit: cover;
}

.attachment-file {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.attachment-filename {
  font-size: 0.875rem;
  word-break: break-all;
}

.messages-area .bubble.out .attachment-download {
  color: var(--app-slate-800);
  background: #fff;
  border-color: rgba(255, 255, 255, 0.6);
}

.messages-area .bubble.out .attachment-filename {
  color: #fff;
}

/* Fingerprint & identicons */

.fingerprint {
  font-family: var(--app-font-mono);
  font-size: 0.78rem;
  letter-spacing: 0.02em;
}

.fingerprint-security-info {
  display: block;
  font-size: 0.72rem;
  line-height: 1.35;
  margin-top: 0.25rem;
  color: var(--app-text-muted);
  font-weight: 500;
}

.identicon-sm { border-radius: var(--app-radius); flex-shrink: 0; }
.identicon-md { border-radius: var(--app-radius); flex-shrink: 0; }
.identicon-lg { border-radius: var(--app-radius-lg); flex-shrink: 0; }

#peerFp {
  font-size: 0.72rem;
  max-width: 100%;
  word-break: break-all;
  color: var(--app-slate-500);
}

#fpValue {
  padding: 0.75rem;
  background: var(--app-slate-50);
  border: 1px solid var(--app-border);
  border-radius: var(--app-radius);
}

/* Modal */

.modal-content {
  background: var(--app-surface);
  color: var(--app-slate-800);
  border: 1px solid var(--app-border);
  border-radius: var(--app-radius-xl);
}

.modal-header {
  border-bottom-color: var(--app-border);
}

.modal-footer {
  border-top-color: var(--app-border);
}

/* Error page */

.app-error-card {
  max-width: 32rem;
  margin: 3rem auto;
  padding: 2rem;
  background: var(--app-surface);
  border: 1px solid var(--app-border);
  border-radius: var(--app-radius-xl);
  text-align: center;
}

.app-error-code {
  font-size: 3rem;
  font-weight: 700;
  color: var(--app-slate-200);
  line-height: 1;
  margin-bottom: 0.5rem;
}

/* Buttons */

.btn-primary {
  background: var(--app-primary);
  border-color: var(--app-primary);
  font-weight: 600;
}

.btn-primary:hover,
.btn-primary:focus {
  background: var(--app-primary-hover);
  border-color: var(--app-primary-hover);
}

/* Responsive */

@media (max-width: 767.98px) {
  .contacts-col {
    max-height: min(44vh, 20rem);
    border-right: none;
    border-bottom: 1px solid var(--app-border);
  }

  .chat-card > .row {
    flex-direction: column;
  }

  .chat-col {
    flex: 1;
    min-height: 0;
  }

  .app-hero {
    padding: 2.5rem 0 2rem;
    border-radius: var(--app-radius-lg);
  }
}
