:root {
  --bg: #07090e;
  --surface-sidebar: #0d111a;
  --surface-card: #131824;
  --surface-elevated: #1a2232;
  --surface-hover: #222c40;
  --border: rgba(255, 255, 255, 0.07);
  --border-focus: rgba(56, 189, 248, 0.4);
  --primary: #38bdf8;
  --primary-glow: rgba(56, 189, 248, 0.15);
  --text: #f8fafc;
  --text-muted: #7e8c9f;
  --green: #22c55e;
  --yellow: #eab308;
  --red: #ef4444;
  --wa-cyan: #38bdf8;
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
}

* { box-sizing: border-box; margin: 0; padding: 0; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; -webkit-tap-highlight-color: transparent; }
html, body { height: 100vh; height: 100dvh; width: 100%; }
body { background: var(--bg); color: var(--text); display: flex; overflow: hidden; padding: 10px; gap: 10px; -webkit-font-smoothing: antialiased; }

/* Modals & Overlays */
.modal-backdrop { position: fixed; inset: 0; background: rgba(3, 5, 8, 0.8); backdrop-filter: blur(12px); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 1rem; }
.floating-card { background: var(--surface-card); border: 1px solid var(--border); padding: 1.75rem; border-radius: var(--radius-lg); width: 420px; max-width: 100%; max-height: 90dvh; overflow-y: auto; box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6); position: relative; }

/* Layout Containers */
.sidebar { width: 320px; min-width: 280px; background: var(--surface-sidebar); border: 1px solid var(--border); border-radius: var(--radius-lg); display: flex; flex-direction: column; overflow: hidden; box-shadow: 0 8px 24px rgba(0,0,0,0.3); }
.chat-area { flex: 1; min-width: 0; display: flex; flex-direction: column; background: var(--surface-sidebar); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; position: relative; box-shadow: 0 8px 24px rgba(0,0,0,0.3); }

