/* ===== Page wrap + floating orbs ===== */
.page-wrap {
  position: relative;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #0f172a;
  color: #f8fafc;
  overflow: hidden;
  padding: 14px;
}
.chat-page {
  background: #0f172a;
  /* the chat is full-bleed; the 14px auth padding would frame it with dead space */
  padding: 0;
}

/* Animated floating blobs */
:root {
  --a: #6366f144;
  --b: #a855f744;
  --c: #38bdf844;
  --d: #f472b644;
}
.orb {
  position: absolute;
  border-radius: 50%;
  background: var(--a);
  mix-blend-mode: screen;
  filter: blur(0);
  animation: float 22s ease-in-out infinite;
  opacity: 0.55;
}
.orb-1 {
  width: 340px; height: 340px; top: -80px; left: -120px;
  background: var(--a);
  animation-duration: 28s;
}
.orb-2 {
  width: 260px; height: 260px; bottom: -60px; right: -80px;
  background: var(--b);
  animation-duration: 34s;
  animation-delay: -3s;
}
.orb-3 {
  width: 200px; height: 200px; top: 50%; left: 10px;
  background: var(--c);
  animation-duration: 26s;
  animation-delay: -5s;
}
.orb-4 {
  width: 180px; height: 180px; bottom: 40%; right: 20px;
  background: var(--d);
  animation-duration: 30s;
  animation-delay: -2s;
}
.orb-5 {
  width: 160px; height: 160px; top: 30%; right: 10%;
  background: var(--b);
  animation-duration: 24s;
  animation-delay: -4s;
}
@keyframes float {
  0%, 100% { transform: translate(0, 0) scale(1); }
  25% { transform: translate(14px, -10px) scale(1.05); }
  50% { transform: translate(-6px, 12px) scale(0.97); }
  75% { transform: translate(10px, 6px) scale(1.03); }
}

/* ===== Auth card ===== */
.auth {
  display: flex;
  justify-content: center;
  width: 100%;;
  max-width: 420px;
  z-index: 2;
}
.auth-card {
  width: 100%;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 22px;
  padding: 34px 28px;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: 0 8px 32px rgba(15, 23, 42, 0.35);
}
.logo-img {
  width: 72px;
  height: 72px;
  display: block;
  margin: 0 auto;
}
.brand {
  font-family: "Arial", sans-serif;
  font-weight: 900;
  font-size: 34px;
  text-align: center;
  margin-top: 10px;
  background: var(--gradient, linear-gradient(135deg, #6366f1, #a855f7));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.tagline {
  text-align: center;
  color: #cbd5e1;
  margin-top: 6px;
  font-size: 14px;
}
.field {
  display: flex;
  flex-direction: column;
  margin-bottom: 20px;
  position: relative;
}
.field label {
  font-size: 13px;
  color: #e2e8f0;
  margin-bottom: 6px;
}
.field input {
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 14px;
  padding: 12px 14px;
  font-size: 15px;
  color: #f8fafc;
  outline: none;
  transition: border-color 0.22s ease, box-shadow 0.22s ease;
}
.field input::placeholder {
  color: #94a3b8;
}
.field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.25);
}
.field .underline {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 2px;
  width: 0;
  background: var(--gradient);
  border-radius: 2px;
  transition: width 0.26s ease;
  pointer-events: none;
}
.field:focus-within .underline {
  width: 100%;
}
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  border: none;
  border-radius: 14px;
  padding: 13px 16px;
  font-size: 15px;
  font-weight: 600;
  color: #fff;
  background: var(--gradient);
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.22s ease;
  margin-top: 4px;
}
.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(99, 102, 241, 0.42);
}
.btn-primary:active {
  transform: translateY(0);
}
.btn-icon {
  flex: 0 0 auto;
}
.auth-foot {
  text-align: center;
  margin-top: 18px;
  font-size: 13px;
  color: #cbd5e1;
}
.auth-foot a {
  color: var(--accent);
  text-decoration: none;
}
.auth-foot a:hover {
  text-decoration: underline;
}
.auth-install {
  margin-top: 18px;
  text-align: center;
}
.install-app-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 48px;
  padding: 12px 16px;
  border: 1px solid rgba(199, 210, 254, 0.28);
  border-radius: 14px;
  background: var(--gradient);
  color: #fff;
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.24);
  animation: install-pulse 2.8s ease-in-out infinite;
  transition: border-color 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
}
.install-app-btn:hover {
  border-color: rgba(255, 255, 255, 0.62);
  transform: translateY(-1px);
  animation-play-state: paused;
  box-shadow: 0 7px 22px rgba(99, 102, 241, 0.42);
}
.install-app-btn:focus-visible {
  outline: 2px solid #a5b4fc;
  outline-offset: 3px;
}
@keyframes install-pulse {
  0%, 100% { opacity: 0.78; box-shadow: 0 3px 12px rgba(99, 102, 241, 0.18); }
  50% { opacity: 1; box-shadow: 0 6px 20px rgba(168, 85, 247, 0.38); }
}
@media (prefers-reduced-motion: reduce) {
  .install-app-btn { animation: none; }
}
.install-help {
  max-width: 300px;
  margin: 12px auto 0;
  color: #94a3b8;
  font-size: 12px;
  line-height: 1.6;
}
.app-foot {
  margin-top: 18px;
  font-size: 12px;
  color: #64748b;
  z-index: 2;
}

