:root,
html[data-theme="onyx"] {
  --rail: #121214;
  --sidebar: #16171B;
  --pane: #1B1C21;
  --elevated: #23252C;
  --elevated-2: #2D3039;
  --border: rgba(255, 255, 255, 0.075);
  --border-hi: rgba(255, 255, 255, 0.14);
  --pop-bg: rgba(20, 21, 26, 0.94);
  --pop-border: rgba(255, 255, 255, 0.11);
  --pop-shadow: 0 18px 48px rgba(0, 0, 0, 0.62), 0 0 0 1px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  --ink: #F2F3F5;
  --ink-soft: #C9CDD4;
  --muted: #8E929B;
  --accent: #5865F2;
  --live: #23A55A;
  --danger: #DA373C;
  --radius: 12px;
  --radius-sm: 8px;
  --titlebar-h: 0px;
  --msg-font: 14px;
  --font: 'Plus Jakarta Sans', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

html[data-theme="ash"] {
  --rail: #1E1F22;
  --sidebar: #232428;
  --pane: #2B2D31;
  --elevated: #313338;
  --elevated-2: #3B3D44;
  --border: rgba(255, 255, 255, 0.08);
  --border-hi: rgba(255, 255, 255, 0.15);
  --ink: #F2F3F5;
  --ink-soft: #DBDEE1;
  --muted: #949BA4;
}

html[data-theme="midnight"] {
  --rail: #07080A;
  --sidebar: #0D0E12;
  --pane: #121318;
  --elevated: #1A1C24;
  --elevated-2: #242732;
  --border: rgba(255, 255, 255, 0.07);
  --border-hi: rgba(255, 255, 255, 0.14);
  --ink: #F4F5F7;
  --ink-soft: #C6CAD2;
  --muted: #838793;
}

html.is-desktop { --titlebar-h: 32px; }

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  background: var(--rail);
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  background: var(--rail);
  color: var(--ink);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.45;
  letter-spacing: -0.01em;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  overscroll-behavior: none;
}

@media (display-mode: standalone) {
  html, body {
    height: 100vh;
    height: 100lvh;
    min-height: -webkit-fill-available;
    background: var(--pane);
  }
}

html.pwa-standalone,
html.pwa-standalone body {
  height: 100vh;
  height: 100lvh;
  min-height: -webkit-fill-available;
  background: var(--pane);
}

/* Custom Scrollbars */
* { scrollbar-width: thin; scrollbar-color: transparent transparent; }
*:hover { scrollbar-color: rgba(255, 255, 255, 0.16) transparent; }
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: transparent; border-radius: 99px; }
*:hover::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.16); }
::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.28); }

.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 12px; }
.num, .mono {
  font-family: var(--font);
  font-variant-numeric: tabular-nums;
  font-feature-settings: "zero" 0, "tnum" 1;
}
button, input, textarea, select { font-family: inherit; color: inherit; }

/* =========================
   FRAMELESS DESKTOP TITLEBAR (Discord Windows Native Feel)
   ========================= */
.desktop-titlebar {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 32px;
  background: var(--rail);
  align-items: center;
  justify-content: flex-end;
  z-index: 200;
  user-select: none;
  -webkit-app-region: drag;
}
html.is-desktop .desktop-titlebar { display: flex; }