/* Header */
.chat-header { height: 64px; padding: 0 1.25rem; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; background: rgba(13, 17, 26, 0.85); backdrop-filter: blur(8px); gap: 0.75rem; }
.header-main-group { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; }
.header-title-group { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.header-title { font-size: 1rem; font-weight: 600; letter-spacing: -0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.header-status { font-size: 0.75rem; color: var(--text-muted); display: flex; align-items: center; gap: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.header-actions { display: flex; gap: 0.6rem; align-items: center; flex-shrink: 0; }
.btn-back { display: none; }

/* Empty State Placeholder */
.chat-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  margin: auto;
  padding: 2rem 1.5rem;
  max-width: 380px;
  color: var(--text-muted);
}
.chat-placeholder .placeholder-icon {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--surface-card);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  color: var(--primary);
  margin-bottom: 1rem;
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}
.chat-placeholder h3 {
  color: var(--text);
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 0.4rem;
}
.chat-placeholder p {
  font-size: 0.82rem;
  line-height: 1.5;
}

/* Tabs */
.nav-tabs { display: flex; margin: 12px 12px 6px; padding: 4px; background: var(--surface-card); border: 1px solid var(--border); border-radius: var(--radius-md); gap: 4px; }
.nav-tab { flex: 1; padding: 0.5rem 0.2rem; text-align: center; font-size: 0.78rem; font-weight: 600; color: var(--text-muted); cursor: pointer; border-radius: var(--radius-sm); transition: all 0.15s ease; }
.nav-tab:hover { color: var(--text); background: var(--surface-hover); }
.nav-tab.active { color: var(--text); background: var(--surface-elevated); box-shadow: 0 2px 6px rgba(0,0,0,0.3); }
.tab-content { flex: 1; overflow-y: auto; display: none; padding: 0.5rem; }
.tab-content.active { display: flex; flex-direction: column; }

/* List Items */
.list-item { padding: 0.65rem 0.85rem; border-radius: var(--radius-sm); cursor: pointer; display: flex; justify-content: space-between; align-items: center; margin-bottom: 3px; transition: background 0.15s; user-select: none; }
.list-item:hover { background: var(--surface-hover); }
.list-item.active { background: var(--surface-elevated); border: 1px solid var(--border); }
.dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; margin-right: 6px; }
.dot-online { background: var(--green); box-shadow: 0 0 8px var(--green); }
.dot-offline { background: var(--red); }
.unread-pill { background: var(--primary); color: #000; font-size: 0.65rem; font-weight: 700; padding: 1px 6px; border-radius: 20px; }

/* Group Accordion UI */
.group-parent-card { margin-bottom: 4px; border-radius: var(--radius-sm); background: transparent; transition: background 0.15s; }
.group-parent-card.open { background: rgba(255, 255, 255, 0.02); }
.group-parent-row { padding: 0.65rem 0.85rem; border-radius: var(--radius-sm); cursor: pointer; display: flex; justify-content: space-between; align-items: center; transition: background 0.15s; user-select: none; }
.group-parent-row:hover { background: var(--surface-hover); }
.group-parent-row.active { background: var(--surface-elevated); border: 1px solid var(--border); }
.group-channels-tree { display: none; flex-direction: column; padding-left: 2.2rem; padding-top: 2px; padding-bottom: 4px; gap: 2px; border-left: 1px solid rgba(255, 255, 255, 0.08); margin-left: 1.4rem; margin-top: 2px; margin-bottom: 4px; }
.group-channels-tree.open { display: flex; }
.group-channel-item { padding: 0.4rem 0.75rem; border-radius: var(--radius-sm); cursor: pointer; font-size: 0.78rem; color: var(--text-muted); display: flex; justify-content: space-between; align-items: center; transition: all 0.15s; }
.group-channel-item:hover { color: var(--text); background: var(--surface-hover); }
.group-channel-item.active { color: var(--primary); background: var(--surface-elevated); font-weight: 600; }
.group-chevron { font-size: 0.7rem; color: var(--text-muted); transition: transform 0.2s ease; display: inline-flex; align-items: center; justify-content: center; width: 16px; height: 16px; }
.group-chevron.open { transform: rotate(90deg); color: var(--text); }

/* Avatars */
.avatar { width: 36px; height: 36px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 0.85rem; color: #fff; flex-shrink: 0; position: relative; cursor: pointer; user-select: none; background-size: cover; background-position: center; border: 1px solid var(--border); }
.avatar.large { width: 70px; height: 70px; font-size: 1.6rem; border: 3px solid var(--surface-card); }
.avatar-dot { position: absolute; bottom: 0; right: 0; width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--surface-card); background: var(--green); }
.avatar-dot.offline { background: var(--red); }

/* Profile Footer */
.user-footer { padding: 0.75rem; border-top: 1px solid var(--border); background: rgba(13, 17, 26, 0.9); }
.user-card { display: flex; align-items: center; justify-content: space-between; padding: 0.5rem 0.6rem; border-radius: var(--radius-md); background: var(--surface-card); border: 1px solid var(--border); }
.user-profile-meta { display: flex; align-items: center; gap: 10px; min-width: 0; cursor: pointer; }
.user-names { display: flex; flex-direction: column; min-width: 0; }
.user-name-text { font-size: 0.82rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-status-text { font-size: 0.68rem; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.btn-icon { width: 32px; height: 32px; border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center; background: transparent; border: none; cursor: pointer; color: var(--text-muted); transition: all 0.15s; }
.btn-icon:hover { color: var(--text); background: var(--surface-hover); }

/* Messages & Bubbles */
.messages { flex: 1; padding: 1.25rem 1.5rem; overflow-y: auto; display: flex; flex-direction: column; gap: 1rem; }
.msg-row { display: flex; gap: 12px; align-items: flex-start; max-width: 80%; }
.msg-row.self { align-self: flex-end; flex-direction: row-reverse; }
.msg-content-wrapper { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.msg-header { display: flex; align-items: baseline; gap: 8px; font-size: 0.78rem; }
.msg-author { font-weight: 600; color: #bae6fd; cursor: pointer; text-decoration: none; }
.msg-author:hover { text-decoration: underline; color: var(--primary); }
.msg-time { font-size: 0.65rem; color: var(--text-muted); }
.msg-bubble { padding: 0.7rem 1rem; border-radius: var(--radius-md); background: var(--surface-card); border: 1px solid var(--border); font-size: 0.88rem; line-height: 1.4; word-break: break-word; position: relative; box-shadow: 0 2px 8px rgba(0,0,0,0.2); }
.msg-row.self .msg-bubble { background: #0369a1; border-color: rgba(56, 189, 248, 0.3); }

/* WhatsApp-Style Checkmarks */
.wa-check-container { display: inline-flex; align-items: center; margin-left: 6px; vertical-align: middle; }
.wa-check svg { width: 15px; height: 11px; }
.wa-check.queued { color: var(--text-muted); opacity: 0.75; }
.wa-check.synced { color: var(--wa-cyan); }

/* File Attachment Cards */
.file-card { display: flex; flex-direction: column; gap: 8px; background: rgba(0,0,0,0.25); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px; max-width: 320px; }
.file-meta-row { display: flex; align-items: center; gap: 10px; min-width: 0; }
.file-icon-box { width: 38px; height: 38px; border-radius: var(--radius-sm); background: var(--surface-elevated); display: flex; align-items: center; justify-content: center; font-size: 1.2rem; flex-shrink: 0; }
.file-details { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.file-name { font-size: 0.82rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text); }
.file-size { font-size: 0.68rem; color: var(--text-muted); }
.file-preview-img { width: 100%; max-height: 200px; object-fit: cover; border-radius: var(--radius-sm); border: 1px solid var(--border); cursor: pointer; }
.file-actions { display: flex; gap: 6px; align-items: center; }

/* Circular Download Progress */
.circle-progress-box { display: flex; align-items: center; gap: 8px; flex: 1; padding: 2px 0; min-width: 0; }
.circle-progress-wrap { position: relative; width: 34px; height: 34px; flex-shrink: 0; }
.circle-progress-svg { transform: rotate(-90deg); width: 34px; height: 34px; }
.circle-progress-bg { fill: none; stroke: rgba(255, 255, 255, 0.1); stroke-width: 3.5; }
.circle-progress-bar { fill: none; stroke: var(--primary); stroke-width: 3.5; stroke-linecap: round; stroke-dasharray: 88; stroke-dashoffset: 88; transition: stroke-dashoffset 0.15s ease; }
.circle-progress-val { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 0.62rem; font-weight: 700; color: var(--text); font-family: monospace; }
.circle-progress-info { display: flex; flex-direction: column; min-width: 0; }
.circle-progress-label { font-size: 0.72rem; color: var(--primary); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 1.2; }
.circle-progress-speed { font-size: 0.65rem; color: var(--text-muted); font-family: monospace; font-weight: 500; }

/* Input & Floating Footer */
.chat-footer { padding: 1rem 1.5rem; background: transparent; display: flex; gap: 0.6rem; align-items: center; }
.floating-input-row { flex: 1; display: flex; align-items: center; background: var(--surface-card); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 0.2rem 0.5rem; transition: border-color 0.2s; }
.floating-input-row:focus-within { border-color: var(--border-focus); box-shadow: 0 0 12px var(--primary-glow); }
.floating-input-row input { flex: 1; background: transparent; border: none; padding: 0.65rem 0.5rem; color: var(--text); font-size: 0.9rem; outline: none; }
button.btn-pill { padding: 0.55rem 1.1rem; border-radius: var(--radius-sm); font-size: 0.82rem; font-weight: 600; cursor: pointer; border: none; background: var(--primary); color: #050811; transition: opacity 0.15s; }
button.btn-pill:hover { opacity: 0.9; }
button:disabled { opacity: 0.35; cursor: not-allowed; }
.badge { font-family: monospace; font-size: 0.68rem; padding: 2px 7px; border-radius: 6px; background: rgba(255, 255, 255, 0.05); }

/* Profile Card Modal */
.profile-card-header { height: 80px; background: linear-gradient(135deg, #0284c7, #38bdf8); border-radius: 14px 14px 0 0; margin: -1.75rem -1.75rem 0; position: relative; }
.profile-card-avatar { position: absolute; bottom: -28px; left: 1.5rem; }
.profile-card-body { padding-top: 36px; }
.profile-field { margin-top: 1rem; }
.profile-field label { font-size: 0.68rem; font-weight: 700; color: var(--text-muted); text-transform: uppercase; display: block; margin-bottom: 4px; letter-spacing: 0.05em; }
.profile-box { background: var(--surface-sidebar); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 0.6rem 0.75rem; font-size: 0.82rem; }

.form-group { margin-bottom: 1rem; text-align: left; }
.form-group label { display: block; font-size: 0.75rem; color: var(--text-muted); margin-bottom: 0.35rem; font-weight: 500; }
.form-group input, .form-group textarea { width: 100%; background: var(--surface-sidebar); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 0.6rem; color: var(--text); font-size: 0.85rem; outline: none; }
.form-group textarea { resize: none; height: 60px; }
.error-banner { background: rgba(239, 68, 68, 0.15); border: 1px solid var(--red); color: #fca5a5; padding: 0.5rem; border-radius: var(--radius-sm); font-size: 0.75rem; display: none; margin-bottom: 0.75rem; }

/* Discord-Style Voice Stage & Controls */
.voice-stage-wrapper {
  display: flex;
  flex-direction: column;
  height: 100%;
  width: 100%;
  background: #111214;
  border-radius: var(--radius-md);
  position: relative;
  overflow: hidden;
}

.voice-stage-header {
  padding: 0.75rem 1.25rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  background: rgba(17, 18, 20, 0.85);
  backdrop-filter: blur(8px);
}

.voice-stage-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
}

.voice-stage-title i {
  color: var(--green);
}

.voice-stage-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.04);
  padding: 4px 10px;
  border-radius: 20px;
  border: 1px solid var(--border);
}

/* Voice Grid */
.voice-stage-grid {
  flex: 1;
  padding: 1rem;
  display: grid;
  gap: 12px;
  align-content: center;
  justify-content: center;
  overflow-y: auto;
  min-height: 0;
}

.voice-tile {
  background: #2b2d31;
  border-radius: 12px;
  border: 2px solid transparent;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  min-height: 180px;
  min-width: 240px;
  max-height: 100%;
  box-shadow: 0 4px 16px rgba(0,0,0,0.3);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.voice-tile.speaking {
  border-color: var(--green);
  box-shadow: 0 0 16px rgba(34, 197, 94, 0.45);
}

.voice-avatar-container {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
}

.voice-avatar {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
  transition: transform 0.15s ease;
}

.voice-tile.speaking .voice-avatar {
  transform: scale(1.05);
  box-shadow: 0 0 0 4px var(--green);
}

.voice-tile-footer {
  position: absolute;
  bottom: 8px;
  left: 8px;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  padding: 3px 8px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
  z-index: 2;
}

.voice-tile-name {
  font-size: 0.75rem;
  font-weight: 600;
  color: #fff;
}

.voice-tile-muted {
  color: var(--red);
  font-size: 0.7rem;
}

/* Video & Screenshare Tiles */
.voice-tile.video-tile {
  background: #000;
  justify-content: stretch;
}

.voice-video-container {
  width: 100%;
  height: 100%;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: #000;
}

.delta-video-canvas, .webrtc-video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
  border-radius: 8px;
}

.voice-screenshare-header {
  position: absolute;
  top: 8px;
  left: 8px;
  right: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 3;
}

.screenshare-badge {
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  color: var(--primary);
  font-size: 0.72rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  gap: 5px;
}

.btn-stop-screen {
  background: rgba(239, 68, 68, 0.8) !important;
  color: #fff !important;
  border-radius: 6px;
  width: 24px;
  height: 24px;
  font-size: 0.7rem;
}

.btn-stop-screen:hover {
  background: var(--red) !important;
}

.btn-fullscreen-screen {
  background: rgba(0, 0, 0, 0.6) !important;
  color: #fff !important;
  border-radius: 6px;
  width: 24px;
  height: 24px;
  font-size: 0.75rem;
}

/* Discord Floating Bottom Control Dock */
.voice-control-dock {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 10px 20px;
  background: rgba(17, 18, 20, 0.95);
  backdrop-filter: blur(12px);
  border-radius: 32px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
  margin: 0 auto 12px;
  z-index: 10;
  align-self: center;
}

.voice-dock-btn {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: #2b2d31;
  color: var(--text);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  position: relative;
  transition: all 0.15s ease;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.voice-dock-btn:hover {
  background: #35373c;
  transform: translateY(-2px);
}

.voice-dock-btn.active {
  background: var(--green);
  color: #000;
}

.voice-dock-btn.muted {
  background: rgba(239, 68, 68, 0.2);
  color: var(--red);
  border: 1px solid rgba(239, 68, 68, 0.4);
}

.voice-dock-btn.danger {
  background: var(--red);
  color: #fff;
}

.voice-dock-btn.danger:hover {
  background: #dc2626;
  transform: translateY(-2px);
}

.screenshare-btn-group {
  display: flex;
  align-items: center;
  gap: 4px;
  position: relative;
}

.voice-dock-btn-sub {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--primary);
  color: #000;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.68rem;
  font-weight: 700;
  transition: transform 0.15s;
}

.voice-dock-btn-sub:hover {
  transform: scale(1.15);
}

.dock-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  background: var(--primary);
  color: #000;
  font-size: 0.62rem;
  font-weight: 800;
  border-radius: 10px;
  padding: 1px 5px;
}

/* ==========================================================================
   Mobile Responsive Layout & Touch Ergonomics (<= 768px)
   ========================================================================== */
@media (max-width: 768px) {
  body {
    padding: 0;
    gap: 0;
    height: 100dvh;
    width: 100vw;
    border-radius: 0;
  }

  .sidebar, .chat-area {
    border-radius: 0;
    border: none;
    height: 100%;
    width: 100%;
    box-shadow: none;
  }

  /* Single-view mobile navigation */
  body.no-space-selected .sidebar {
    display: flex !important;
    width: 100% !important;
    flex: 1 !important;
  }
  body.no-space-selected .chat-area {
    display: none !important;
  }

  body:not(.no-space-selected) .sidebar {
    display: none !important;
  }
  body:not(.no-space-selected) .chat-area {
    display: flex !important;
    width: 100% !important;
    flex: 1 !important;
  }

  /* Back Button */
  .btn-back {
    display: flex !important;
    width: 38px;
    height: 38px;
    font-size: 1.1rem;
    color: var(--text);
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
  }
  .btn-back:active {
    background: var(--surface-hover);
  }

  /* Chat Header */
  .chat-header {
    height: auto;
    min-height: 56px;
    padding: 0.6rem 0.85rem;
    padding-top: max(0.6rem, env(safe-area-inset-top));
    padding-left: max(0.85rem, env(safe-area-inset-left));
    padding-right: max(0.85rem, env(safe-area-inset-right));
    gap: 0.5rem;
  }
  .header-main-group {
    gap: 8px;
  }
  .header-title {
    font-size: 0.95rem;
  }
  .header-status {
    font-size: 0.7rem;
  }

  /* Chat Messages */
  .messages {
    padding: 0.75rem 0.75rem;
    gap: 0.75rem;
    -webkit-overflow-scrolling: touch;
  }
  .msg-row {
    max-width: 88%;
    gap: 8px;
  }
  .msg-bubble {
    font-size: 0.9rem;
    padding: 0.6rem 0.85rem;
  }
  .file-card {
    max-width: 100%;
  }

  /* Chat Footer & Input */
  .chat-footer {
    padding: 0.5rem 0.75rem;
    padding-bottom: max(0.5rem, env(safe-area-inset-bottom));
    padding-left: max(0.75rem, env(safe-area-inset-left));
    padding-right: max(0.75rem, env(safe-area-inset-right));
    gap: 0.5rem;
  }
  .floating-input-row input {
    font-size: 16px !important; /* Prevents iOS Safari auto-zoom */
    padding: 0.55rem 0.5rem;
  }
  .btn-icon {
    width: 38px;
    height: 38px;
    font-size: 1.05rem;
  }
  button.btn-pill {
    padding: 0.55rem 1rem;
    min-height: 38px;
    font-size: 0.85rem;
  }

  /* Sidebar touch targets */
  .nav-tabs {
    margin: 8px 8px 4px;
    padding: 3px;
  }
  .nav-tab {
    padding: 0.6rem 0.3rem;
    min-height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.82rem;
  }
  .list-item {
    padding: 0.75rem 0.85rem;
    min-height: 48px;
  }
  .list-item:active {
    background: var(--surface-hover);
  }
  .group-parent-row {
    padding: 0.75rem 0.85rem;
    min-height: 46px;
  }
  .group-channel-item {
    padding: 0.55rem 0.85rem;
    min-height: 40px;
  }

  /* User footer in sidebar */
  .user-footer {
    padding: 0.65rem 0.75rem;
    padding-bottom: max(0.65rem, env(safe-area-inset-bottom));
    padding-left: max(0.75rem, env(safe-area-inset-left));
    padding-right: max(0.75rem, env(safe-area-inset-right));
  }
  .user-card {
    padding: 0.55rem 0.65rem;
    min-height: 48px;
  }

  /* Form inputs in modals & tabs: prevent iOS zoom */
  .form-group input,
  .form-group textarea,
  #target-pubkey-in,
  #group-name-in,
  #auth-username-in {
    font-size: 16px !important;
  }

  /* Modals on Mobile */
  .modal-backdrop {
    padding: 12px;
    align-items: center;
    justify-content: center;
  }
  .floating-card {
    width: 100% !important;
    max-width: calc(100vw - 24px) !important;
    max-height: calc(100dvh - 32px);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    margin: 0;
  }

  /* Voice Channel & Video Grid on Mobile */
  .voice-stage-grid {
    padding: 0.5rem;
    gap: 8px;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    align-content: flex-start;
  }
  .voice-tile {
    min-width: 0 !important;
    min-height: 120px !important;
    height: 140px;
    border-radius: 8px;
  }
  .voice-avatar {
    width: 52px;
    height: 52px;
  }
  .voice-control-dock {
    padding: 6px 12px;
    gap: 8px;
    margin-bottom: max(8px, env(safe-area-inset-bottom));
    border-radius: 24px;
    max-width: 95%;
  }
  .voice-dock-btn {
    width: 42px;
    height: 42px;
    font-size: 1rem;
  }
  .voice-dock-btn-sub {
    width: 20px;
    height: 20px;
    font-size: 0.6rem;
  }
}

/* Extra small mobile screens (<= 480px) */
@media (max-width: 480px) {
  .badge-sig {
    display: none !important;
  }
  .badge-e2ee .badge-text {
    display: none;
  }
  .header-actions {
    gap: 0.35rem;
  }
}