/* Unlock/key-derivation overlay */
.unlock {
  position: fixed;
  inset: 0;
  background: #0f172a;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 22px;
  z-index: 9999;
}
.unlock-logo {
  width: 80px;
  height: 80px;
  filter: drop-shadow(0 4px 16px rgba(99, 102, 241, 0.5));
}
.spinner {
  width: 40px;
  height: 4px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.15);
  overflow: hidden;
  position: relative;
}
.spinner::before {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--gradient);
  width: 30%;
  height: 100%;
  animation: spin 1.2s linear infinite;
}
@keyframes spin {
  0% { left: 0%; }
  100% { left: 100%; }
}
.unlock-text {
  color: #94a3b8;
  font-size: 13px;
}

/* ===== Reset + base ===== */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}
html, body {
  height: 100%;
}
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  background: #0f172a;
  color: #0f172a;
  overflow: hidden;
}

/* ===== Theme ===== */
:root {
  --accent: #6366f1;
  --accent-2: #a855f7;
  --gradient: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
  --bg: #f0f2f5;
  --sidebar-bg: rgba(15, 23, 42, 0.6);
  --header-bg: #ffffffcc;
  --bubble-in: #ffffff;
  --bubble-out: #e0e0ff;
  --text-primary: #111827;
  --text-secondary: #6b7280;
  --border: #d1d5db;
  --shadow: 0 2px 8px rgba(16, 25, 47, 0.08);
}

/* ===== Layout ===== */
.chat-container {
  display: flex;
  width: 100%;
  max-width: 100%;
  height: 100vh;
  background: var(--bg);
  overflow: hidden;
  backdrop-filter: none;
}

/* Glassmorphism sidebar */
.chat-sidebar {
  flex: 0 0 360px;
  max-width: 30%;
  min-width: 280px;
  background: linear-gradient(160deg, #1e293b, #0f172a);
  color: #f8fafc;
  display: flex;
  flex-direction: column;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.sidebar-header .avatar-sm {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--accent);
}
.sidebar-user {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.sidebar-user .name {
  font-weight: 600;
  font-size: 15px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-user .status-dot {
  display: inline-block;
  margin-left: -2px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 0 3px #1e293b;
}
.sidebar-actions {
  display: flex;
  gap: 6px;
}
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
  width: 38px;
  height: 38px;
  border-radius: 14px;
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.10);
  color: #f8fafc;
  cursor: pointer;
  transition: all 0.18s ease;
}
.icon-btn:hover {
  background: rgba(255, 255, 255, 0.22);
  border-color: rgba(255, 255, 255, 0.16);
}

/* Notification badge on the "find people" button */
.icon-badge {
  position: absolute;
  top: -3px;
  right: -3px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  background: #ef4444;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 0 2px #0f172a;
  pointer-events: none;
}

.search-bar {
  position: relative;
  margin: 12px 14px;
  border-radius: 22px;
  background: #0f172ab3;
  border: 1px solid rgba(255, 255, 255, 0.10);
  padding: 8px 36px 8px 12px;
  color: #cbd5e1;
}
.search-bar input {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: #f8fafc;
  font-size: 14px;
  /* Without this the field is only as tall as its line-box (~18px), which is a
     very small touch target on a phone. */
  min-height: 26px;
}
.search-bar input::placeholder {
  color: #94a3b8;
}
.search-bar svg {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: #94a3b8;
}

.chat-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 0;
}
.chat-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border-radius: 6px;
  margin: 0 6px;
  cursor: pointer;
  transition: background 0.15s ease;
  border-left: 3px solid transparent;
}
.chat-item:hover {
  background: rgba(255, 255, 255, 0.06);
}
.chat-item.active {
  background: rgba(99, 102, 241, 0.18);
  border-left-color: var(--accent);
}
.chat-item .avatar-md {
  width: 48px;
  height: 48px;
  border-radius: 16px;
  object-fit: cover;
}
.chat-meta {
  flex: 1;
  min-width: 0;
}
.chat-name {
  font-weight: 600;
  color: #f8fafc;
  margin-bottom: 2px;
  /* names can contain one unbreakable token (a long handle or a URL-style
     room name); without this the row's text spills past the drawer edge */
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-preview {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.preview-text {
  color: #94a3b8;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.preview-time {
  color: #64748b;
  font-size: 12px;
  white-space: nowrap;
}

/* ===== Main chat ===== */
.chat-main {
  flex: 1;
  /* flex items default to min-width:auto, which refuses to shrink below the
     intrinsic width of the input/header row and overflows narrow screens */
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  border-left: 1px solid var(--border);
}

.chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: var(--header-bg);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(10px);
}
.chat-header .group {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
}
.chat-header .group .avatar-md {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
}
.group-info .group-name {
  font-weight: 600;
  color: var(--text-primary);
}
.group-info .group-meta {
  color: var(--text-secondary);
  font-size: 12px;
}
.header-actions {
  display: flex;
  gap: 8px;
}
.header-actions .icon-btn {
  color: var(--text-secondary);
  background: #f1f1f1;
  border: 1px solid var(--border);
}
.header-actions .icon-btn:hover {
  background: #e4e6ea;
}

.mobile-back {
  display: none;
}

/* ===== Messages ===== */
.messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  background: var(--bg);
}
.message-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.message-group .day-divider {
  text-align: center;
  font-size: 12px;
  color: var(--text-secondary);
  margin: 8px 0;
}