.titlebar-controls {
  display: flex;
  height: 100%;
  -webkit-app-region: no-drag;
}
.win-btn {
  width: 44px;
  height: 32px;
  border: none;
  background: transparent;
  color: var(--ink-soft);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 110ms ease, color 110ms ease;
}
.win-btn svg { width: 11px; height: 11px; }
.win-btn:hover { background: rgba(255, 255, 255, 0.08); color: #fff; }
.win-btn.win-close:hover { background: var(--danger); color: #fff; }

/* =========================
   BUTTONS & INPUTS
   ========================= */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid transparent;
  border-radius: 9px;
  padding: 0 14px;
  height: 36px;
  font-weight: 600;
  font-size: 13px;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease, filter 120ms ease, transform 70ms ease, box-shadow 120ms ease;
}
.btn:active { transform: scale(0.975); }
.btn:disabled { opacity: 0.48; cursor: not-allowed; pointer-events: none; }
.btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.16);
}
.btn-primary:hover { filter: brightness(1.08); }
.btn-live {
  background: var(--live);
  color: #fff;
  font-weight: 600;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18);
}
.btn-live:hover { filter: brightness(1.08); }
.btn-danger { background: rgba(218, 55, 60, 0.14); border-color: rgba(218, 55, 60, 0.34); color: #F79A9D; }
.btn-danger:hover { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-ghost { background: var(--elevated); border-color: var(--border-hi); color: var(--ink); }
.btn-ghost:hover { background: var(--elevated-2); border-color: rgba(255, 255, 255, 0.2); }
.btn-sm { height: 32px; padding: 0 12px; font-size: 12px; border-radius: 8px; }
.btn-square { width: 36px; height: 36px; padding: 0; font-size: 17px; font-weight: 600; flex-shrink: 0; }
.btn-full { width: 100%; }

button:focus-visible,
a:focus-visible,
.switch input:focus-visible + .slider {
  outline: 2px solid color-mix(in srgb, var(--accent) 78%, #fff);
  outline-offset: 2px;
}

.chip-btn {
  background: var(--elevated);
  border: 1px solid var(--border-hi);
  color: var(--ink-soft);
  height: 30px;
  padding: 0 13px;
  border-radius: 99px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 120ms ease, color 120ms ease, border-color 120ms ease;
}
.chip-btn:hover { background: var(--elevated-2); color: #fff; border-color: rgba(255, 255, 255, 0.2); }

.icon-btn {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--ink-soft);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 120ms ease, color 120ms ease, transform 70ms ease;
}
.icon-btn:hover, .icon-btn.active { background: var(--elevated-2); color: #fff; }
.icon-btn:active { transform: scale(0.94); }
.icon-btn.accent-hover:hover { color: #fff; background: color-mix(in srgb, var(--accent) 24%, transparent); }
.icon-btn.recording { color: #fff; background: var(--danger); animation: pulse-rec 1.1s infinite; }
.icon-btn.sm { width: 28px; height: 28px; border-radius: 7px; }
.icon-btn svg { width: 17px; height: 17px; }
.icon-btn.sm svg { width: 15px; height: 15px; }

@keyframes pulse-rec {
  0%, 100% { box-shadow: 0 0 0 0 rgba(218, 55, 60, 0.5); }
  50% { box-shadow: 0 0 0 7px rgba(218, 55, 60, 0); }
}

input[type="text"], input[type="password"], input[type="search"], input[type="url"], textarea, select {
  background: var(--rail);
  border: 1px solid var(--border-hi);
  border-radius: 9px;
  padding: 9px 12px;
  font-size: 13.5px;
  outline: none;
  transition: border-color 120ms ease, background 120ms ease;
}
input:focus, textarea:focus, select:focus {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--rail) 85%, var(--accent) 5%);
}
select option { background: var(--sidebar); color: var(--ink); }

/* =========================
   AUTH SCREEN
   ========================= */
.auth-screen {
  position: fixed;
  top: calc(var(--app-top, 0px) + var(--titlebar-h));
  left: 0;
  right: 0;
  height: calc(var(--app-h, 100dvh) - var(--titlebar-h));
  display: grid;
  place-items: center;
  padding: calc(20px + env(safe-area-inset-top, 0px)) 20px calc(20px + env(safe-area-inset-bottom, 0px));
  background: radial-gradient(circle at 50% 10%, color-mix(in srgb, var(--accent) 22%, transparent), transparent 50%), var(--rail);
  overflow-y: auto;
}
.auth-card {
  width: 100%;
  max-width: 348px;
  background: var(--pane);
  border: 1px solid var(--border-hi);
  border-radius: 16px;
  padding: 26px 22px 22px;
  display: flex;
  flex-direction: column;
  gap: 15px;
  box-shadow: 0 28px 72px rgba(0, 0, 0, 0.62), inset 0 1px 0 rgba(255, 255, 255, 0.06);
}
.auth-brand { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.auth-brand img { border-radius: 15px; box-shadow: 0 10px 26px rgba(0, 0, 0, 0.4); }
.auth-brand h1 { margin: 0; font-size: 19px; font-weight: 700; letter-spacing: -0.025em; }
.auth-form { display: flex; flex-direction: column; gap: 9px; }
.auth-form input { height: 40px; padding: 0 12px; }
.auth-form .btn-primary { margin-top: 4px; height: 40px; }
.invite-banner {
  background: color-mix(in srgb, var(--accent) 18%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 42%, transparent);
  border-radius: 9px;
  padding: 8px 11px;
  font-size: 12.5px;
  text-align: center;
  font-weight: 600;
}
.form-error {
  background: rgba(218, 55, 60, 0.16);
  border: 1px solid rgba(218, 55, 60, 0.4);
  color: #FCA5A5;
  padding: 8px 11px;
  border-radius: 9px;
  font-size: 12.5px;
}

.segmented {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  background: var(--rail);
  padding: 3px;
  border-radius: 10px;
  border: 1px solid var(--border);
}
.seg-btn {
  border: none;
  background: transparent;
  color: var(--muted);
  font-weight: 600;
  font-size: 12.5px;
  padding: 6px 10px;
  border-radius: 7px;
  cursor: pointer;
  transition: background 110ms ease, color 110ms ease;
}
.seg-btn:hover { color: var(--ink); }
.seg-btn.active { background: var(--elevated-2); color: #fff; }

/* =========================
   DISCORD-INSPIRED APP SHELL
   ========================= */
.app-shell {
  position: fixed;
  top: calc(var(--app-top, 0px) + var(--titlebar-h));
  left: 0;
  right: 0;
  width: 100%;
  height: calc(var(--app-h, 100dvh) - var(--titlebar-h));
  display: flex;
  gap: 0;
  padding: 0;
  background: var(--rail);
  overflow: hidden;
}

.sidebar {
  width: 266px;
  flex-shrink: 0;
  background: var(--sidebar);
  border-top: 1px solid var(--border);
  border-right: 1px solid var(--border);
  border-top-left-radius: 12px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
html:not(.is-desktop) .sidebar { border-top: none; border-top-left-radius: 0; }
.sidebar-inner {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.sidebar-header {
  height: 50px;
  padding: 0 10px 0 14px;
  background: var(--sidebar);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  position: relative;
  z-index: 10;
}
.sidebar-brand { display: flex; align-items: center; gap: 9px; }
.sidebar-brand img { border-radius: 6px; }
.brand-title { font-weight: 700; font-size: 14.5px; letter-spacing: -0.02em; line-height: 1; display: inline-flex; align-items: center; }
.status-pill-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); flex-shrink: 0; align-self: center; }
.status-pill-dot.online { background: var(--live); box-shadow: 0 0 0 2px rgba(35, 165, 90, 0.25); }

.sidebar-search { position: relative; padding: 9px 10px 8px; }
.sidebar-search .search-ic {
  position: absolute;
  left: 20px;
  top: 50%;
  transform: translateY(-48%);
  width: 14px;
  height: 14px;
  color: var(--muted);
  pointer-events: none;
}
.sidebar-search input {
  width: 100%;
  height: 34px;
  padding: 0 10px 0 32px;
  font-size: 13px;
  background: var(--rail);
  border: 1px solid var(--border);
  border-radius: 8px;
}

/* Inline New Chat Panel */
.new-panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.inline-form { display: flex; flex-direction: column; gap: 9px; }
.suggestions { display: flex; flex-direction: column; gap: 4px; max-height: 240px; overflow-y: auto; }
.suggestion-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 9px;
  border-radius: 9px;
  background: var(--elevated);
  border: 1px solid transparent;
  cursor: pointer;
  text-align: left;
  font-size: 13px;
  font-weight: 500;
}
.suggestion-item:hover { background: var(--elevated-2); border-color: var(--border-hi); }

.pwa-banner {
  margin: 0 10px 8px;
  padding: 8px 10px;
  background: color-mix(in srgb, var(--accent) 16%, var(--elevated));
  border: 1px solid color-mix(in srgb, var(--accent) 36%, transparent);
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  font-weight: 600;
}
.pwa-banner-actions { display: flex; align-items: center; gap: 4px; }

.room-list {
  flex: 1;
  overflow-y: auto;
  padding: 2px 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.room-swipe-wrap {
  position: relative;
  overflow: hidden;
  border-radius: 9px;
}
.room-swipe-del {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 78px;
  border: none;
  background: var(--danger);
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: opacity 110ms ease;
}
.room-swipe-wrap.swiped .room-swipe-del,
.room-swipe-wrap.swiping-open .room-swipe-del {
  opacity: 1;
  pointer-events: auto;
}
.room-swipe-del svg { width: 17px; height: 17px; }
.room-swipe-del:hover { filter: brightness(1.08); }
.room-item {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 9px;
  border-radius: 9px;
  border: 1px solid transparent;
  background: var(--sidebar);
  text-align: left;
  width: 100%;
  cursor: pointer;
  transition: background 110ms ease, border-color 110ms ease, transform 200ms cubic-bezier(0.22, 1, 0.36, 1);
  user-select: none;
}
.room-item.swiping { transition: none; }
.room-item:hover { background: var(--elevated); }
.room-item.active {
  background: var(--elevated-2);
  border-color: var(--border);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}
.room-item-body { flex: 1; min-width: 0; }
.room-item-top { display: flex; justify-content: space-between; align-items: baseline; gap: 6px; }
.room-item-name { font-weight: 600; font-size: 13.5px; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.room-item-time { font-size: 10.5px; color: var(--muted); flex-shrink: 0; font-variant-numeric: tabular-nums; }
.room-item-bottom { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-top: 2px; }
.room-item-preview { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.unread-badge {
  background: var(--accent);
  color: #fff;
  font-size: 10.5px;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 99px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.call-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(35, 165, 90, 0.18);
  border: 1px solid rgba(35, 165, 90, 0.36);
  color: #5BE08E;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 99px;
}
.room-item.has-call .avatar {
  box-shadow: 0 0 0 2px var(--sidebar), 0 0 0 4px rgba(35, 165, 90, 0.85);
}
.room-item.has-call {
  background: rgba(35, 165, 90, 0.06);
}
.room-item.has-call:hover {
  background: rgba(35, 165, 90, 0.12);
}

/* Mobile-only home helpers (hidden on desktop) */
.mobile-quick-actions,
.mobile-section-bar,
.mobile-bottom-nav { display: none; }

/* Rich Empty Room List Card */
.room-empty-search { padding: 20px 12px; text-align: center; color: var(--muted); font-size: 13px; }
.room-empty-card {
  margin: 14px 4px;
  padding: 22px 16px;
  background: var(--elevated);
  border: 1px solid var(--border-hi);
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 8px;
}
.room-empty-ic img { border-radius: 14px; display: block; box-shadow: 0 10px 26px rgba(0, 0, 0, 0.45); }
.room-empty-card strong { font-size: 15px; font-weight: 700; color: var(--ink); margin-top: 4px; }
.room-empty-card p { margin: 0; font-size: 12.5px; line-height: 1.45; color: var(--muted); max-width: 240px; }
.room-empty-btns { width: 100%; display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }

/* Animated Live Audio Equalizer Bars */
.live-eq {
  display: inline-flex;
  align-items: flex-end;
  gap: 2.5px;
  height: 15px;
  padding: 1px 0;
  flex-shrink: 0;
}
.live-eq i {
  display: block;
  width: 3px;
  height: 100%;
  border-radius: 99px;
  background: #4CE088;
  transform-origin: bottom center;
  animation: liveEq 920ms ease-in-out infinite;
}
.live-eq i:nth-child(1) { animation-delay: 0ms; }
.live-eq i:nth-child(2) { animation-delay: 180ms; }
.live-eq i:nth-child(3) { animation-delay: 340ms; }
.live-eq.sm { height: 11px; gap: 2px; }
.live-eq.sm i { width: 2.5px; }
.live-eq.xs { height: 10px; gap: 1.5px; }
.live-eq.xs i { width: 2px; }

@keyframes liveEq {
  0%, 100% { transform: scaleY(0.28); opacity: 0.7; }
  45% { transform: scaleY(1); opacity: 1; }
  72% { transform: scaleY(0.52); opacity: 0.85; }
}

/* Discord-Style Inset User Dock Card (Baseline-locked to Chat Composer!) */
.sidebar-footer {
  padding: 4px 10px 12px;
  background: var(--sidebar);
  flex-shrink: 0;
}
.me-dock {
  height: 46px;
  background: var(--rail);
  border: 1px solid var(--border);
  border-radius: 11px;
  padding: 0 7px 0 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}
.me-info { display: flex; align-items: center; gap: 9px; min-width: 0; }
.me-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.2; }
.me-text strong { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me-actions { display: flex; align-items: center; gap: 2px; }

/* Avatars */
.avatar {
  position: relative;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
  user-select: none;
  background-size: cover;
  background-position: center;
}
.avatar.has-img { color: transparent; }
.avatar-edit-btn {
  position: relative;
  border: none;
  background: transparent;
  padding: 0;
  cursor: pointer;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.avatar-edit-btn:active { transform: scale(0.96); }
.avatar-cam-badge {
  position: absolute;
  right: -2px;
  bottom: -2px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  border: 2px solid var(--elevated);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.45);
}
.avatar-cam-badge svg { width: 12px; height: 12px; }
.avatar-cam-badge.lg { width: 28px; height: 28px; right: 0; bottom: 0; }
.avatar-cam-badge.lg svg { width: 15px; height: 15px; }
.avatar.xs { width: 24px; height: 24px; font-size: 10px; }
.avatar.sm { width: 32px; height: 32px; font-size: 12px; }
.avatar.md { width: 36px; height: 36px; font-size: 13.5px; }
.avatar.lg { width: 58px; height: 58px; font-size: 21px; }
.avatar.xl { width: 76px; height: 76px; font-size: 27px; }
.avatar .online-dot {
  position: absolute;
  right: -1px;
  bottom: -1px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--live);
  border: 2px solid var(--sidebar);
}

/* =========================
   MAIN SURFACE
   ========================= */
.main-pane {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--pane);
  border-top: 1px solid var(--border);
  overflow: hidden;
}
html:not(.is-desktop) .main-pane { border-top: none; }

.empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  text-align: center;
  padding: 24px;
}
.empty-state img { border-radius: 15px; box-shadow: 0 14px 36px rgba(0, 0, 0, 0.45); }
.empty-copy { display: flex; flex-direction: column; gap: 4px; }
.empty-copy h2 { margin: 0; font-size: 17px; font-weight: 700; letter-spacing: -0.02em; color: var(--ink); }
.empty-copy p { margin: 0; font-size: 13px; }
.empty-actions { display: flex; gap: 8px; margin-top: 2px; }

.pane-header {
  height: 50px;
  padding: 0 12px 0 14px;
  background: var(--pane);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-shrink: 0;
  position: relative;
  z-index: 10;
}
.pane-head-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.pane-head-left h2 { margin: 0; font-size: 15px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-profile-trigger {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 4px 10px 4px 4px;
  margin-left: -4px;
  border: none;
  border-radius: 12px;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
  transition: background 140ms ease;
}
.chat-profile-trigger:hover { background: var(--elevated); }
.chat-profile-trigger:active { transform: scale(0.985); }
.chat-title-wrap { min-width: 0; display: flex; flex-direction: column; }
.chat-header-actions { display: flex; align-items: center; gap: 3px; flex-shrink: 0; }
.header-sep { width: 1px; height: 18px; background: var(--border-hi); margin: 0 5px; }

/* =========================
   CRISP HIGH-CONTRAST SETTINGS (Web + Mobile Apple-Grade Controls)
   ========================= */
.settings-view { flex: 1; display: flex; flex-direction: column; min-height: 0; background: var(--pane); }
.settings-layout {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  max-width: 760px;
  width: 100%;
  margin: 0 auto;
  padding: 20px 20px 28px;
  gap: 18px;
  overflow-y: auto;
  overflow-x: hidden;
}
.settings-profile-card {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 16px;
  background: var(--sidebar);
  border: 1px solid var(--border-hi);
  border-radius: 16px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}
.settings-profile-top {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.status-edit-row {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.status-edit-row input {
  flex: 1;
  min-width: 0;
  height: 36px;
  padding: 0 12px;
  font-size: 13px;
  background: var(--rail);
  border: 1px solid var(--border-hi);
  border-radius: 9px;
  color: var(--ink);
}
.status-edit-row input:focus { border-color: var(--accent); outline: none; }
.status-edit-row .btn { height: 36px; padding: 0 14px; border-radius: 9px; }
.settings-profile-left {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
  flex: 1;
}
.settings-profile-left .avatar.md { width: 50px; height: 50px; font-size: 17px; }
.settings-profile-meta { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.settings-profile-meta strong { font-size: 15.5px; font-weight: 700; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.settings-profile-meta span { font-size: 12.5px; color: var(--ink-soft); opacity: 0.78; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.settings-profile-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.settings-profile-card .btn-primary { border-radius: 9px; height: 34px; padding: 0 14px; }
.settings-card.account-card {
  padding: 0;
  gap: 0;
  overflow: hidden;
}
.account-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 13px 16px;
}
.account-row + .account-row {
  border-top: 1px solid var(--border);
}
.account-row-danger {
  background: rgba(218, 55, 60, 0.05);
}
.account-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.account-meta strong { font-size: 13.5px; font-weight: 600; color: var(--ink); }
.account-row-danger .account-meta strong { color: #F7B4B6; }
.account-meta .muted { font-size: 12px; color: var(--muted); }
.account-row .btn { min-width: 92px; flex-shrink: 0; }
.settings-save-row {
  display: flex;
  justify-content: flex-end;
  padding-top: 2px;
}
.settings-save-row .btn {
  min-width: 148px;
  height: 38px;
}
.settings-nav {
  width: 170px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.snav-btn {
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink-soft);
  text-align: left;
  padding: 10px 13px;
  border-radius: 10px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease, border-color 120ms ease;
}
.snav-btn:hover { background: var(--sidebar); color: #fff; }
.snav-btn.active { background: var(--elevated); border-color: var(--border-hi); color: #fff; }

.settings-content { flex: 1; min-width: 0; max-width: 100%; }
.settings-panel { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.settings-card {
  background: var(--sidebar);
  border: 1px solid var(--border-hi);
  border-radius: 15px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
  max-width: 100%;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}
.card-section-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-soft);
  opacity: 0.85;
}

/* Theme Picker Cards */
.theme-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}
.theme-card {
  background: var(--rail);
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-soft);
  transition: border-color 120ms ease, transform 90ms ease, background 120ms ease;
}
.theme-card:hover { border-color: var(--border-hi); color: #fff; }
.theme-card.active {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, var(--rail));
  color: #fff;
}
.theme-preview {
  width: 100%;
  height: 48px;
  border-radius: 8px;
  overflow: hidden;
  display: flex;
  border: 1px solid rgba(255, 255, 255, 0.1);
}
.theme-preview i { width: 32%; display: block; height: 100%; }
.theme-preview b { flex: 1; display: block; height: 100%; }
.tp-onyx i { background: #121214; }
.tp-onyx b { background: #1B1C21; }
.tp-ash i { background: #1E1F22; }
.tp-ash b { background: #2B2D31; }
.tp-midnight i { background: #07080A; }
.tp-midnight b { background: #121318; }

/* Accent Swatches */
.accent-swatches { display: flex; flex-wrap: wrap; gap: 11px; align-items: center; }
.accent-dot {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid transparent;
  background: var(--sw);
  cursor: pointer;
  flex-shrink: 0;
  transition: transform 110ms ease, box-shadow 110ms ease;
}
.accent-dot:hover { transform: scale(1.1); }
.accent-dot.active { box-shadow: 0 0 0 2px var(--sidebar), 0 0 0 4px #fff; }
.accent-custom {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: conic-gradient(#F43F5E, #F59E0B, #23A55A, #06B6D4, #5865F2, #EB459E, #F43F5E);
  color: #fff;
  overflow: hidden;
}
.accent-custom.active { background: var(--sw); }
.accent-custom input[type="color"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  border: none;
  padding: 0;
}
.accent-custom svg {
  width: 16px;
  height: 16px;
  pointer-events: none;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.7));
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
  max-width: 100%;
}
.setting-label { font-size: 13px; font-weight: 600; color: var(--ink); width: 104px; flex-shrink: 0; }
#btn-mic-test { width: 104px; flex-shrink: 0; height: 34px; }
.setting-select, .setting-input {
  flex: 1;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  height: 38px;
  padding: 0 12px;
  font-size: 13px;
  font-weight: 500;
  color: #fff;
  background: var(--elevated);
  border: 1px solid var(--border-hi);
  border-radius: 9px;
}
.setting-select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 34px;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23C9CDD4' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 15px;
}
#spanel-server .setting-row .btn { height: 38px; padding: 0 14px; border-radius: 9px; }
.mic-meter-track { flex: 1; min-width: 0; height: 8px; min-height: 8px; background: var(--rail); border: 1px solid var(--border); border-radius: 99px; overflow: hidden; }
.mic-meter-fill { height: 100%; width: 0%; background: var(--live); border-radius: 99px; transition: width 60ms linear; }
.toggle-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 14px;
  font-weight: 500;
  color: #fff;
  cursor: pointer;
  padding: 2px 0;
}
.toggle-item + .toggle-item {
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.switch { position: relative; width: 44px; height: 24px; display: inline-block; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; inset: 0; background: var(--elevated-2); border: 1px solid var(--border-hi); border-radius: 99px; transition: background 140ms ease; }
.slider::before { content: ''; position: absolute; width: 18px; height: 18px; left: 2px; top: 2px; border-radius: 50%; background: #fff; transition: transform 140ms ease; box-shadow: 0 2px 4px rgba(0, 0, 0, 0.35); }
.switch input:checked + .slider { background: var(--live); border-color: var(--live); }
.switch input:checked + .slider::before { transform: translateX(20px); }
.server-presets { display: flex; gap: 8px; }

/* =========================
   CHAT SHELL + CALL MODE + RIGHT SIDEBAR
   ========================= */
.chat-shell { flex: 1; display: flex; min-height: 0; position: relative; }
.chat-column { flex: 1; min-width: 0; display: flex; flex-direction: column; min-height: 0; }

.chat-shell.call-mode #chat-body-wrap,
.chat-shell.call-mode #chat-search-bar { display: none !important; }
.chat-shell.call-mode #call-stage { flex: 1; display: flex !important; }

.chat-shell.call-mode.call-chat-open #chat-body-wrap {
  display: flex !important;
  position: absolute;
  top: 50px;
  right: 0;
  bottom: 0;
  width: 348px;
  background: var(--pane);
  border-left: 1px solid var(--border-hi);
  z-index: 25;
  box-shadow: -16px 0 40px rgba(0, 0, 0, 0.55);
}

/* Rich Compact Live Ongoing Call Preview Card (Web & Mobile Identical Aesthetic) */
.return-call-bar, .join-call-banner {
  margin: 10px 16px 4px;
  padding: 10px 12px;
  background: linear-gradient(105deg, rgba(35, 165, 90, 0.22), rgba(35, 165, 90, 0.08) 55%, var(--sidebar));
  border: 1px solid rgba(76, 224, 136, 0.36);
  border-radius: 15px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-shrink: 0;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.34), inset 0 1px 0 rgba(255, 255, 255, 0.09);
  animation: callBarIn 260ms cubic-bezier(0.22, 1, 0.36, 1) both;
}
@keyframes callBarIn {
  from { opacity: 0; transform: translateY(-8px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.join-call-left {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
  flex: 1;
}
.call-preview-thumb {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}
.call-preview-thumb video {
  width: 58px;
  height: 36px;
  border-radius: 8px;
  object-fit: cover;
  background: #000;
  border: 1px solid rgba(76, 224, 136, 0.45);
  display: block;
}
.call-avatar-stack {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
}
.call-avatar-stack .avatar.xs {
  width: 30px;
  height: 30px;
  font-size: 11px;
  border: 2px solid var(--sidebar);
  box-shadow: 0 0 0 1.5px rgba(76, 224, 136, 0.65);
}
.call-avatar-stack .avatar.xs + .avatar.xs { margin-left: -9px; }
.call-av-more {
  margin-left: -6px;
  height: 24px;
  padding: 0 6px;
  border-radius: 99px;
  background: var(--elevated-2);
  border: 1px solid var(--border-hi);
  color: #fff;
  font-size: 10.5px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
}
.call-bar-meta {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
  flex: 1;
  overflow: hidden;
  line-height: 1.2;
}
.call-bar-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 5px;
  min-width: 0;
}
.call-bar-title {
  font-size: 13px;
  font-weight: 700;
  color: #E7FFF0;
  letter-spacing: -0.01em;
  white-space: nowrap;
}
.call-media-badges { display: inline-flex; align-items: center; gap: 4px; }
.call-mchip {
  font-size: 10px;
  font-weight: 700;
  color: #E7FFF0;
  background: rgba(35, 165, 90, 0.34);
  border: 1px solid rgba(76, 224, 136, 0.4);
  padding: 1px 6px;
  border-radius: 99px;
}
.call-bar-sub {
  font-size: 12px;
  font-weight: 500;
  color: #9CEAB9;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.call-bar-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.call-mini-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.call-mini-btn svg { width: 16px; height: 16px; }
.call-mini-btn.muted-off { background: rgba(218, 55, 60, 0.28); border-color: rgba(218, 55, 60, 0.45); color: #FCA5A5; }
.pulse-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--live); flex-shrink: 0; box-shadow: 0 0 0 3px rgba(35, 165, 90, 0.25); }
.join-call-banner .btn-live,
.return-call-bar .btn-live {
  border-radius: 99px;
  padding: 7px 14px;
  font-size: 12.5px;
  font-weight: 700;
  flex-shrink: 0;
  box-shadow: 0 4px 16px rgba(35, 165, 90, 0.42);
}

/* Empty Conversation Starter Card (anchored cleanly near TOP) */
.chat-empty-intro {
  margin: 22px auto 0;
  padding: 20px 20px 28px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 8px;
  max-width: 340px;
  animation: fadeSlideUp 280ms cubic-bezier(0.22, 1, 0.36, 1) both;
}
.chat-empty-intro .avatar.xl {
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.45), 0 0 0 4px rgba(255, 255, 255, 0.06);
  margin-bottom: 6px;
}
.chat-empty-intro h3 {
  margin: 0;
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ink);
}
.chat-empty-intro p {
  margin: 0;
  font-size: 13.5px;
  color: var(--muted);
  line-height: 1.45;
}
.chat-empty-actions {
  display: flex;
  gap: 10px;
  margin-top: 10px;
  flex-wrap: wrap;
  justify-content: center;
}
.chat-empty-actions .btn {
  border-radius: 99px;
  padding: 9px 18px;
}
@keyframes fadeSlideUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.chat-search-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--sidebar);
}
.chat-search-bar input { flex: 1; min-width: 0; height: 34px; padding: 0 11px; font-size: 13px; }
.search-count { font-size: 12px; font-weight: 600; color: var(--ink-soft); min-width: 34px; text-align: center; flex-shrink: 0; }
.search-mark {
  background: rgba(245, 158, 11, 0.34);
  color: #fff;
  border-radius: 4px;
  padding: 0 2px;
}
.search-mark.current {
  background: #F59E0B;
  color: #09090B;
  font-weight: 700;
  box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.45);
}

/* =========================
   DISCORD-STYLE FULL CALL STAGE
   ========================= */
.call-stage {
  flex: 1;
  min-height: 0;
  background: #0B0C0E;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

.call-stage:fullscreen,
.call-stage:-webkit-full-screen {
  width: 100vw !important;
  height: 100vh !important;
  background: #000 !important;
}
.call-stage:fullscreen .stage-body,
.call-stage:-webkit-full-screen .stage-body { padding: 0 !important; }
.call-stage:fullscreen .spotlight-box,
.call-stage:-webkit-full-screen .spotlight-box { border-radius: 0 !important; border: none !important; }
.call-stage.fill-mode .spotlight-viewport video,
.call-stage.fill-mode .peer-tile.screen-tile video { object-fit: cover !important; }
.call-stage:fullscreen .stage-hud-top,
.call-stage:fullscreen .call-dock,
.call-stage:-webkit-full-screen .stage-hud-top,
.call-stage:-webkit-full-screen .call-dock { transition: opacity 220ms ease; }
.call-stage:fullscreen.hud-idle .stage-hud-top,
.call-stage:fullscreen.hud-idle .call-dock,
.call-stage:-webkit-full-screen.hud-idle .stage-hud-top,
.call-stage:-webkit-full-screen.hud-idle .call-dock { opacity: 0; pointer-events: none; }

.stage-hud-top {
  position: absolute;
  top: 12px;
  left: 14px;
  right: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  z-index: 12;
  pointer-events: none;
}
.stage-pill, .stage-tools { pointer-events: auto; }
.stage-pill {
  height: 32px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: rgba(18, 19, 22, 0.84);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.11);
  padding: 0 12px;
  border-radius: 99px;
  font-size: 12px;
  font-weight: 600;
  color: #F2F3F5;
}
.telemetry-short { color: #5BE08E; font-weight: 700; }
.telemetry-detail { display: none; color: var(--muted); font-weight: 500; }
.stage-pill:hover .telemetry-detail:not(.hidden) { display: inline; }

.zoom-toast {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(18, 19, 22, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.16);
  padding: 4px 12px;
  border-radius: 99px;
  font-size: 12px;
  font-weight: 600;
  color: #fff;
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease;
}
.zoom-toast.show { opacity: 1; }

.stage-tools { display: inline-flex; align-items: center; gap: 6px; }
.preset-select {
  height: 32px;
  appearance: none;
  -webkit-appearance: none;
  background: rgba(18, 19, 22, 0.84);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.11);
  padding: 0 28px 0 12px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 99px;
  color: #F2F3F5;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='13' height='13' viewBox='0 0 24 24' fill='none' stroke='%23C9CDD4' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 13px;
  transition: background-color 120ms ease, border-color 120ms ease;
}
.preset-select:hover { background-color: var(--elevated-2); border-color: rgba(255, 255, 255, 0.2); }
.hud-icon-btn {
  width: 32px;
  height: 32px;
  border-radius: 99px;
  border: 1px solid rgba(255, 255, 255, 0.11);
  background: rgba(18, 19, 22, 0.84);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: #F2F3F5;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease, transform 70ms ease;
}
.hud-icon-btn:hover { background: var(--elevated-2); border-color: rgba(255, 255, 255, 0.2); }
.hud-icon-btn:active { transform: scale(0.94); }
.hud-icon-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.hud-icon-btn svg { width: 15px; height: 15px; }

.stage-body {
  flex: 1;
  min-height: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 12px 14px 80px;
  gap: 10px;
  position: relative;
}

.spotlight-box {
  position: relative;
  flex: 1;
  width: 100%;
  min-height: 0;
  background: #000;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.09);
  display: flex;
  align-items: center;
  justify-content: center;
}
.spotlight-viewport {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  touch-action: none;
  cursor: grab;
}
.spotlight-viewport.zoomed:active { cursor: grabbing; }
.spotlight-viewport video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  transform-origin: center center;
  will-change: transform;
  user-select: none;
  -webkit-user-drag: none;
}
.spotlight-viewport video.mirror { transform: scaleX(-1); }

.spotlight-avatar-wrap { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.spotlight-avatar-wrap strong { font-size: 16px; font-weight: 600; }

.unpin-pill {
  position: absolute;
  bottom: 12px;
  left: 12px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(18, 19, 22, 0.88);
  border: 1px solid var(--accent);
  color: #fff;
  padding: 5px 11px;
  border-radius: 99px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  z-index: 6;
}
.unpin-pill svg { width: 13px; height: 13px; color: var(--accent); }
.unpin-pill:hover { background: color-mix(in srgb, var(--accent) 30%, #121316); }

/* Proportional Full-Stage Participants Grid */
.participants-grid {
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  grid-auto-rows: minmax(0, 1fr);
  gap: 12px;
  align-content: stretch;
  justify-content: center;
  max-width: 1180px;
  padding-top: 40px;
}
.spotlight-box:not(.hidden) + .participants-grid {
  height: 122px;
  flex-shrink: 0;
  display: flex;
  flex-wrap: nowrap;
  overflow-x: auto;
  overflow-y: hidden;
  justify-content: safe center;
  align-items: center;
  gap: 10px;
  padding: 2px 8px;
  max-width: 100%;
}
.spotlight-box:not(.hidden) + .participants-grid .peer-tile {
  width: 200px;
  height: 112px;
  min-height: 0;
  flex-shrink: 0;
  border-radius: 13px;
  justify-content: center;
  padding-top: 0;
}
.spotlight-box:not(.hidden) + .participants-grid .avatar.lg { width: 46px; height: 46px; font-size: 17px; }
.spotlight-box:not(.hidden) + .participants-grid .tile-pin-btn {
  top: 7px;
  right: 7px;
  width: 26px;
  height: 26px;
}
.spotlight-box:not(.hidden) + .participants-grid .tile-pin-btn svg { width: 12px; height: 12px; }
.spotlight-box:not(.hidden) + .participants-grid .peer-tile-footer {
  left: 7px;
  bottom: 7px;
  max-width: calc(100% - 14px);
  padding: 3px 8px;
  border-radius: 7px;
  font-size: 11px;
}
.spotlight-box:not(.hidden) + .participants-grid .peer-tile-footer.has-vol {
  right: 7px;
}
.spotlight-box:not(.hidden) + .participants-grid .peer-vol { width: 52px; }

.peer-tile {
  position: relative;
  min-height: 200px;
  background: var(--sidebar);
  border: 2px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: border-color 120ms ease;
}
.peer-tile:hover { border-color: var(--border-hi); }
.peer-tile.speaking {
  border-color: var(--live);
  box-shadow: inset 0 0 0 1px var(--live), 0 0 24px rgba(35, 165, 90, 0.28);
}
.peer-tile.speaking .avatar {
  box-shadow: 0 0 0 4px rgba(35, 165, 90, 0.35), 0 0 0 9px rgba(35, 165, 90, 0.14);
}
.peer-tile.pinned { border-color: var(--accent); }
.peer-tile video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.peer-tile.screen-tile video { object-fit: contain; background: #000; }
.peer-tile video.mirror,
.floating-pip video.mirror,
#return-call-video.mirror { transform: scaleX(-1); }

.tile-pin-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 30px;
  height: 30px;
  border-radius: 99px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(18, 19, 22, 0.84);
  color: var(--ink-soft);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  transition: opacity 130ms ease, background 120ms ease;
  z-index: 4;
}
.peer-tile:hover .tile-pin-btn,
.tile-pin-btn.active { opacity: 1; }
.tile-pin-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.tile-pin-btn svg { width: 14px; height: 14px; }

.peer-tile-footer {
  position: absolute;
  left: 10px;
  bottom: 10px;
  max-width: calc(100% - 20px);
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: rgba(14, 15, 19, 0.78);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.09);
  padding: 5px 10px;
  border-radius: 9px;
  font-size: 12px;
  font-weight: 600;
  z-index: 4;
}
.peer-tile-footer.has-vol {
  right: 10px;
  display: flex;
}
.peer-tile-name {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.peer-tile-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.peer-tile-ic {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.peer-tile-ic svg { width: 13px; height: 13px; }
.peer-tile-ic.muted { color: #F79A9D; }
.peer-tile-ic.screen { color: #5BE08E; }
.peer-vol { width: 64px; accent-color: var(--accent); cursor: pointer; }

/* Discord-Style Call Control Bar */
.call-dock {
  position: absolute;
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 8px;
  border-radius: 99px;
  background: rgba(18, 19, 24, 0.88);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.56), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  z-index: 14;
}
.dock-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: none;
  background: #2B2D31;
  color: #F2F3F5;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease, transform 80ms ease;
}
.dock-btn:hover { background: #383A40; }
.dock-btn:active { transform: scale(0.94); }
.dock-btn svg { width: 19px; height: 19px; }
.dock-btn.active { background: #F2F3F5; color: #111214; }
.dock-btn.muted-off { background: rgba(218, 55, 60, 0.24); color: #F79A9D; }
.dock-btn.sharing { background: var(--live); color: #fff; }
.dock-btn.danger { background: var(--danger); color: #fff; width: 52px; border-radius: 99px; }
.dock-btn.danger:hover { filter: brightness(1.1); }

/* Compact Stop-Screen Confirmation Popover */
.dock-btn-wrap { position: relative; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.screen-stop-pop {
  position: absolute;
  bottom: calc(100% + 10px);
  left: 50%;
  transform: translateX(-50%);
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 5px 4px 11px;
  border-radius: 999px;
  background: var(--pop-bg);
  border: 1px solid var(--pop-border);
  box-shadow: var(--pop-shadow);
  backdrop-filter: blur(22px) saturate(150%);
  -webkit-backdrop-filter: blur(22px) saturate(150%);
  white-space: nowrap;
  z-index: 30;
  animation: popUpIn 140ms cubic-bezier(0.16, 1, 0.3, 1) both;
}
.screen-stop-pop::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: var(--pop-bg);
}
.screen-stop-pop span {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--ink);
  margin-right: 3px;
}
.stop-pop-btn {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 110ms ease, filter 110ms ease, background 110ms ease;
}
.stop-pop-btn svg { width: 12px; height: 12px; }
.stop-pop-btn.yes { background: var(--danger); color: #fff; }
.stop-pop-btn.yes:hover { filter: brightness(1.12); }
.stop-pop-btn.no { background: rgba(255, 255, 255, 0.1); color: #D4D6DE; }
.stop-pop-btn.no:hover { background: rgba(255, 255, 255, 0.18); color: #fff; }
.stop-pop-btn:active { transform: scale(0.92); }
@keyframes popUpIn {
  from { opacity: 0; transform: translate(-50%, 6px) scale(0.95); }
  to { opacity: 1; transform: translate(-50%, 0) scale(1); }
}

/* =========================
   CHAT FEED & COMPOSER
   ========================= */
.chat-body-wrap { flex: 1; min-height: 0; display: flex; flex-direction: column; }

.messages-wrap {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 16px 20px 8px;
  position: relative;
  display: flex;
  flex-direction: column;
}
.load-older {
  align-self: center;
  background: var(--elevated);
  border: 1px solid var(--border-hi);
  color: var(--ink-soft);
  border-radius: 99px;
  padding: 5px 14px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  margin-bottom: 12px;
}

.messages-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: auto;
}
.messages-list:has(.chat-empty-intro) {
  margin-top: 0;
  margin-bottom: auto;
}

.date-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 16px 0 8px;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
}
.date-divider::before, .date-divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }

/* Chat Call Log Pills */
.call-log-row {
  display: flex;
  justify-content: center;
  margin: 8px 0;
  animation: msgIn 180ms cubic-bezier(0.22, 1, 0.36, 1) both;
}
.call-log-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px 5px 7px;
  border-radius: 999px;
  background: var(--elevated);
  border: 1px solid var(--border-hi);
  color: var(--ink);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
  transition: background 140ms ease, border-color 140ms ease, transform 80ms ease;
}
.call-log-pill:hover { background: var(--elevated-2); border-color: rgba(255, 255, 255, 0.2); }
.call-log-pill:active { transform: scale(0.98); }
.call-log-ic {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.09);
  color: var(--ink-soft);
  flex-shrink: 0;
}
.call-log-ic svg { width: 12px; height: 12px; }
.call-log-pill.active .call-log-ic { background: rgba(35, 165, 90, 0.2); color: #3BD17B; }
.call-log-pill.missed .call-log-ic,
.call-log-pill.declined .call-log-ic { background: rgba(242, 63, 67, 0.18); color: #FF6B6E; }
.call-log-pill.missed .call-log-text,
.call-log-pill.declined .call-log-text { color: #F79A9D; }
.call-log-time { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }

.msg-row {
  display: flex;
  align-items: flex-end;
  gap: 9px;
  position: relative;
  max-width: 100%;
  animation: msgIn 180ms cubic-bezier(0.22, 1, 0.36, 1) both;
}
@keyframes msgIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
.msg-row.mine { flex-direction: row-reverse; }
.msg-row.grouped .msg-avatar-col { visibility: hidden; }
.msg-row.highlight .msg-bubble { box-shadow: 0 0 0 2px var(--accent); }

.msg-avatar-col { width: 32px; flex-shrink: 0; }
.msg-content-col { display: flex; flex-direction: column; align-items: flex-start; max-width: min(580px, 82%); min-width: 0; }
.msg-row.mine .msg-content-col { align-items: flex-end; }

.msg-meta { display: flex; align-items: baseline; gap: 7px; margin: 0 4px 3px; }
.msg-author { font-weight: 700; font-size: 12.5px; color: var(--ink); }
.msg-time { font-size: 10.5px; color: var(--muted); font-variant-numeric: tabular-nums; }

.msg-bubble {
  background: var(--elevated);
  border: 1px solid var(--border);
  border-radius: 14px 14px 14px 4px;
  padding: 7.5px 12px;
  max-width: 100%;
  transition: border-color 120ms ease;
}
.msg-bubble.media-only {
  padding: 5px;
}
.msg-bubble.media-only .file-card,
.msg-bubble.media-only .msg-image,
.msg-bubble.media-only .msg-video {
  margin-top: 0;
}
.msg-bubble.media-only .file-card {
  border-color: transparent;
  background: color-mix(in srgb, var(--rail) 70%, transparent);
}
.msg-row.mine .msg-bubble {
  background: color-mix(in srgb, var(--accent) 22%, var(--elevated));
  border-color: color-mix(in srgb, var(--accent) 42%, transparent);
  border-radius: 14px 14px 4px 14px;
}

.msg-reply-ref {
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 6px 10px 6px 12px;
  margin-bottom: 6px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  max-width: 340px;
  cursor: pointer;
  transition: background 120ms ease;
}
.msg-reply-ref::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--accent);
}
.msg-reply-ref:hover { background: rgba(255, 255, 255, 0.1); }
.msg-row.mine .msg-reply-ref {
  background: rgba(0, 0, 0, 0.22);
}
.msg-row.mine .msg-reply-ref::before {
  background: rgba(255, 255, 255, 0.86);
}
.reply-ref-name {
  font-size: 11.5px;
  font-weight: 700;
  color: color-mix(in srgb, var(--accent) 42%, #fff);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.msg-row.mine .reply-ref-name { color: #fff; }
.reply-ref-body {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: rgba(242, 243, 245, 0.78);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.reply-inline-ic { width: 13px; height: 13px; flex-shrink: 0; color: var(--accent); }
.msg-row.mine .reply-inline-ic { color: #fff; }

.msg-text { white-space: pre-wrap; word-break: break-word; font-size: var(--msg-font); line-height: 1.48; color: var(--ink); }
.msg-text.deleted { color: var(--muted); font-style: italic; }
.msg-text a { color: #94A3FF; text-decoration: underline; }
.msg-edited { font-size: 10.5px; color: var(--muted); }

.msg-image {
  display: block;
  margin-top: 4px;
  max-width: min(360px, 100%);
  max-height: 320px;
  border-radius: 10px;
  cursor: zoom-in;
}
.msg-video { display: block; margin-top: 4px; max-width: min(400px, 100%); max-height: 300px; border-radius: 10px; background: #000; }
.msg-audio { margin-top: 4px; width: min(270px, 100%); height: 36px; }

.file-card {
  margin-top: 4px;
  min-width: 230px;
  max-width: 340px;
  background: var(--rail);
  border: 1px solid var(--border-hi);
  border-radius: 10px;
  padding: 9px 11px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.file-card-top { display: flex; align-items: center; gap: 9px; }
.file-icon {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  background: color-mix(in srgb, var(--accent) 22%, transparent);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.file-icon.folder { background: rgba(35, 165, 90, 0.22); color: #5BE08E; }
.file-meta { flex: 1; min-width: 0; }
.file-name { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-sub { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.folder-details summary { font-size: 11.5px; color: var(--ink-soft); cursor: pointer; }
.folder-tree { margin: 4px 0 0; padding: 6px 8px; background: var(--sidebar); border-radius: 6px; max-height: 130px; overflow-y: auto; font-size: 11px; color: var(--ink-soft); list-style: none; }

/* Floating Message Action Toolbar */
.msg-actions {
  position: absolute;
  top: -15px;
  right: 8px;
  display: none;
  align-items: center;
  background: var(--pop-bg);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  border: 1px solid var(--pop-border);
  border-radius: 10px;
  padding: 2px;
  gap: 2px;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  z-index: 18;
}
.msg-row.mine .msg-actions { right: auto; left: 8px; }
.msg-row:hover .msg-actions,
.msg-row.actions-open .msg-actions { display: flex; animation: popQuick 130ms cubic-bezier(0.16, 1, 0.3, 1) both; }
@keyframes popQuick {
  from { opacity: 0; transform: translateY(3px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.msg-act-btn {
  width: 26px;
  height: 26px;
  border: none;
  background: transparent;
  color: var(--ink-soft);
  border-radius: 7px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  transition: background 110ms ease, color 110ms ease;
}
.msg-act-btn:hover { background: rgba(255, 255, 255, 0.1); color: #fff; }
.msg-act-btn.danger-act { color: #F79A9D; }
.msg-act-btn.danger-act:hover { background: var(--danger); color: #fff; }
.msg-act-btn svg { width: 13.5px; height: 13.5px; }

.msg-reactions { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.react-chip {
  border: 1px solid var(--border-hi);
  background: var(--elevated);
  color: var(--ink);
  border-radius: 99px;
  padding: 2px 8px;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: transform 100ms ease, background 120ms ease;
}
.react-chip:active { transform: scale(0.94); }
.react-chip.mine { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 22%, var(--elevated)); }

.drop-overlay {
  position: absolute;
  inset: 12px;
  background: rgba(18, 18, 20, 0.9);
  border: 2px dashed var(--accent);
  border-radius: 12px;
  display: grid;
  place-items: center;
  z-index: 20;
  pointer-events: none;
}

.typing-bar {
  min-height: 20px;
  padding: 0 20px;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 7px;
}
.typing-dots {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}
.typing-dots i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
  display: block;
  animation: typingWave 1.1s ease-in-out infinite;
}
.typing-dots i:nth-child(2) { animation-delay: 160ms; }
.typing-dots i:nth-child(3) { animation-delay: 320ms; }
@keyframes typingWave {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.45; }
  30% { transform: translateY(-3.5px); opacity: 1; }
}
.upload-bar {
  margin: 0 16px 8px;
  padding: 8px 12px;
  background: var(--elevated);
  border: 1px solid var(--border-hi);
  border-radius: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
}
.progress-track { flex: 1; height: 5px; background: var(--rail); border-radius: 99px; overflow: hidden; }
.progress-fill { height: 100%; width: 0%; background: var(--accent); transition: width 120ms ease; }

.context-bar {
  position: relative;
  overflow: hidden;
  margin: 0 16px 8px;
  padding: 8px 10px 8px 13px;
  background: color-mix(in srgb, var(--elevated) 92%, var(--accent) 8%);
  border: 1px solid var(--border-hi);
  border-radius: 11px;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.24);
  animation: fadeSlideUp 150ms cubic-bezier(0.22, 1, 0.36, 1) both;
}
.context-bar::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--accent);
}
.context-bar-ic {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: color-mix(in srgb, var(--accent) 22%, transparent);
  color: color-mix(in srgb, var(--accent) 35%, #fff);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.context-bar-ic svg { width: 15px; height: 15px; }
.context-bar-text { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.context-bar-text strong {
  font-size: 12.5px;
  font-weight: 700;
  color: color-mix(in srgb, var(--accent) 35%, #fff);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.context-bar-text span {
  font-size: 13px;
  color: #E4E6EE;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.context-bar-close {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.08);
  color: var(--ink-soft);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease;
}
.context-bar-close:hover { background: rgba(255, 255, 255, 0.16); color: #fff; }
.context-bar-close svg { width: 15px; height: 15px; }

/* Draggable Floating In-App PiP Mini-Player */
.floating-pip {
  position: fixed;
  right: 14px;
  bottom: 108px;
  width: 204px;
  aspect-ratio: 16 / 10;
  z-index: 195;
  border-radius: 14px;
  overflow: hidden;
  background: #000;
  border: 1px solid var(--pop-border);
  box-shadow: var(--pop-shadow);
  touch-action: none;
  cursor: grab;
  transition: left 200ms cubic-bezier(0.16, 1, 0.3, 1), top 200ms cubic-bezier(0.16, 1, 0.3, 1);
}
.floating-pip.dragging { transition: none; cursor: grabbing; }
.floating-pip video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.fpip-controls {
  position: absolute;
  top: 6px;
  right: 6px;
  display: flex;
  gap: 4px;
  z-index: 2;
}
.fpip-btn {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(14, 15, 19, 0.78);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 110ms ease, transform 80ms ease;
}
.fpip-btn:hover { background: rgba(28, 30, 38, 0.92); }
.fpip-btn svg { width: 12px; height: 12px; }
.fpip-btn:active { transform: scale(0.92); }

/* Symmetrical Discord-Grade Composer (Baseline-locked to Left User Dock!) */
.composer-dock { padding: 4px 16px 12px; flex-shrink: 0; }
.composer {
  display: flex;
  align-items: center;
  min-height: 46px;
  gap: 4px;
  padding: 5px 6px;
  background: var(--elevated);
  border: 1px solid var(--border-hi);
  border-radius: 11px;
  transition: border-color 140ms ease, box-shadow 140ms ease;
}
.composer:focus-within {
  border-color: color-mix(in srgb, var(--accent) 72%, var(--border-hi));
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 16%, transparent);
}
.composer textarea {
  flex: 1;
  resize: none;
  min-height: 34px;
  max-height: 128px;
  height: 34px;
  line-height: 22px;
  padding: 6px 8px;
  background: transparent;
  border: none;
  font-size: 14px;
}
.composer textarea:focus { background: transparent; border: none; }
.btn-send {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: none;
  background: var(--accent);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.16);
  transition: filter 110ms ease, transform 70ms ease;
}
.btn-send:hover { filter: brightness(1.08); }
.btn-send:active { transform: scale(0.94); }
.btn-send svg { width: 15px; height: 15px; }

/* =========================
   DISCORD-STYLE RIGHT SIDEBAR
   ========================= */
.right-sidebar {
  width: 276px;
  flex-shrink: 0;
  background: var(--sidebar);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.right-sidebar-head {
  height: 50px;
  padding: 0 10px 0 16px;
  background: var(--sidebar);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.right-sidebar-title { font-size: 13.5px; font-weight: 700; letter-spacing: -0.015em; }
.right-sidebar-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.right-sidebar-foot {
  padding: 10px 14px 12px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.group-avatar-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 16px 12px 14px;
  background: var(--elevated);
  border: 1px solid var(--border-hi);
  border-radius: 13px;
  text-align: center;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

/* Discord-Style DM Profile Card with Banner */
.dm-profile {
  border-radius: 13px;
  overflow: hidden;
  background: var(--elevated);
  border: 1px solid var(--border-hi);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}
.dm-profile-banner {
  height: 62px;
  background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 45%, #121214));
}
.dm-profile-card {
  padding: 0 14px 14px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
}
.dm-profile-card .avatar.xl {
  margin-top: -38px;
  border: 5px solid var(--elevated);
}
.dm-profile-name { font-size: 16.5px; font-weight: 700; margin-top: 5px; letter-spacing: -0.015em; }
.status-chip {
  margin-top: 7px;
  font-size: 11.5px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 99px;
  background: var(--rail);
  border: 1px solid var(--border);
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.status-chip::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--muted);
  flex-shrink: 0;
}
.status-chip.online {
  background: rgba(35, 165, 90, 0.16);
  border-color: rgba(35, 165, 90, 0.34);
  color: #5BE08E;
}
.status-chip.online::before {
  background: var(--live);
  box-shadow: 0 0 0 2px rgba(35, 165, 90, 0.25);
}
#group-member-count::before { display: none; }

.close-drawer-btn {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: transparent;
  color: var(--ink-soft);
}
.close-drawer-btn svg { width: 16px; height: 16px; }
.close-drawer-btn:hover { background: var(--elevated-2); color: #fff; }

.profile-bio-card {
  margin: 0 14px 14px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--rail);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.profile-bio-text {
  margin: 0;
  font-size: 13px;
  line-height: 1.48;
  color: var(--ink);
  word-break: break-word;
}

/* Group Info Sections */
.group-sections { display: flex; flex-direction: column; gap: 14px; }
.rs-block { display: flex; flex-direction: column; gap: 7px; }
.rs-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.invite-copy-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: var(--rail);
  padding: 5px 5px 5px 11px;
  border-radius: 9px;
  border: 1px solid var(--border-hi);
  font-size: 12.5px;
  font-weight: 600;
}
#info-invite-code {
  font-family: ui-monospace, 'Cascadia Mono', 'SFMono-Regular', monospace;
  letter-spacing: 0.08em;
  font-size: 12px;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
}
.members-list { display: flex; flex-direction: column; gap: 4px; }
.member-row { display: flex; align-items: center; gap: 10px; padding: 7px 9px; border-radius: 10px; background: var(--rail); border: 1px solid transparent; transition: background 110ms ease, border-color 110ms ease; }
.member-row:hover { background: var(--elevated); border-color: var(--border); }
.member-meta { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 1px; }
.member-name { font-size: 13px; font-weight: 600; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.member-sub { font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.inline-row { display: flex; align-items: center; gap: 6px; }
.inline-row input { flex: 1; min-width: 0; height: 36px; padding: 0 11px; font-size: 13px; border-radius: 9px; }
.inline-row .btn { height: 36px; border-radius: 9px; }

/* =========================
   CLASSIC WAVEFORM VOICE PLAYER + LIVE RECORDING BAR
   ========================= */
.voice-player {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 224px;
  max-width: 280px;
  padding: 4px 2px;
}
.voice-player audio { display: none; }
.vp-play {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  cursor: pointer;
  transition: transform 120ms ease, filter 120ms ease;
}
.vp-play:hover { filter: brightness(1.1); }
.vp-play:active { transform: scale(0.92); }
.vp-play svg { width: 17px; height: 17px; }
.msg-row.mine .vp-play { background: rgba(255, 255, 255, 0.24); color: #fff; }
.vp-mid { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 5px; }
.vp-bars {
  display: flex;
  align-items: center;
  gap: 2.5px;
  height: 28px;
  cursor: pointer;
}
.vp-bar {
  flex: 1;
  min-width: 2.5px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.24);
  transition: background 120ms ease, height 220ms ease;
}
.vp-bar.played { background: var(--accent); }
.msg-row.mine .vp-bar { background: rgba(255, 255, 255, 0.34); }
.msg-row.mine .vp-bar.played { background: #fff; }
.vp-meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.vp-time { font-size: 11px; color: var(--muted); }
.msg-row.mine .vp-time { color: rgba(255, 255, 255, 0.8); }
.vp-speed {
  border: none;
  border-radius: 99px;
  padding: 2px 7px;
  font-size: 10.5px;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.1);
  color: var(--ink-soft);
  cursor: pointer;
}
.msg-row.mine .vp-speed { background: rgba(255, 255, 255, 0.2); color: #fff; }

.rec-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  background: var(--elevated);
  border: 1px solid rgba(242, 63, 67, 0.4);
  border-radius: 22px;
}
.rec-cancel-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.08);
  color: var(--ink-soft);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  cursor: pointer;
}
.rec-cancel-btn svg { width: 16px; height: 16px; }
.rec-live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--danger);
  flex-shrink: 0;
  animation: pulseDot 1s infinite ease-in-out;
}
@keyframes pulseDot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.8); }
}
.rec-timer { font-size: 13px; font-weight: 700; color: #fff; min-width: 36px; }
.rec-wave {
  flex: 1;
  height: 26px;
  display: flex;
  align-items: center;
  gap: 2.5px;
  overflow: hidden;
}
.rec-wave-bar {
  flex: 1;
  min-width: 2.5px;
  border-radius: 99px;
  background: var(--danger);
  transition: height 90ms linear;
}

/* =========================
   UNIFIED COMPACT OBSIDIAN POPUPS, MODALS, CONTEXT SHEETS & OVERLAYS
   ========================= */
.app-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 230;
  background: rgba(5, 6, 9, 0.62);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 120ms ease both;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.app-modal-card {
  width: min(308px, calc(100vw - 32px));
  background: var(--pop-bg);
  backdrop-filter: blur(24px) saturate(150%);
  -webkit-backdrop-filter: blur(24px) saturate(150%);
  border: 1px solid var(--pop-border);
  border-radius: 15px;
  padding: 18px 18px 16px;
  box-shadow: var(--pop-shadow);
  display: flex;
  flex-direction: column;
  gap: 6px;
  animation: sheetPop 150ms cubic-bezier(0.16, 1, 0.3, 1) both;
}
@keyframes sheetPop {
  from { opacity: 0; transform: translateY(6px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.app-modal-title {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #fff;
  line-height: 1.3;
}
.app-modal-body {
  margin: 0;
  font-size: 12.8px;
  line-height: 1.48;
  color: var(--muted);
}
.app-modal-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 12px;
}
.app-modal-actions .btn {
  height: 36px;
  border-radius: 9px;
  font-size: 13px;
  font-weight: 600;
}
.app-modal-actions .btn-ghost {
  background: rgba(255, 255, 255, 0.055);
  border-color: rgba(255, 255, 255, 0.09);
  color: var(--ink-soft);
}
.app-modal-actions .btn-ghost:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}
.app-modal-actions .btn-danger {
  background: rgba(218, 55, 60, 0.88);
  border-color: rgba(255, 255, 255, 0.1);
  color: #fff;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18);
}
.app-modal-actions .btn-danger:hover {
  background: var(--danger);
  filter: brightness(1.06);
}

.msg-bubble.pressing { transform: scale(0.975); transition: transform 130ms ease; }
.msg-bubble,
.msg-ctx-backdrop,
.msg-ctx-backdrop * {
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}
.msg-ctx-backdrop {
  position: fixed;
  inset: 0;
  z-index: 220;
  background: rgba(5, 6, 9, 0.54);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: block;
  animation: fadeIn 120ms ease both;
}
.msg-ctx-stack {
  position: fixed;
  max-width: min(340px, calc(100vw - 24px));
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  animation: sheetPop 140ms cubic-bezier(0.16, 1, 0.3, 1) both;
}
.msg-ctx-stack.align-right { align-items: flex-end; }
.msg-ctx-reacts {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 4px 6px;
  border-radius: 999px;
  background: var(--pop-bg);
  backdrop-filter: blur(24px) saturate(150%);
  -webkit-backdrop-filter: blur(24px) saturate(150%);
  border: 1px solid var(--pop-border);
  box-shadow: var(--pop-shadow);
}
.ctx-react-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid transparent;
  background: transparent;
  font-size: 19px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 120ms cubic-bezier(0.16, 1, 0.3, 1), background 110ms ease;
}
.ctx-react-btn:hover { background: rgba(255, 255, 255, 0.09); transform: scale(1.16); }
.ctx-react-btn:active { transform: scale(0.94); }
.ctx-react-btn.active { background: color-mix(in srgb, var(--accent) 24%, transparent); border-color: color-mix(in srgb, var(--accent) 70%, transparent); }
.msg-ctx-bubble {
  max-width: 88%;
  padding: 8px 12px;
  border-radius: 13px 13px 13px 4px;
  background: var(--elevated);
  border: 1px solid var(--pop-border);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.48), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  display: inline-flex;
  align-items: flex-end;
  gap: 9px;
}
.msg-ctx-bubble.mine {
  border-radius: 13px 13px 4px 13px;
  background: color-mix(in srgb, var(--accent) 28%, var(--elevated));
  border-color: color-mix(in srgb, var(--accent) 48%, transparent);
}
.msg-ctx-text { font-size: 13.5px; line-height: 1.44; color: #fff; word-break: break-word; }
.msg-ctx-time { font-size: 10.5px; color: rgba(255, 255, 255, 0.58); flex-shrink: 0; }
.msg-ctx-menu {
  width: 178px;
  padding: 4px;
  border-radius: 13px;
  background: var(--pop-bg);
  backdrop-filter: blur(24px) saturate(150%);
  -webkit-backdrop-filter: blur(24px) saturate(150%);
  border: 1px solid var(--pop-border);
  box-shadow: var(--pop-shadow);
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.ctx-menu-sep {
  height: 1px;
  background: var(--border);
  margin: 3px 6px;
}
.ctx-menu-row {
  width: 100%;
  height: 34px;
  padding: 0 10px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  font-size: 13px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 9px;
  cursor: pointer;
  transition: background 100ms ease, color 100ms ease;
}
.ctx-menu-row:hover { background: rgba(255, 255, 255, 0.08); color: #fff; }
.ctx-menu-row:active { transform: scale(0.985); }
.ctx-menu-row svg { width: 15px; height: 15px; flex-shrink: 0; color: var(--muted); transition: color 100ms ease; }
.ctx-menu-row:hover svg { color: var(--ink); }
.ctx-menu-row.danger { color: #F79A9D; }
.ctx-menu-row.danger svg { color: #F79A9D; }
.ctx-menu-row.danger:hover { background: rgba(218, 55, 60, 0.16); color: #FFB3B5; }
.ctx-menu-row.danger:hover svg { color: #FFB3B5; }

.msg-row.editing-target .msg-bubble {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.context-bar.editing-bar::before {
  background: var(--live);
}
.btn-send.editing-save {
  background: var(--live);
}

/* =========================
   PREMIUM INCOMING CALL OVERLAY (Unified Obsidian Glass Card + FaceTime Mobile)
   ========================= */
.incoming-call-backdrop {
  position: fixed;
  inset: 0;
  z-index: 180;
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  padding: 20px;
  pointer-events: none;
}
.incoming-call-card {
  position: relative;
  overflow: hidden;
  pointer-events: auto;
  width: min(312px, calc(100vw - 32px));
  background: var(--pop-bg);
  backdrop-filter: blur(24px) saturate(150%);
  -webkit-backdrop-filter: blur(24px) saturate(150%);
  border: 1px solid var(--pop-border);
  border-radius: 16px;
  padding: 15px;
  display: flex;
  flex-direction: column;
  gap: 13px;
  box-shadow: var(--pop-shadow), 0 0 0 1px rgba(35, 165, 90, 0.24);
  animation: callCardUp 260ms cubic-bezier(0.16, 1, 0.3, 1) both;
}
@keyframes callCardUp {
  from { opacity: 0; transform: translateY(16px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.incoming-glow {
  position: absolute;
  inset: -45% auto auto -18%;
  width: 220px;
  height: 220px;
  border-radius: 50%;
  background: radial-gradient(circle, color-mix(in srgb, var(--caller-color, #23A55A) 28%, transparent), transparent 68%);
  pointer-events: none;
  z-index: 0;
}
.incoming-info {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.incoming-avatar-ring {
  position: relative;
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.incoming-avatar-ring .avatar.lg {
  width: 44px;
  height: 44px;
  font-size: 16px;
  position: relative;
  z-index: 2;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);
}
.sonar-ring {
  position: absolute;
  inset: 2px;
  border-radius: 50%;
  border: 1.5px solid rgba(76, 224, 136, 0.65);
  animation: sonarPulse 2s cubic-bezier(0.22, 1, 0.36, 1) infinite;
  z-index: 1;
}
.sonar-ring.r2 { animation-delay: 850ms; }
@keyframes sonarPulse {
  0% { transform: scale(1); opacity: 0.85; }
  100% { transform: scale(1.58); opacity: 0; }
}
.incoming-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.incoming-kicker {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 700;
  color: #5BE08E;
  letter-spacing: 0.01em;
}
.incoming-text strong {
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.incoming-actions {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  width: 100%;
}
.inc-btn {
  border: 1px solid transparent;
  border-radius: 9px;
  height: 36px;
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  cursor: pointer;
  padding: 0 12px;
  font-size: 13px;
  font-weight: 600;
  transition: transform 90ms ease, filter 110ms ease, background 110ms ease;
}
.inc-btn:hover { filter: brightness(1.08); }
.inc-btn:active { transform: scale(0.97); }
.inc-btn-ic {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.inc-btn-ic svg { width: 15px; height: 15px; }
.inc-decline { background: rgba(218, 55, 60, 0.16); border-color: rgba(218, 55, 60, 0.36); color: #F79A9D; }
.inc-decline:hover { background: var(--danger); border-color: var(--danger); color: #fff; }
.inc-accept {
  background: var(--live);
  color: #fff;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 6px 18px rgba(35, 165, 90, 0.36);
}

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 250;
  background: rgba(7, 8, 11, 0.88);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 20px;
  animation: fadeIn 140ms ease both;
}
.lightbox img { max-width: 94vw; max-height: 82vh; border-radius: 12px; object-fit: contain; box-shadow: 0 24px 64px rgba(0, 0, 0, 0.7); }
.lightbox-close {
  position: fixed;
  top: calc(14px + var(--titlebar-h) + env(safe-area-inset-top, 0px));
  right: 16px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--pop-border);
  background: var(--pop-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 110ms ease, transform 80ms ease;
}
.lightbox-close:hover { background: var(--elevated-2); color: #fff; }
.lightbox-close:active { transform: scale(0.94); }
.lightbox-close svg { width: 16px; height: 16px; }

.toast-stack {
  position: fixed;
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  right: 16px;
  z-index: 260;
  display: flex;
  flex-direction: column;
  gap: 6px;
  pointer-events: none;
}
.toast {
  background: var(--pop-bg);
  backdrop-filter: blur(20px) saturate(140%);
  -webkit-backdrop-filter: blur(20px) saturate(140%);
  border: 1px solid var(--pop-border);
  color: var(--ink);
  padding: 8px 14px;
  border-radius: 10px;
  font-size: 12.5px;
  font-weight: 600;
  box-shadow: var(--pop-shadow);
  animation: toastIn 180ms cubic-bezier(0.16, 1, 0.3, 1) both;
}
@keyframes toastIn {
  from { opacity: 0; transform: translateY(10px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.mobile-only { display: none; }

/* =========================
   NATIVE-GRADE MOBILE RESPONSIVE (iPhone / Android PWA)
   ========================= */
@media (max-width: 768px) {
  .desktop-titlebar { display: none !important; }
  html.is-desktop { --titlebar-h: 0px; }
  html, body {
    background: var(--pane);
    font-size: 15px;
    --msg-font: 15px;
  }
  .mobile-only { display: inline-flex; }

  /* Prevent iOS Safari/PWA input zoom & viewport shift */
  input[type="text"], input[type="password"], input[type="search"], input[type="url"], textarea, select,
  .composer textarea, .sidebar-search input, .chat-search-bar input, .setting-select, .setting-input, .inline-row input {
    font-size: 16px;
  }

  /* Full-Presence Mobile Auth Screen */
  .auth-card {
    max-width: 100%;
    padding: 32px 22px 26px;
    border-radius: 22px;
    gap: 20px;
  }
  .auth-brand img { width: 76px; height: 76px; border-radius: 18px; }
  .auth-brand h1 { font-size: 26px; font-weight: 800; }
  .segmented { padding: 4px; border-radius: 12px; }
  .seg-btn { padding: 10px 12px; font-size: 14.5px; border-radius: 9px; }
  .auth-form { gap: 12px; }
  .auth-form input { height: 48px; padding: 0 14px; border-radius: 12px; }
  .auth-form .btn-primary { height: 48px; font-size: 15.5px; border-radius: 12px; }

  /* App Shell & Persistent Bottom Tab Navigation */
  .app-shell {
    background: var(--pane);
    flex-direction: column;
  }
  .sidebar, .main-pane {
    width: 100%;
    flex: 1;
    min-height: 0;
    height: auto;
    border: none;
    border-radius: 0;
    background: var(--pane);
  }
  .main-pane { display: none; }
  .app-shell.mobile-chat-open .sidebar,
  .app-shell.mobile-settings-open .sidebar { display: none; }
  .app-shell.mobile-chat-open .main-pane,
  .app-shell.mobile-settings-open .main-pane {
    display: flex;
    animation: mobilePaneIn 200ms cubic-bezier(0.22, 1, 0.36, 1) both;
  }
  /* Hide redundant Settings back button on mobile — bottom tab bar switches directly */
  .app-shell.mobile-settings-open #btn-close-settings { display: none; }
  /* Hide bottom tab bar ONLY when deep inside an active chat conversation */
  .app-shell.mobile-chat-open:not(.mobile-settings-open) #mobile-bottom-nav { display: none; }
  @keyframes mobilePaneIn {
    from { opacity: 0.72; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
  }

  /* Comfortable Native Mobile Headers (62px + safe-area; standalone adds clearance below iOS 26 OS blur band) */
  .sidebar-header, .pane-header {
    height: calc(62px + env(safe-area-inset-top, 0px));
    padding: env(safe-area-inset-top, 0px) 14px 0 16px;
    background: var(--pane);
    border-bottom: 1px solid var(--border);
  }
  .sidebar-brand { gap: 11px; }
  .sidebar-brand img { width: 32px; height: 32px; border-radius: 9px; }
  .brand-title { font-size: 21px; font-weight: 800; letter-spacing: -0.03em; }
  .status-pill-dot { width: 8px; height: 8px; }

  .icon-btn { width: 42px; height: 42px; border-radius: 12px; }
  .icon-btn svg { width: 21px; height: 21px; }
  .icon-btn.sm { width: 38px; height: 38px; border-radius: 10px; }
  .icon-btn.sm svg { width: 19px; height: 19px; }
  /* Hide duplicate + button on mobile since Quick Actions strip already provides DM/Group/Code */
  #btn-new-chat { display: none; }

  /* Spacious Mobile Search Bar */
  .sidebar-search { padding: 12px 16px 10px; }
  .sidebar-search .search-ic { left: 30px; width: 18px; height: 18px; transform: translateY(-48%); }
  .sidebar-search input {
    height: 44px;
    padding: 0 14px 0 42px;
    border-radius: 13px;
    background: var(--elevated);
    border-color: var(--border);
  }

  /* Mobile Quick Action Strip (3 Tactile Tiles) */
  .mobile-quick-actions {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 9px;
    padding: 2px 16px 10px;
    flex-shrink: 0;
  }
  .mqa-btn {
    background: var(--elevated);
    border: 1px solid var(--border);
    border-radius: 13px;
    padding: 10px 6px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    color: var(--ink);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: background 120ms ease, transform 90ms ease, border-color 120ms ease;
  }
  .mqa-btn:active { transform: scale(0.96); background: var(--elevated-2); border-color: var(--border-hi); }
  .mqa-ic {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    background: color-mix(in srgb, var(--accent) 20%, transparent);
    color: color-mix(in srgb, var(--accent) 72%, #fff);
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
  .mqa-ic svg { width: 17px; height: 17px; }

  /* Mobile Section Header */
  .mobile-section-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 18px 8px;
    font-size: 13px;
    font-weight: 700;
    color: var(--muted);
    letter-spacing: 0.01em;
    flex-shrink: 0;
  }
  .mobile-count-pill {
    background: var(--elevated);
    color: var(--ink-soft);
    border: 1px solid var(--border);
    padding: 2px 9px;
    border-radius: 99px;
    font-size: 12px;
    font-weight: 700;
  }

  /* Generous Native Room Rows */
  .room-list { padding: 4px 12px 14px; gap: 6px; }
  .room-item {
    padding: 12px 12px;
    gap: 14px;
    border-radius: 15px;
    background: color-mix(in srgb, var(--elevated) 55%, transparent);
    border: 1px solid rgba(255, 255, 255, 0.04);
  }
  .room-item:active { transform: scale(0.985); background: var(--elevated-2); }
  .room-item .avatar.md { width: 52px; height: 52px; font-size: 18px; }
  .room-item .avatar .online-dot { width: 13px; height: 13px; border-width: 2.5px; border-color: var(--pane); }
  .room-item-name { font-size: 16px; font-weight: 700; }
  .room-item-time { font-size: 12px; }
  .room-item-bottom { margin-top: 4px; }
  .room-item-preview { font-size: 14px; color: var(--ink-soft); opacity: 0.8; }
  .unread-badge { min-width: 22px; height: 22px; font-size: 12px; padding: 0 7px; }
  .call-pill { font-size: 12px; padding: 3px 10px; }

  .room-empty-card {
    margin: 12px 4px;
    padding: 28px 20px;
    border-radius: 18px;
    gap: 10px;
  }
  .room-empty-ic img { width: 64px; height: 64px; border-radius: 16px; }
  .room-empty-card strong { font-size: 18px; }
  .room-empty-card p { font-size: 14px; max-width: 280px; }
  .room-empty-btns .btn { height: 46px; font-size: 15px; border-radius: 12px; }

  /* Integrated Persistent Mobile Bottom Tab Bar (stays visible across Söhbətlər & Ayarlar) */
  .sidebar-footer { display: none; }
  .mobile-bottom-nav {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0;
    flex-shrink: 0;
    background: color-mix(in srgb, var(--sidebar) 96%, #000);
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    padding: 4px 12px max(22px, calc(10px + env(safe-area-inset-bottom, 0px)));
  }
  .mnav-item {
    position: relative;
    border: none;
    background: transparent;
    color: rgba(201, 205, 212, 0.65);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 8px 10px 6px;
    min-height: 52px;
    border-radius: 12px;
    font-size: 11.5px;
    font-weight: 600;
    cursor: pointer;
    transition: color 140ms ease, transform 90ms ease;
  }
  .mnav-item::before {
    content: '';
    position: absolute;
    top: -4px;
    width: 30px;
    height: 3px;
    border-radius: 99px;
    background: var(--accent);
    opacity: 0;
    transform: scaleX(0.4);
    transition: opacity 160ms ease, transform 180ms cubic-bezier(0.22, 1, 0.36, 1);
  }
  .mnav-item:active { transform: scale(0.95); }
  .mnav-item svg { width: 22px; height: 22px; }
  .mnav-item.active {
    color: #fff;
  }
  .mnav-item.active::before {
    opacity: 1;
    transform: scaleX(1);
  }
  .mnav-item.active svg { color: color-mix(in srgb, var(--accent) 82%, #fff); }
  .mnav-item .avatar.xs { width: 24px; height: 24px; font-size: 10px; box-shadow: 0 0 0 1.5px rgba(255, 255, 255, 0.16); }
  .mnav-item.active .avatar.xs { box-shadow: 0 0 0 2px var(--accent); }

  /* Mobile New Chat Panel */
  .new-panel-body { padding: 16px; gap: 16px; }
  .inline-form { gap: 12px; }
  .inline-form input { height: 48px; padding: 0 14px; border-radius: 12px; }
  .inline-form .btn { height: 48px; font-size: 15.5px; border-radius: 12px; }
  .suggestion-item { padding: 11px 12px; gap: 12px; border-radius: 12px; font-size: 15px; }
  .suggestion-item .avatar.sm { width: 40px; height: 40px; font-size: 14px; }

  /* Mobile Chat Header & Actions */
  .pane-head-left { gap: 10px; }
  .pane-head-left .avatar.md { width: 40px; height: 40px; font-size: 15px; }
  .pane-head-left h2 { font-size: 17px; font-weight: 700; }
  #chat-subtitle { font-size: 12.5px; }
  .chat-header-actions { gap: 6px; }
  .header-sep { display: none; }
  #btn-call-voice, #btn-call-video {
    background: var(--elevated);
    border: 1px solid var(--border);
    color: #fff;
    border-radius: 50%;
    width: 40px;
    height: 40px;
  }
  #btn-toggle-search { width: 40px; height: 40px; border-radius: 50%; }

  /* Mobile Ongoing / Active Call Live Preview Banner (compact & rich) */
  .return-call-bar, .join-call-banner {
    margin: 8px 12px 2px;
    padding: 9px 11px;
    border-radius: 15px;
    gap: 10px;
  }
  .call-preview-thumb video { width: 52px; height: 34px; }
  .call-bar-title { font-size: 13px; }
  .call-bar-sub { font-size: 12px; }
  .join-call-banner .btn-live,
  .return-call-bar .btn-live {
    padding: 8px 14px;
    font-size: 13px;
  }

  /* Mobile Messages (Larger, Tactile, Readable) */
  .messages-wrap { padding: 26px 12px 8px; }
  .messages-list { gap: 5px; }
  .date-divider { font-size: 12px; margin: 18px 0 10px; }
  .msg-avatar-col { width: 34px; }
  .msg-avatar-col .avatar.sm { width: 34px; height: 34px; font-size: 13px; }
  .msg-content-col { max-width: 86%; }
  .msg-author { font-size: 13.5px; }
  .msg-time { font-size: 11.5px; }
  .msg-bubble { padding: 9px 14px; border-radius: 18px 18px 18px 5px; }
  .msg-row.mine .msg-bubble { border-radius: 18px 18px 5px 18px; }
  .msg-text { font-size: var(--msg-font); line-height: 1.48; }
  .msg-reply-ref { font-size: 12.5px; padding: 4px 10px; margin-bottom: 6px; }
  .msg-actions { top: -22px; padding: 4px; border-radius: 12px; gap: 2px; }
  .msg-act-btn { width: 36px; height: 36px; font-size: 16px; border-radius: 9px; }
  .msg-act-btn svg { width: 17px; height: 17px; }
  .react-chip { padding: 4px 10px; font-size: 13px; }
  .file-card { min-width: 240px; padding: 11px 13px; border-radius: 13px; }
  .file-name { font-size: 14px; }
  .file-sub { font-size: 12px; }
  .typing-bar { min-height: 24px; padding: 0 16px; font-size: 13px; }

  .chat-empty-intro .avatar.xl { width: 84px; height: 84px; font-size: 30px; }
  .chat-empty-intro h3 { font-size: 21px; }
  .chat-empty-intro p { font-size: 14.5px; }
  .chat-empty-actions .btn { height: 44px; padding: 0 20px; font-size: 14.5px; }

  /* Mobile Thumb-Zone Composer (elevated cleanly above iPhone Home Indicator, tightens when keyboard opens) */
  #btn-attach-folder { display: none; }
  .composer-dock {
    padding: 8px 12px max(28px, calc(14px + env(safe-area-inset-bottom, 0px)));
    background: var(--pane);
  }
  html.kbd-open .composer-dock {
    padding: 6px 12px 10px;
  }
  .composer {
    padding: 6px 7px;
    border-radius: 24px;
    gap: 5px;
    background: var(--elevated);
  }
  .composer textarea {
    min-height: 40px;
    height: 40px;
    line-height: 24px;
    padding: 8px 8px;
  }
  .composer .icon-btn { width: 40px; height: 40px; border-radius: 50%; }
  .btn-send { width: 40px; height: 40px; border-radius: 50%; }
  .btn-send svg { width: 18px; height: 18px; }

  /* Mobile Settings (Zero Overflow, Apple-Clean Controls, High Contrast) */
  .settings-layout {
    flex-direction: column;
    flex-wrap: nowrap;
    padding: 14px 14px 24px;
    gap: 14px;
  }
  .settings-profile-card {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    padding: 15px;
    border-radius: 16px;
  }
  .settings-profile-actions {
    width: 100%;
    display: flex;
    gap: 8px;
  }
  .settings-profile-card .btn {
    flex: 1;
    height: 40px;
    border-radius: 11px;
    font-size: 13.5px;
  }
  .settings-profile-card .status-edit-row input {
    height: 40px;
    border-radius: 11px;
  }
  .settings-profile-card .status-edit-row .btn {
    flex: none;
    height: 40px;
    padding: 0 14px;
  }
  .settings-nav {
    width: 100%;
    flex-direction: row;
    background: var(--rail);
    padding: 4px;
    border-radius: 13px;
    border: 1px solid var(--border-hi);
    gap: 4px;
  }
  .snav-btn {
    flex: 1;
    text-align: center;
    padding: 10px 8px;
    font-size: 14px;
    border-radius: 9px;
  }
  .settings-card { padding: 16px 14px; border-radius: 16px; gap: 14px; }
  .settings-card.account-card { padding: 0; gap: 0; }
  .card-section-title { font-size: 11.5px; }
  .theme-card { padding: 9px 8px; border-radius: 12px; font-size: 13px; gap: 8px; }
  .theme-preview { height: 52px; border-radius: 8px; }
  .accent-swatches { gap: 12px; }
  .accent-dot { width: 36px; height: 36px; }
  .setting-row {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }
  .setting-label { width: auto; font-size: 13.5px; }
  #btn-mic-test { width: 100%; height: 40px; }
  .mic-meter-track { flex: none; width: 100%; height: 8px; }
  .setting-select, .setting-input {
    flex: none;
    width: 100%;
    max-width: 100%;
    height: 44px;
    padding: 0 36px 0 12px;
    border-radius: 11px;
    font-size: 15px;
  }
  .setting-input { padding: 0 12px; }
  .account-row { flex-direction: column; align-items: stretch; gap: 10px; padding: 14px; }
  .account-row .btn { width: 100%; height: 42px; }
  .settings-save-row .btn { width: 100%; height: 44px; }
  .toggle-item { font-size: 14.5px; min-height: 36px; }
  .switch { width: 48px; height: 28px; }
  .slider::before { width: 22px; height: 22px; left: 2px; top: 2px; }
  .switch input:checked + .slider::before { transform: translateX(20px); }

  /* Mobile Profile / Group Info Full-Width Native Sheet */
  .right-sidebar {
    position: fixed;
    top: var(--app-top, 0px);
    right: 0;
    left: 0;
    height: var(--app-h, 100dvh);
    width: 100%;
    z-index: 60;
    background: var(--pane);
    border-left: none;
    animation: mobilePaneIn 220ms cubic-bezier(0.22, 1, 0.36, 1) both;
  }
  .right-sidebar-head {
    height: calc(62px + env(safe-area-inset-top, 0px));
    padding: env(safe-area-inset-top, 0px) 14px 0 18px;
    background: var(--pane);
  }
  .right-sidebar-title { font-size: 18px; }
  .right-sidebar-body { padding: 18px 16px; gap: 18px; }
  .dm-profile { border-radius: 18px; }
  .dm-profile-banner { height: 84px; }
  .dm-profile-card .avatar.xl { width: 88px; height: 88px; font-size: 31px; margin-top: -44px; }
  .dm-profile-name { font-size: 21px; }
  .status-chip { font-size: 13px; padding: 5px 12px; }
  .member-row { padding: 10px 10px; gap: 12px; border-radius: 12px; }
  .member-row .avatar.sm { width: 42px; height: 42px; font-size: 15px; }
  .inline-row input { height: 46px; border-radius: 12px; }
  .inline-row .btn { min-width: 46px; height: 46px; border-radius: 12px; font-size: 18px; }
  .right-sidebar-foot { padding: 14px 16px max(28px, calc(16px + env(safe-area-inset-bottom, 0px))); }
  .right-sidebar-foot .btn { height: 46px; font-size: 15px; border-radius: 12px; }

  /* Mobile Full-Stage Call View & Viewport-Safe Dock */
  .chat-shell.call-mode.call-chat-open #chat-body-wrap {
    top: calc(62px + env(safe-area-inset-top, 0px));
    left: 0;
    width: 100%;
    border-left: none;
  }
  .preset-select { display: none; }
  .stage-hud-top { top: 12px; left: 12px; right: 12px; }
  .stage-pill { padding: 7px 14px; font-size: 13.5px; }
  .hud-icon-btn { width: 40px; height: 40px; }
  .hud-icon-btn svg { width: 19px; height: 19px; }
  .stage-body { padding: 10px 10px max(106px, calc(92px + env(safe-area-inset-bottom, 0px))); }
  .participants-grid { grid-template-columns: 1fr; padding-top: 52px; gap: 12px; }
  .peer-tile { min-height: 220px; border-radius: 18px; }
  .peer-tile .avatar.lg { width: 82px; height: 82px; font-size: 29px; }
  .peer-tile-footer { padding: 8px 12px; font-size: 13.5px; border-radius: 11px; }
  .tile-pin-btn { opacity: 0.92; width: 36px; height: 36px; }
  .tile-pin-btn svg { width: 16px; height: 16px; }
  .call-dock {
    max-width: calc(100vw - 16px);
    padding: 6px 8px;
    gap: 5px;
    bottom: max(26px, calc(14px + env(safe-area-inset-bottom, 0px)));
  }
  .dock-btn { width: 42px; height: 42px; flex-shrink: 0; }
  .dock-btn svg { width: 20px; height: 20px; }
  .dock-btn.danger { width: 50px; }

  /* FaceTime-Grade Mobile Incoming Call Overlay */
  .incoming-call-backdrop {
    align-items: center;
    justify-content: center;
    background: rgba(6, 7, 10, 0.74);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    pointer-events: auto;
    padding: 20px;
  }
  .incoming-call-card {
    width: min(344px, 100%);
    flex-direction: column;
    text-align: center;
    padding: 30px 24px 24px;
    border-radius: 28px;
    gap: 24px;
  }
  .incoming-glow {
    inset: -30% auto auto 50%;
    transform: translateX(-50%);
    width: 280px;
    height: 280px;
  }
  .incoming-info {
    flex-direction: column;
    gap: 16px;
  }
  .incoming-avatar-ring { width: 92px; height: 92px; }
  .incoming-avatar-ring .avatar.lg { width: 84px; height: 84px; font-size: 30px; }
  .incoming-text { align-items: center; gap: 5px; }
  .incoming-kicker { font-size: 13px; }
  .incoming-text strong { font-size: 23px; white-space: normal; }
  .incoming-actions {
    display: flex;
    width: 100%;
    justify-content: space-evenly;
    gap: 20px;
  }
  .inc-btn {
    height: auto;
    padding: 0;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    flex-direction: column;
    font-size: 13px;
    gap: 8px;
  }
  .inc-btn-ic {
    width: 64px;
    height: 64px;
    border-radius: 50%;
  }
  .inc-decline .inc-btn-ic { background: var(--danger); color: #fff; }
  .inc-decline span:last-child { color: #FCA5A5; }
  .inc-accept .inc-btn-ic {
    background: var(--live);
    color: #fff;
    box-shadow: 0 8px 24px rgba(35, 165, 90, 0.45);
  }
  .inc-accept span:last-child { color: #8BE4AD; }
  .inc-btn-ic svg { width: 27px; height: 27px; }

  .toast-stack {
    left: 16px;
    right: 16px;
    bottom: max(96px, calc(78px + env(safe-area-inset-bottom, 0px)));
    align-items: center;
  }
  .toast { font-size: 14px; padding: 11px 18px; border-radius: 99px; }

  .close-drawer-btn { width: 42px; height: 42px; border-radius: 12px; background: var(--elevated); color: var(--ink); }
  .close-drawer-btn svg { width: 20px; height: 20px; }
  .room-swipe-wrap { border-radius: 14px; }
  .room-item { background: color-mix(in srgb, var(--elevated) 55%, var(--pane)); }
  .room-item.active { background: var(--elevated-2); }
  .msg-actions { display: none !important; }
  .voice-player { min-width: 210px; max-width: 256px; }
  .ctx-menu-row { height: 39px; font-size: 13.5px; }
  .ctx-react-btn { width: 36px; height: 36px; font-size: 20px; }
  .app-modal-actions .btn { height: 40px; font-size: 13.5px; }
  .spotlight-box:not(.hidden) + .participants-grid { height: 112px; padding: 2px 6px; gap: 8px; }
  .spotlight-box:not(.hidden) + .participants-grid .peer-tile { width: 168px; height: 102px; border-radius: 13px; }
  .spotlight-box:not(.hidden) + .participants-grid .avatar.lg { width: 42px; height: 42px; font-size: 15px; }
  .spotlight-box:not(.hidden) + .participants-grid .tile-pin-btn { width: 28px; height: 28px; top: 6px; right: 6px; }
  .spotlight-box:not(.hidden) + .participants-grid .peer-tile-footer { left: 6px; bottom: 6px; padding: 3px 7px; font-size: 11px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