.message {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  max-width: 72%;
}
.message.own {
  align-self: flex-end;
  flex-direction: row-reverse;
  gap: 10px;
}
.message .avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  box-shadow: 0 1px 2px rgba(16, 25, 47, 0.10);
}
.message.own .avatar {
  display: none;
}
.message .bubble {
  padding: 10px 14px;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.45;
  word-break: break-word;
  box-shadow: var(--shadow);
  position: relative;
}
.message.received .bubble {
  background: var(--bubble-in);
  border-bottom-right-radius: 6px;
  color: var(--text-primary);
}
.message.own .bubble {
  background: var(--gradient);
  border-bottom-left-radius: 6px;
  color: #ffffff;
}
.bubble .time {
  font-size: 11px;
  opacity: 0.7;
  margin-top: 4px;
  text-align: right;
}
.message.own .bubble .time {
  opacity: 0.85;
}

/* ===== Encrypted photo messages ===== */
.message .bubble.bubble-media {
  padding: 6px;
}
.bubble-media .text {
  display: block;
  padding: 6px 8px 0;
}
.media-pending {
  min-width: 180px;
  min-height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  opacity: 0.75;
  color: inherit;
}
.media-wrap {
  display: block;
}
.media-img {
  display: block;
  width: 100%;
  max-width: 320px;
  height: auto;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.06);
  cursor: zoom-in;
}
.photo-viewer {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  background: rgba(4, 10, 20, 0.92);
}
.photo-viewer img {
  max-width: 100%;
  max-height: 100%;
  border-radius: 10px;
}
.compose-preview {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin: 0 14px 8px;
  padding: 10px;
  border-radius: 14px;
  background: rgba(148, 163, 184, 0.14);
  font-size: 12px;
}
.compose-preview .preview-thumb {
  width: 56px;
  height: 56px;
  object-fit: cover;
  border-radius: 10px;
}
.compose-preview .preview-info {
  flex: 1;
  min-width: 140px;
  color: #cbd5e1;
}
.btn-sm {
  padding: 6px 12px;
  font-size: 13px;
  border-radius: 999px;
  cursor: pointer;
  border: none;
}
.btn-ghost {
  background: transparent;
  color: inherit;
  border: 1px solid rgba(148, 163, 184, 0.45);
}

/* ===== Footer ===== */
.chat-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  background: var(--header-bg);
  border-top: 1px solid var(--border);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}
.chat-footer .icon-btn {
  color: var(--text-secondary);
  background: #f1f1f1;
  border: 1px solid var(--border);
}
.chat-footer .icon-btn:hover {
  background: #e4e6ea;
}
.message-input {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 10px 16px;
  font-size: 14px;
  outline: 0;
  background: #fafafa;
  transition: border-color 0.18s ease;
}
.message-input:focus {
  border-color: var(--accent);
}
.message-input::placeholder {
  color: var(--text-secondary);
}
.send-btn {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: var(--gradient);
  color: #ffffff;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(99, 102, 241, 0.40);
  transition: transform 0.12s ease;
}
.send-btn:hover {
  transform: scale(1.05);
}

/* ===== Responsive: Tablet ===== */
@media (max-width: 1024px) {
  .chat-container {
    font-size: 14px;
  }
  .chat-sidebar {
    flex: 0 0 320px;
    min-width: 320px;
  }
}

/* Scrollbars */
.chat-list,
.messages {
  scrollbar-width: thin;
  scrollbar-color: rgba(0, 0, 0, 0.2) transparent;
}
.chat-list::-webkit-scrollbar,
.messages::-webkit-scrollbar {
  width: 6px;
}
.chat-list::-webkit-scrollbar-track,
.messages::-webkit-scrollbar-track {
  background: transparent;
}
.chat-list::-webkit-scrollbar-thumb,
.messages::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.18);
  border-radius: 3px;
}

/* ===== Viewport height that ignores mobile browser chrome ===== */
@supports (height: 100dvh) {
  .page-wrap { min-height: 100dvh; }
  .chat-container { height: 100dvh; }
}

/* ===== Header text never overflows the actions ===== */
.chat-header .group { min-width: 0; }
.group-info { min-width: 0; }
.group-info .group-name,
.group-info .group-meta {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-header .group .group-info { flex: 1; min-width: 0; }

/* ===== Mobile: auth / register must scroll when tall ===== */
@media (max-width: 768px) {
  .page-wrap {
    justify-content: flex-start;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: max(20px, env(safe-area-inset-top)) 14px calc(20px + env(safe-area-inset-bottom));
  }
  .auth-card {
    padding: 26px 20px;
    border-radius: 18px;
  }
  .brand { font-size: 30px; }
  .logo-img { width: 60px; height: 60px; }
}

/* ===== Mobile: chat ===== */
@media (max-width: 768px) {
  /* the auth pages scroll above; the chat owns the whole viewport, edge to edge */
  .page-wrap.chat-page {
    padding: 0;
    overflow: hidden;
  }

  .chat-sidebar {
    position: absolute;
    inset: 0;
    z-index: 20;
    /* flex min/max widths from the desktop rail would leave a 40px strip of chat
       visible beside the drawer, so the drawer is allowed to fill the viewport */
    width: auto;
    min-width: 0;
    max-width: 100%;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    border-right: none;
  }
  .chat-sidebar.open {
    transform: translateX(0);
  }

  .chat-main {
    position: relative;
    width: 100%;
  }

  .mobile-back {
    display: inline-flex;
  }

  .chat-header {
    padding: 8px 10px;
    padding-top: max(8px, env(safe-area-inset-top));
    gap: 8px;
  }
  .chat-header .group .avatar-md { width: 40px; height: 40px; }
  .chat-header .group { gap: 8px; }

  .chat-item {
    padding: 14px;
  }

  /* 16px prevents iOS Safari auto-zooming the field into focus */
  .message-input,
  .search-bar input,
  .field input {
    font-size: 16px;
  }

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

@media (max-width: 480px) {
  .chat-container {
    font-size: 13px;
  }
  .messages {
    padding: 16px 8px;
  }
  .message {
    max-width: 84%;
  }
  .chat-footer {
    padding: 10px 8px;
    gap: 6px;
    padding-bottom: max(10px, env(safe-area-inset-bottom));
  }
  .chat-footer .icon-btn {
    width: 36px;
    height: 36px;
  }
  .message-input {
    padding: 10px 12px;
  }
  .send-btn {
    width: 38px;
    height: 38px;
  }
  .auth-card {
    padding: 22px 16px;
  }
}

/* ===== Very small / landscape-short phones ===== */
@media (max-width: 360px) {
  .chat-header .header-actions { gap: 4px; }
  .group-info .group-name { font-size: 14px; }
  .sidebar-header { padding: 14px 10px; gap: 8px; }
  .search-bar { margin: 10px; }
}

/* ===== 1:1 encrypted calls ===== */
.call-overlay {
  position: fixed;
  inset: 0;
  z-index: 130;
  display: flex;
  flex-direction: column;
  background: #0b1020;
}
.call-stage {
  position: relative;
  flex: 1;
  min-height: 0;
  background: #0b1020;
}
.call-remote {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #0b1020;
}
.call-local {
  position: absolute;
  right: 14px;
  bottom: 14px;
  width: 28%;
  max-width: 170px;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  border-radius: 14px;
  background: #111a30;
  border: 1px solid #ffffff22;
  box-shadow: var(--shadow);
}
.call-info {
  position: absolute;
  top: 16px;
  left: 16px;
  color: #ffffff;
  max-width: 70%;
}
.call-peer {
  font-size: 16px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.call-status {
  font-size: 13px;
  opacity: 0.8;
  margin-top: 3px;
  line-height: 1.35;
}
.call-timer {
  font-size: 12px;
  opacity: 0.7;
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
}
.call-controls {
  display: flex;
  justify-content: center;
  gap: 14px;
  padding: 16px;
  background: #0b1020;
}
.call-btn {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  cursor: pointer;
  background: #1c2440;
  color: #ffffff;
}
.call-btn.off {
  background: #ffffff26;
}
.call-btn-end {
  background: #ef4444;
}
.call-incoming {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: 22px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
  padding: 10px 14px;
  border-radius: 16px;
  background: #ffffffee;
  color: var(--text-primary);
  box-shadow: var(--shadow);
  max-width: min(92vw, 420px);
}
.call-incoming-text {
  font-size: 14px;
}
.call-incoming-actions {
  display: flex;
  gap: 8px;
}
/* Accept/decline is the one thing that must be hit correctly on the first try,
   often one-handed on a small phone. */
.call-incoming-actions .btn-sm {
  min-height: 42px;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 600;
}
@media (max-width: 480px) {
  .call-local {
    width: 34%;
    right: 10px;
    bottom: 10px;
  }
  .call-btn {
    width: 44px;
    height: 44px;
  }
}

/* ===== Privacy cover + copy resistance ===== */
.privacy-veil {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  text-align: center;
  background: var(--bg);
  color: var(--text-secondary);
  font-size: 14px;
}
.bubble,
.media-img,
.photo-viewer img,
.call-overlay {
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

/* Respect reduced motion: stop the floating orb animation */
@media (prefers-reduced-motion: reduce) {
  .orb { animation: none; }
}

.quick-tools { display:flex; gap:6px; padding:8px 12px; border-bottom:1px solid rgba(148,163,184,.18); }
.quick-tools button { border:1px solid rgba(148,163,184,.28); border-radius:999px; background:rgba(255,255,255,.06); color:inherit; padding:7px 10px; cursor:pointer; font:inherit; font-size:12px; }
.feature-panel { position:fixed; inset:0; z-index:10000; display:flex; align-items:flex-start; justify-content:center; padding:7vh 12px 16px; background:rgba(4,10,20,.55); }
.feature-panel-card { width:min(520px,100%); max-height:86vh; overflow:auto; border-radius:16px; padding:18px; color:#172033; background:#fff; box-shadow:0 20px 70px #0005; }
.feature-panel-card h2 { margin:0 0 14px; font-size:20px; }
.feature-panel-card label { display:block; margin:10px 0 4px; font-size:13px; color:#526071; }
.feature-panel-card input,.feature-panel-card textarea,.feature-panel-card select { width:100%; box-sizing:border-box; border:1px solid #d6dce5; border-radius:9px; padding:10px; font:inherit; }
.feature-panel-card button { cursor:pointer; }
.feature-panel-card .panel-action { border:0; border-radius:9px; background:#6366f1; color:white; padding:10px 14px; margin-top:12px; }
.feature-panel-card .panel-close { float:right; border:0; background:transparent; font-size:22px; color:#667085; }
.feature-row { display:flex; align-items:center; gap:10px; border-bottom:1px solid #edf0f4; padding:10px 0; }
.feature-row img { width:38px; height:38px; border-radius:50%; object-fit:cover; }
.chat-main { background:var(--personal-chat-bg, #0f172a); }
.chat-main .messages { background:var(--personal-chat-bg, #0f172a); }
.btn-primary,.send-btn,.call-incoming-actions .btn-sm:first-child { background:var(--brand-accent, #6366f1); }
:root[data-theme="light"] .chat-page { background:#f1f5f9; color:#172033; }
:root[data-theme="light"] .chat-sidebar { background:#f8fafc; color:#172033; }
:root[data-theme="light"] .chat-main { color:#172033; }
:root[data-theme="light"] .chat-header,.chat-page[data-theme="light"] .chat-header { background:#fff; color:#172033; }
:root[data-theme="light"] .message-input { color:#172033; background:#fff; }
