/* ═══════════════════════════════════════════════════════
   Adharc — Discord-style CSS
   ═══════════════════════════════════════════════════════ */

:root {
  --bg-primary: #313338;
  --bg-secondary: #2b2d31;
  --bg-tertiary: #1e1f22;
  --bg-floating: #111214;
  --bg-accent: #5865f2;
  --bg-accent-hover: #4752c4;
  --bg-modifier-hover: rgba(79, 84, 92, 0.16);
  --bg-modifier-active: rgba(79, 84, 92, 0.24);
  --bg-modifier-selected: rgba(79, 84, 92, 0.32);

  --text-normal: #dbdee1;
  --text-muted: #949ba4;
  --text-link: #00a8fc;
  --text-positive: #23a55a;
  --text-danger: #f23f43;

  --header-primary: #f2f3f5;
  --header-secondary: #b5bac1;

  --channel-icon: #80848e;
  --interactive-normal: #b5bac1;
  --interactive-hover: #dbdee1;
  --interactive-active: #fff;

  --scrollbar-thin-thumb: #1a1b1e;
  --scrollbar-thin-track: #2b2d31;

  --font-primary: 'gg sans', 'Noto Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif;
  --font-code: 'Consolas', 'Andale Mono WT', 'Andale Mono', 'Lucida Console', monospace;

  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 16px;
  --radius-full: 50%;
  --user-panel-height: 52px;
  --media-dock-height: 26vh;

  /* Safe area insets for notch devices */
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);

  /* Mobile drawer width */
  --drawer-width: 300px;
  --scroll-shadow-top: inset 0 10px 12px -12px rgba(0, 0, 0, 0.58);
  --scroll-shadow-bottom: inset 0 -10px 12px -12px rgba(0, 0, 0, 0.58);
  --landing-bg-image: url('/assets/rhino-vibes-bg.jpg');
}

* { margin: 0; padding: 0; box-sizing: border-box; }
[hidden] { display: none !important; }

html {
  /* Use dvh for mobile address-bar-aware height */
  height: 100dvh;
  height: 100vh; /* fallback */
}

body {
  font-family: var(--font-primary);
  background: var(--bg-tertiary);
  color: var(--text-normal);
  overflow: hidden;
  height: 100dvh;
  height: 100vh;
  width: 100vw;
  /* Prevent iOS rubber-banding */
  overscroll-behavior: none;
  -webkit-text-size-adjust: 100%;
}

/* Shared motion tokens */
:root {
  --ease-out-std: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-out-soft: cubic-bezier(0.16, 1, 0.3, 1);
}

/* ── Screens ─────────────────────────────────────────── */
.screen {
  display: none;
  height: 100dvh;
  height: 100vh;
  width: 100vw;
}
.screen.active {
  display: flex;
  animation: ui-screen-fade-in 220ms var(--ease-out-soft);
}

/* ── Auth Screen ─────────────────────────────────────── */
#auth-screen {
  position: relative;
  align-items: center;
  justify-content: center;
  background: #0f1012;
  padding: 16px;
  padding-top: calc(16px + var(--sat));
  overflow: hidden;
}

.auth-container {
  background: linear-gradient(162deg, rgba(249, 247, 239, 0.93), rgba(243, 240, 229, 0.88));
  border-radius: 14px;
  border: 1px solid rgba(20, 20, 20, 0.3);
  padding: 30px 30px 26px;
  width: 100%;
  max-width: 520px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.48);
  animation: ui-surface-rise 300ms var(--ease-out-std);
  position: relative;
  z-index: 2;
  backdrop-filter: blur(3px);
  color: #1a1a1a;
}

.auth-sonic-bg {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

.auth-wave-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  opacity: 0.16;
  mix-blend-mode: multiply;
}

.auth-sonic-bg::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(180deg, rgba(252, 250, 242, 0.52), rgba(238, 233, 220, 0.58)),
    radial-gradient(circle at 22% 18%, rgba(255, 255, 255, 0.34), rgba(255, 255, 255, 0) 52%),
    var(--landing-bg-image);
  background-size: cover, cover, cover;
  background-position: center, center, center;
  background-repeat: no-repeat;
  filter: grayscale(0.08) contrast(1.02);
}

.auth-sonic-bg::after {
  content: '';
  position: absolute;
  inset: 0;
  background:
    linear-gradient(100deg, rgba(13, 13, 13, 0.34), rgba(13, 13, 13, 0.08) 36%, rgba(13, 13, 13, 0.28) 100%),
    radial-gradient(circle at 50% 110%, rgba(0, 0, 0, 0.45), rgba(0, 0, 0, 0) 58%);
}

.auth-wave-emitter {
  position: absolute;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  contain: paint;
}

.auth-wave-emitter-core {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle, rgba(222, 248, 255, 0.8) 0%, rgba(168, 225, 255, 0.7) 34%, rgba(87, 162, 230, 0.22) 100%);
  box-shadow: 0 0 20px rgba(126, 195, 246, 0.42);
  opacity: 0.55;
  transition: opacity 480ms ease, box-shadow 620ms ease, filter 680ms ease;
}

.auth-sonic-bg.is-interacting .auth-wave-emitter-core {
  opacity: 0.82;
  filter: hue-rotate(-10deg) saturate(1.14);
  box-shadow: 0 0 24px rgba(255, 189, 118, 0.48);
}

.auth-wave-ring {
  position: absolute;
  left: var(--x, 50%);
  top: var(--y, 50%);
  width: var(--ring-size, 26px);
  height: var(--ring-size, 26px);
  border-radius: 50%;
  transform: translate(-50%, -50%) scale(0.14);
  border: var(--ring-thickness, 2px) solid hsl(var(--ring-hue, 198) var(--ring-sat, 85%) var(--ring-lit, 76%) / var(--ring-alpha, 0.62));
  box-shadow:
    0 0 18px hsl(var(--ring-hue, 198) 80% 68% / calc(var(--ring-alpha, 0.62) * 0.72)),
    inset 0 0 10px hsl(var(--ring-hue, 198) 90% 88% / calc(var(--ring-alpha, 0.62) * 0.45));
  opacity: 0;
  pointer-events: none;
  will-change: transform, opacity;
  backface-visibility: hidden;
  animation: auth-wave-fractal var(--ring-duration, 5600ms) cubic-bezier(0.12, 0.64, 0.2, 1) forwards;
}

.auth-sonic-bg.is-interacting .auth-wave-ring {
  filter: hue-rotate(-8deg) saturate(1.12);
}

@keyframes auth-wave-fractal {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.12);
  }
  10% {
    opacity: var(--ring-peak-opacity, 0.56);
  }
  62% {
    opacity: calc(var(--ring-peak-opacity, 0.56) * 0.34);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(var(--ring-scale, 16));
  }
}

.auth-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}
.auth-glyph {
  width: 72px;
  height: 72px;
  border-radius: 16px;
  flex-shrink: 0;
}
.auth-logo h1 {
  font-family: 'Sorts Mill Goudy', 'Times New Roman', serif;
  font-size: clamp(2.1rem, 5vw, 3rem);
  color: #111;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.auth-logo::after {
  content: 'Vibes Chat';
  display: block;
  margin-left: 84px;
  margin-top: -8px;
  font-family: 'Sorts Mill Goudy', 'Times New Roman', serif;
  font-size: 1.15rem;
  color: rgba(20, 20, 20, 0.86);
}

.auth-invite-banner {
  margin-bottom: 16px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(240, 178, 50, 0.55);
  background: rgba(240, 178, 50, 0.12);
  color: #f6ca63;
  font-size: 13px;
  line-height: 1.35;
}

.auth-desktop-downloads {
  margin-top: 12px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(111, 183, 255, 0.4);
  background: rgba(111, 183, 255, 0.1);
  color: #1a1a1a;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.auth-desktop-downloads a {
  color: #111;
  text-decoration: none;
}

.auth-desktop-downloads a:hover {
  text-decoration: underline;
}

.auth-panel { display: none; }
.auth-panel.active {
  display: block;
  animation: ui-section-reveal 260ms var(--ease-out-soft);
}
.auth-panel + .auth-panel {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}

.auth-panel h2 {
  font-size: 20px;
  color: #171717;
  margin-bottom: 8px;
  font-family: 'Cinzel', 'Times New Roman', serif;
  letter-spacing: 0.02em;
}
.auth-subtitle {
  color: rgba(20, 20, 20, 0.72);
  font-size: 14px;
  margin-bottom: 20px;
  line-height: 1.4;
}

.form-group {
  margin-bottom: 16px;
}
.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  color: rgba(20, 20, 20, 0.8);
  margin-bottom: 8px;
  letter-spacing: 0.02em;
}
.form-group input[type="text"] {
  width: 100%;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.68);
  border: 1px solid rgba(16, 16, 16, 0.26);
  border-radius: var(--radius-sm);
  color: #151515;
  font-size: 16px;
  outline: none;
  /* 16px prevents iOS auto-zoom on focus */
}
.form-group input[type="text"]:focus {
  border-color: rgba(17, 17, 17, 0.62);
  box-shadow: 0 0 0 2px rgba(17, 17, 17, 0.18);
}

.form-inline {
  display: flex;
  gap: 8px;
}
.form-inline input { flex: 1; min-width: 0; }

.remember-row {
  margin-top: -6px;
}

.remember-toggle {
  display: inline-flex !important;
  align-items: center;
  gap: 8px;
  font-size: 13px !important;
  color: rgba(20, 20, 20, 0.74) !important;
  text-transform: none !important;
  letter-spacing: normal !important;
  font-weight: 500 !important;
  cursor: pointer;
}

.remember-toggle input[type="checkbox"] {
  accent-color: var(--bg-accent);
}

.auth-login-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.auth-help {
  margin-top: 12px;
  border: 1px solid rgba(16, 16, 16, 0.2);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.42);
  overflow: hidden;
}

.auth-help summary {
  list-style: none;
  cursor: pointer;
  padding: 10px 12px;
  font-size: 13px;
  font-weight: 700;
  color: rgba(20, 20, 20, 0.8);
  user-select: none;
}

.auth-help summary::-webkit-details-marker {
  display: none;
}

.auth-help summary::after {
  content: '+';
  float: right;
  color: rgba(20, 20, 20, 0.6);
}

.auth-help[open] summary::after {
  content: '-';
}

.auth-help-body {
  border-top: 1px solid rgba(16, 16, 16, 0.14);
  padding: 10px 12px 12px;
}

.auth-help-body p {
  font-size: 13px;
  line-height: 1.4;
  color: rgba(20, 20, 20, 0.74);
  margin-bottom: 8px;
}

.auth-help-body p:last-child {
  margin-bottom: 0;
}

.btn-forget-key {
  justify-content: center;
  min-height: 36px;
}

.file-drop {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 80px;
  border: 2px dashed rgba(17, 17, 17, 0.32);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, box-shadow 0.2s, transform 0.2s;
}
.file-drop:hover, .file-drop.dragover {
  border-color: rgba(14, 14, 14, 0.72);
  background: rgba(255, 255, 255, 0.52);
}
.file-drop.loaded {
  border-style: solid;
  border-color: rgba(14, 14, 14, 0.7);
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.64), rgba(240, 236, 222, 0.6));
  box-shadow: 0 0 0 1px rgba(14, 14, 14, 0.26), 0 10px 24px rgba(0, 0, 0, 0.16);
}
.file-drop.loaded:hover {
  transform: translateY(-1px);
}
.file-drop.loaded .file-drop-text {
  color: #151515;
  font-weight: 700;
}
.file-drop-text {
  color: rgba(20, 20, 20, 0.74);
  font-size: 14px;
  text-align: center;
  padding: 0 12px;
}

.btn-primary {
  width: 100%;
  padding: 12px;
  background: #151515;
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, transform 0.15s ease, box-shadow 0.22s ease;
  /* Better touch target */
  min-height: 44px;
}
.btn-primary:hover:not(:disabled) {
  background: #000;
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.34);
}
.btn-primary:active:not(:disabled) { transform: scale(0.98); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-secondary {
  padding: 12px 20px;
  background: #2b2b2b;
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, transform 0.15s ease, box-shadow 0.2s ease;
  min-height: 44px;
}
.btn-secondary:hover {
  background: #111;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.22);
}
.btn-secondary:active { transform: scale(0.98); }

.btn-link {
  background: none;
  border: none;
  color: rgba(20, 20, 20, 0.68);
  cursor: pointer;
  font-size: 14px;
  padding: 8px 16px;
  transition: color 0.2s, transform 0.12s ease;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}
.btn-link:hover { color: var(--text-normal); }
.btn-link:active { transform: translateY(1px); }
.btn-link.active { color: var(--bg-accent); }

.auth-toggle {
  display: flex;
  justify-content: center;
  margin-top: 16px;
  gap: 8px;
}

.error-msg {
  margin-top: 12px;
  padding: 10px;
  background: rgba(242, 63, 67, 0.1);
  border: 1px solid var(--text-danger);
  border-radius: var(--radius-sm);
  color: var(--text-danger);
  font-size: 14px;
}

/* ── Server Select Screen ────────────────────────────── */
#server-screen {
  position: relative;
  align-items: center;
  justify-content: center;
  background: #0f1012;
  padding: 16px;
  padding-top: calc(16px + var(--sat));
  overflow: hidden;
}

.server-select-container {
  background: linear-gradient(164deg, rgba(249, 247, 239, 0.94), rgba(244, 240, 228, 0.88));
  border-radius: 14px;
  border: 1px solid rgba(20, 20, 20, 0.3);
  padding: 30px 30px 24px;
  width: 100%;
  max-width: 520px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.48);
  max-height: calc(100dvh - 32px - var(--sat));
  overflow-y: auto;
  animation: ui-surface-rise 300ms var(--ease-out-std);
  position: relative;
  z-index: 2;
  backdrop-filter: blur(3px);
}

.server-sonic-bg::before {
  background-image:
    linear-gradient(180deg, rgba(251, 249, 241, 0.5), rgba(234, 229, 216, 0.58)),
    radial-gradient(circle at 68% 14%, rgba(255, 255, 255, 0.3), rgba(255, 255, 255, 0) 48%),
    var(--landing-bg-image);
  background-size: cover, cover, cover;
  background-position: center 36%, center, center 36%;
  background-repeat: no-repeat;
  filter: grayscale(0.08) contrast(1.02);
}

.server-select-container h2 {
  color: #171717;
  margin-bottom: 18px;
  font-family: 'Cinzel', 'Times New Roman', serif;
  letter-spacing: 0.02em;
}

.server-select-brand {
  margin-bottom: 16px;
}

.server-select-brand h1 {
  font-family: 'Sorts Mill Goudy', 'Times New Roman', serif;
  font-size: clamp(2rem, 4.4vw, 2.7rem);
  color: #111;
  line-height: 0.95;
}

.server-select-brand p {
  margin-top: 6px;
  font-family: 'Sorts Mill Goudy', 'Times New Roman', serif;
  font-size: 1.06rem;
  color: rgba(20, 20, 20, 0.82);
}

.server-list {
  max-height: 300px;
  overflow-y: auto;
  margin-bottom: 20px;
  box-shadow: var(--scroll-shadow-top), var(--scroll-shadow-bottom);
  border-radius: var(--radius-sm);
}

.server-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background 0.15s, transform 0.16s ease, box-shadow 0.2s ease;
  min-height: 56px;
}
.server-card:hover {
  background: rgba(16, 16, 16, 0.08);
  transform: translateY(-1px);
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
}
.server-card:active { background: var(--bg-modifier-active); }

.server-card-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-lg);
  background: #151515;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.server-card-name {
  font-weight: 600;
  color: #171717;
}
.server-card-id {
  font-size: 11px;
  color: rgba(20, 20, 20, 0.58);
  font-family: var(--font-code);
  word-break: break-all;
}

.server-actions {
  border-top: 1px solid rgba(16, 16, 16, 0.2);
  padding-top: 16px;
}
.server-actions .form-group { margin-bottom: 10px; }

.server-action-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}

.server-action-row input[type="text"] {
  min-width: 280px;
}

.server-action-row button {
  min-width: 100px;
}

.no-servers {
  text-align: center;
  color: rgba(20, 20, 20, 0.7);
  padding: 24px 0;
}

#server-screen .session-actions .btn-link {
  color: rgba(20, 20, 20, 0.72);
}

#auth-screen .btn-link:hover,
#server-screen .btn-link:hover {
  color: #111;
}

.session-actions {
  margin-top: 12px;
  display: flex;
  justify-content: center;
  gap: 8px;
}

.btn-logout {
  display: inline-flex;
  margin: 0;
  color: var(--text-danger);
}

/* ── App Layout ──────────────────────────────────────── */
.app-layout {
  display: grid;
  grid-template-columns: 72px 240px 1fr 240px;
  height: 100dvh;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
}

/* ── Drawer Backdrop (mobile only, hidden on desktop) ── */
.drawer-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 149;
  opacity: 0;
  transition: opacity 0.25s ease;
  -webkit-tap-highlight-color: transparent;
}
.drawer-backdrop.active {
  opacity: 1;
}

/* ── Mobile-only buttons (hidden on desktop) ─────────── */
.mobile-menu-btn,
.mobile-members-btn,
.mobile-back-servers-btn,
.mobile-close-btn {
  display: none;
}

/* Server rail */
.server-rail {
  background: var(--bg-tertiary);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 0;
  padding-top: calc(12px + var(--sat));
  gap: 8px;
  overflow-y: auto;
}

.server-rail-list {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.server-icon {
  width: 48px;
  height: 48px;
  border-radius: 24px;
  background: var(--bg-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 700;
  color: var(--text-normal);
  cursor: pointer;
  transition: border-radius 0.2s, background 0.2s, color 0.2s;
  -webkit-tap-highlight-color: transparent;
}
.server-icon-title {
  border: none;
}
.server-icon:hover, .server-icon.active {
  border-radius: var(--radius-lg);
  background: var(--bg-accent);
  color: #fff;
}
.server-icon.server-icon-draggable {
  cursor: grab;
}
.server-icon.server-icon-draggable:active {
  cursor: grabbing;
}
.server-icon.dragging {
  opacity: 0.5;
  transform: scale(0.96);
}
.server-icon.drag-over-before {
  box-shadow: inset 0 3px 0 0 var(--bg-accent);
}
.server-icon.drag-over-after {
  box-shadow: inset 0 -3px 0 0 var(--bg-accent);
}

.server-add {
  background: var(--bg-primary);
  color: var(--text-positive);
}
.server-add:hover {
  background: var(--text-positive);
  color: #fff;
}
.server-add svg { pointer-events: none; }

.rail-divider {
  width: 32px;
  height: 2px;
  background: var(--bg-modifier-active);
  border-radius: 1px;
}

/* Channel sidebar */
.channel-sidebar {
  background: var(--bg-secondary);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-header {
  height: 48px;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  box-shadow: 0 1px 0 rgba(0,0,0,0.15);
  flex-shrink: 0;
}
.sidebar-header h3 {
  font-size: 16px;
  font-weight: 700;
  color: var(--header-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

.sidebar-server-actions {
  display: flex;
  gap: 4px;
}

.channel-list {
  flex: 1;
  overflow-y: auto;
  padding: 0 8px;
  -webkit-overflow-scrolling: touch;
  box-shadow: var(--scroll-shadow-top), var(--scroll-shadow-bottom);
}

.channel-category {
  padding: 5px 8px 4px;
  font-size: 12px;
  font-weight: 700;
  color: var(--channel-icon);
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.channel-category-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-right: 8px;
  margin-top: 8px;
}

.channel-category-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.channel-collapse-btn {
  width: 24px;
  height: 24px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--channel-icon);
  cursor: pointer;
  font-size: 22px;
  line-height: 1;
  transform-origin: 50% 50%;
  transition: transform 0.18s ease, color 0.12s ease, background 0.12s ease;
}

.channel-collapse-btn:hover {
  background: var(--bg-modifier-hover);
  color: var(--interactive-hover);
}

.channel-collapse-btn.is-collapsed {
  transform: rotate(-90deg);
}

.channel-add-btn {
  width: 24px;
  height: 24px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--channel-icon);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
}
.channel-add-btn:hover {
  background: var(--bg-modifier-hover);
  color: var(--interactive-hover);
}

#text-channels.is-collapsed,
#voice-channels.is-collapsed {
  display: none;
}

.channel-item {
  display: flex;
  flex-flow: row wrap;
  align-items: center;
  padding: 2px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--channel-icon);
  font-size: 16px;
  font-weight: 500;
  transition: background 0.12s, color 0.12s, transform 0.16s ease;
  gap: 6px;
  min-height: 32px;
  -webkit-tap-highlight-color: transparent;
}
.channel-item:hover {
  background: var(--bg-modifier-hover);
  color: var(--interactive-hover);
  transform: translateX(2px);
}
.channel-item:active {
  background: var(--bg-modifier-active);
}
.channel-item.active {
  background: var(--bg-modifier-selected);
  color: var(--interactive-active);
}
.channel-item.voice-active {
  background: var(--bg-modifier-selected);
  color: var(--interactive-active);
}
.channel-item.voice-active .channel-voice-header {
  background: var(--bg-modifier-selected);
  color: var(--interactive-active);
}
.channel-item.voice-active .channel-voice-header:hover {
  background: var(--bg-modifier-selected);
  color: var(--interactive-active);
}
.channel-item.channel-item-draggable {
  cursor: grab;
}
.channel-item.channel-item-draggable:active {
  cursor: grabbing;
}
.channel-item.channel-item-draggable .channel-voice-header {
  cursor: grab;
}
.channel-item.channel-item-draggable:active .channel-voice-header {
  cursor: grabbing;
}
.channel-item.dragging {
  opacity: 0.45;
  transform: scale(0.985);
}
.channel-item.drag-over-before {
  box-shadow: inset 0 2px 0 0 var(--bg-accent);
}
.channel-item.drag-over-after {
  box-shadow: inset 0 -2px 0 0 var(--bg-accent);
}

.channel-icon { font-weight: 400; opacity: 0.7; flex-shrink: 0; }
.channel-icon svg { vertical-align: middle; }
.channel-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.channel-drag-handle {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 16px;
  color: var(--text-muted);
  opacity: 0.65;
  font-size: 12px;
  letter-spacing: -1px;
  cursor: grab;
  user-select: none;
}
.channel-item.channel-item-draggable:active .channel-drag-handle {
  cursor: grabbing;
}
.channel-item.channel-item-draggable:hover .channel-drag-handle {
  opacity: 0.95;
  color: var(--interactive-hover);
}

.channel-voice-header {
  display: flex;
  align-items: center;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--channel-icon);
  font-size: 16px;
  font-weight: 500;
  gap: 6px;
  min-height: 40px;
  transition: background 0.12s, color 0.12s, transform 0.16s ease;
  -webkit-tap-highlight-color: transparent;
  flex: 0 1 100%;
  position: relative;
  overflow: visible;
}
.channel-voice-header:hover {
  background: var(--bg-modifier-hover);
  color: var(--interactive-hover);
  transform: translateX(2px);
}

.channel-voice-header.voice-poof-join::before,
.channel-voice-header.voice-poof-leave::before {
  content: '';
  position: absolute;
  left: -16px;
  top: 50%;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  pointer-events: none;
  opacity: 0;
}

.channel-voice-header.voice-poof-join::before {
  background:
    radial-gradient(circle at 45% 45%, rgba(174, 255, 225, 0.92), rgba(174, 255, 225, 0.24) 60%, transparent 100%);
  box-shadow:
    0 0 10px rgba(105, 219, 173, 0.56),
    8px -4px 0 0 rgba(166, 248, 220, 0.28),
    10px 5px 0 0 rgba(136, 232, 194, 0.2),
    4px 8px 0 0 rgba(150, 244, 206, 0.2);
  animation: voice-poof-join 760ms ease-out;
}

.channel-voice-header.voice-poof-leave::before {
  background:
    radial-gradient(circle at 45% 45%, rgba(230, 233, 239, 0.86), rgba(230, 233, 239, 0.25) 60%, transparent 100%);
  box-shadow:
    0 0 9px rgba(186, 193, 206, 0.5),
    7px -3px 0 0 rgba(205, 212, 226, 0.26),
    9px 5px 0 0 rgba(182, 189, 206, 0.18),
    3px 8px 0 0 rgba(168, 176, 193, 0.18);
  animation: voice-poof-leave 760ms ease-out;
}

@keyframes voice-poof-join {
  0% {
    opacity: 0.1;
    transform: translate(0, -50%) scale(0.2);
    filter: blur(0px);
  }
  22% {
    opacity: 0.82;
    transform: translate(4px, -58%) scale(1.6);
    filter: blur(0.4px);
  }
  62% {
    opacity: 0.42;
    transform: translate(11px, -70%) scale(2.6);
    filter: blur(1.1px);
  }
  100% {
    opacity: 0;
    transform: translate(18px, -82%) scale(3.4);
    filter: blur(2px);
  }
}

@keyframes voice-poof-leave {
  0% {
    opacity: 0.14;
    transform: translate(0, -50%) scale(0.2);
    filter: blur(0px);
  }
  22% {
    opacity: 0.72;
    transform: translate(3px, -54%) scale(1.45);
    filter: blur(0.35px);
  }
  62% {
    opacity: 0.34;
    transform: translate(9px, -65%) scale(2.3);
    filter: blur(1px);
  }
  100% {
    opacity: 0;
    transform: translate(14px, -76%) scale(3.1);
    filter: blur(1.9px);
  }
}

.voice-users {
  padding-left: 32px;
}
.voice-user {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
  font-size: 13px;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  transition: background 0.2s ease, box-shadow 0.2s ease, opacity 0.18s ease, transform 0.18s ease;
  opacity: 1;
  transform: translateY(0);
  will-change: opacity, transform;
}

.voice-user.voice-user-enter {
  animation: voice-user-enter 180ms var(--ease-out-soft);
}

.voice-user.voice-user-leave {
  animation: voice-user-leave 220ms ease forwards;
  pointer-events: none;
}

.voice-user-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.voice-user-mic-unavailable {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-danger);
  opacity: 0.9;
}

.voice-user-media-actions {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.voice-user-avatar {
  width: 24px;
  height: 24px;
  border-radius: var(--radius-full);
  background: var(--bg-accent);
  border: 1px solid rgba(255, 255, 255, 0.12);
  image-rendering: pixelated;
  flex-shrink: 0;
  transform: scale(1);
  transition: transform 0.18s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.voice-user.speaking .voice-user-name {
  color: var(--interactive-active);
  font-weight: 700;
}

.voice-user.speaking {
  background: rgba(35, 165, 90, 0.14);
  box-shadow: inset 0 0 0 1px rgba(35, 165, 90, 0.25);
}

.voice-user.speaking .voice-user-avatar {
  transform: scale(1.11);
  border-color: rgba(103, 226, 148, 0.8);
  box-shadow: 0 0 0 3px rgba(35, 165, 90, 0.2);
  animation: speaking-pulse 1.15s ease-in-out infinite;
}

@keyframes voice-user-enter {
  from {
    opacity: 0;
    transform: translateY(6px) scale(0.98);
    filter: blur(0.4px);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
    filter: blur(0);
  }
}

@keyframes voice-user-leave {
  from {
    opacity: 1;
    transform: translateY(0) scale(1);
    filter: blur(0);
  }
  to {
    opacity: 0;
    transform: translateY(-6px) scale(0.98);
    filter: blur(0.8px);
  }
}

.sidebar-music-player {
  flex-shrink: 0;
  width: 100%;
  margin: 0;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(0, 0, 0, 0.22);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sidebar-music-row {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 6px;
}

.sidebar-music-now-playing {
  flex: 1;
  min-width: 0;
  font-size: 12px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
  border-radius: var(--radius-sm);
  padding: 3px 4px;
}

.sidebar-music-now-playing:hover {
  background: var(--bg-modifier-hover);
  color: var(--interactive-hover);
}

.sidebar-music-now-playing:focus-visible {
  outline: 2px solid var(--bg-accent);
  outline-offset: 1px;
}

.sidebar-music-controls {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  margin-left: auto;
}

.sidebar-music-controls .control-btn {
  width: 30px;
  height: 30px;
}

/* User panel */
.user-panel {
  min-height: var(--user-panel-height);
  background: rgba(17,18,20,0.3);
  display: flex;
  flex-direction: column;
  justify-content: center;
  background-color: #1f1f1f;
  flex-shrink: 0;
  padding: 12px;
  gap: 4px;
}

.user-row {
  width: 100%;
}

.user-row-top {
  display: flex;
  align-items: center;
}

.user-row-controls {
  display: flex;
  justify-content: flex-end;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  width: 100%;
}

.user-avatar {
  width: 26px;
  height: 26px;
  border-radius: var(--radius-full);
  background: var(--bg-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
  transform: scale(1);
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.user-avatar-canvas {
  image-rendering: pixelated;
  border: 1px solid rgba(255, 255, 255, 0.14);
}

.user-panel.speaking {
  background-color: rgba(31, 31, 31, 0.85);
}

.user-avatar.speaking {
  transform: scale(1.08);
  box-shadow: 0 0 0 4px rgba(35, 165, 90, 0.2);
  border: 1px solid rgba(103, 226, 148, 0.85);
  animation: speaking-pulse 1.15s ease-in-out infinite;
}

.user-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--header-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}

.user-name-row {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  min-width: 0;
  flex: 1;
}

.user-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
}

.user-rename-btn {
  width: 22px;
  height: 22px;
  color: var(--text-muted);
  flex-shrink: 0;
  opacity: 0.86;
}

.user-rename-btn:hover {
  color: var(--interactive-hover);
  opacity: 1;
}

.user-rename-btn svg {
  width: 13px;
  height: 13px;
}

.user-controls {
  display: flex;
  gap: 4px;
  width: 100%;
  justify-content: flex-end;
}
.control-btn {
  width: 36px;
  height: 36px;
  border: none;
  background: none;
  color: var(--interactive-normal);
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.12s, color 0.12s, transform 0.15s ease;
  -webkit-tap-highlight-color: transparent;
  position: relative;
  overflow: hidden;
}
.control-btn:hover {
  background: var(--bg-modifier-hover);
  color: var(--interactive-hover);
  transform: translateY(-1px);
}
.control-btn.active {
  color: var(--text-danger);
}

#btn-mute.active::after,
#btn-deafen.active::after {
  content: '';
  position: absolute;
  left: 7px;
  right: 7px;
  top: 17px;
  height: 2px;
  border-radius: 999px;
  background: currentColor;
  box-shadow: 0 0 8px rgba(242, 63, 67, 0.45);
  transform: rotate(-32deg);
  transform-origin: center;
  pointer-events: none;
  opacity: 0.95;
}

#btn-mute.active svg,
#btn-deafen.active svg {
  animation: muted-icon-jiggle 4.8s ease-in-out infinite;
  transform-origin: 50% 50%;
}

@keyframes muted-icon-jiggle {
  0%, 70%, 100% { transform: rotate(0deg) translateX(0); }
  74% { transform: rotate(-4deg) translateX(-0.4px); }
  78% { transform: rotate(3deg) translateX(0.4px); }
  82% { transform: rotate(-2deg) translateX(-0.2px); }
  86% { transform: rotate(0deg) translateX(0); }
}

/* ── Main Content ────────────────────────────────────── */
.main-content {
  background: var(--bg-primary);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  isolation: isolate;
  min-width: 0;
  min-height: 0;         /* prevent flex/grid overflow */
  max-height: 100dvh;   /* fallback */
}

.chat-visualizer-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
  opacity: 0.92;
}

.chat-header {
  height: 48px;
  padding: 0 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 1px 0 rgba(0,0,0,0.15);
  flex-shrink: 0;
  position: relative;
  z-index: 20;
}
.channel-hash {
  font-size: 20px;
  font-weight: 600;
  color: var(--channel-icon);
}
#current-channel-name {
  font-size: 16px;
  font-weight: 700;
  color: var(--header-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-connection-indicator {
  margin-left: 6px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  background: rgba(0, 0, 0, 0.2);
  flex-shrink: 0;
}

.chat-connection-dot {
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
  background: currentColor;
}

.chat-connection-online {
  color: var(--text-positive);
}

.chat-connection-offline {
  color: var(--text-danger);
}

.chat-connection-connecting,
.chat-connection-reconnecting {
  color: #f0b232;
}

.header-actions {
  margin-left: auto;
  display: flex;
  gap: 4px;
  position: relative;  /* anchor for theme dropdown */
}
.header-btn {
  width: 36px;
  height: 36px;
  border: none;
  background: none;
  color: var(--interactive-normal);
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.12s, transform 0.15s ease, background 0.12s ease;
  -webkit-tap-highlight-color: transparent;
}
.header-btn:hover {
  color: var(--interactive-hover);
  transform: translateY(-1px);
  background: var(--bg-modifier-hover);
}
.header-btn.active { color: var(--text-positive); }
#btn-visualizer.active {
  color: #9fd3ff;
  background: rgba(111, 183, 255, 0.14);
}

#btn-music-panel.music-live,
#btn-music-panel-sidebar.music-live {
  position: relative;
  overflow: hidden;
}

#btn-music-panel.music-live {
  color: #9fc9da;
  background: rgba(83, 132, 160, 0.1);
  box-shadow: 0 0 8px rgba(101, 160, 194, 0.2);
}

#btn-music-panel-sidebar.music-live {
  color: #d9be93;
  background: rgba(153, 124, 76, 0.1);
  box-shadow: 0 0 8px rgba(184, 148, 92, 0.18);
}

#btn-music-panel.music-live svg {
  animation: music-live-icon-top 2.1s ease-in-out infinite;
  transform-origin: 50% 50%;
}

#btn-music-panel-sidebar.music-live svg {
  animation: music-live-icon-side 1.9s ease-in-out infinite;
  transform-origin: 50% 50%;
}

@keyframes music-live-icon-top {
  0%, 100% { transform: rotate(0deg) translateY(0) scale(1); }
  25% { transform: rotate(-4deg) translateY(-0.2px) scale(1.02); }
  50% { transform: rotate(3deg) translateY(0) scale(1.015); }
  75% { transform: rotate(-2deg) translateY(0.1px) scale(1.02); }
}

@keyframes music-live-icon-side {
  0%, 100% { transform: rotate(0deg) translateY(0) scale(1); }
  30% { transform: rotate(5deg) translateY(-0.12px) scale(1.025); }
  55% { transform: rotate(-4deg) translateY(0.08px) scale(1.015); }
  80% { transform: rotate(2deg) translateY(0) scale(1.02); }
}

@media (min-width: 1101px) {
  body.desktop-hide-server-rail .app-layout {
    grid-template-columns: 0 240px 1fr 240px;
  }

  body.desktop-hide-members-sidebar .app-layout {
    grid-template-columns: 72px 240px 1fr 0;
  }

  body.desktop-hide-server-rail.desktop-hide-members-sidebar .app-layout {
    grid-template-columns: 0 240px 1fr 0;
  }

  body.desktop-hide-server-rail .server-rail {
    width: 0;
    padding: 0;
    opacity: 0;
    pointer-events: none;
    overflow: hidden;
  }

  body.desktop-hide-members-sidebar .members-sidebar {
    width: 0;
    min-width: 0;
    opacity: 0;
    pointer-events: none;
    overflow: hidden;
    border: none;
  }
}

.music-panel {
  margin: 8px 12px 0;
  padding: 10px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(0, 0, 0, 0.24);
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: min(72vh, 760px);
  overflow: auto;
  position: relative;
  z-index: 1;
  box-shadow: var(--scroll-shadow-top), var(--scroll-shadow-bottom);
}

.music-panel-resizer {
  position: relative;
  left: 0;
  right: 0;
  height: 10px;
  margin: -2px -10px -10px;
  cursor: row-resize;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 0 0 var(--radius-md) var(--radius-md);
  flex-shrink: 0;
}

.music-panel-resizer:hover {
  background: rgba(255, 255, 255, 0.14);
}

.music-panel-header {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.music-now-playing {
  color: var(--text-muted);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.music-controls-row .music-now-playing {
  flex: 1;
  min-width: 0;
}

.music-controls-row,
.music-search-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.music-debug-row {
  font-size: 11px;
  color: #d7c68a;
  background: rgba(215, 198, 138, 0.08);
  border: 1px solid rgba(215, 198, 138, 0.25);
  border-radius: var(--radius-sm);
  padding: 6px 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.music-volume-slider {
  width: 112px;
  flex-shrink: 0;
}

.music-volume-slider-sidebar {
  width: 72px;
}

.music-volume-wrap {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}

.music-volume-wrap-sidebar {
  margin-left: 0;
}

.music-volume-icon {
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  position: relative;
  cursor: pointer;
  border-radius: var(--radius-sm);
  outline: none;
}

.music-volume-icon:hover {
  color: var(--interactive-hover);
}

.music-volume-icon:focus-visible {
  box-shadow: 0 0 0 2px rgba(88, 101, 242, 0.45);
}

.music-volume-icon svg {
  width: 24px;
  height: 24px;
}

.music-volume-wrap.muted .music-volume-icon::after {
  content: '';
  position: absolute;
  left: 2px;
  right: 2px;
  top: 12px;
  height: 2px;
  border-radius: 999px;
  background: currentColor;
  transform: rotate(-32deg);
  opacity: 0.95;
}

.music-search-row input {
  flex: 1;
  min-width: 0;
  min-height: 44px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255,255,255,0.14);
  background: var(--bg-tertiary);
  color: var(--text-normal);
  padding: 10px 12px;
}

.music-results,
.music-queue {
  max-height: none;
  min-height: 84px;
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-right: 2px;
  box-shadow: var(--scroll-shadow-top), var(--scroll-shadow-bottom);
  border-radius: var(--radius-sm);
}

.music-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.music-preset-btn {
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-normal);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  white-space: nowrap;
}

.music-preset-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.22);
}

.music-preset-btn:active {
  transform: scale(0.97);
}

.music-preset-btn.added {
  color: #4caf50;
  border-color: rgba(76, 175, 80, 0.4);
  background: rgba(76, 175, 80, 0.1);
}

.music-preset-btn:disabled {
  cursor: default;
  opacity: 0.8;
}

.music-lists {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  min-height: 0;
  flex: 1;
}

.music-list-block {
  min-height: 110px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.music-list-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--header-secondary);
}

.music-list-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.music-list-action {
  width: 28px;
  height: 28px;
  color: var(--text-danger);
}

.music-results-block {
  background: rgba(0, 168, 252, 0.06);
  border-color: rgba(0, 168, 252, 0.28);
}

.music-queue-block {
  background: rgba(240, 178, 50, 0.06);
  border-color: rgba(240, 178, 50, 0.28);
}

.music-row-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,0.03);
}

.music-row-item.active {
  border: 1px solid rgba(111,183,255,0.45);
  background: rgba(111,183,255,0.12);
}

.music-added-check {
  color: #4caf50;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
}

.music-row-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}

.music-row-btn {
  width: 28px;
  height: 28px;
}

.music-row-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.music-row-main strong,
.music-row-main span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.music-row-main span {
  color: var(--text-muted);
  font-size: 12px;
}

@media (max-width: 768px) {
  .music-panel {
    max-height: 56vh;
  }
  .music-panel-resizer {
    display: none;
  }
  .music-volume-slider {
    width: 88px;
  }
  .music-volume-slider-sidebar {
    width: 62px;
  }
}

/* Chat messages */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  -webkit-overflow-scrolling: touch;
  box-shadow: var(--scroll-shadow-top), var(--scroll-shadow-bottom);
  position: relative;
  z-index: 1;
}

.chat-welcome {
  padding: 16px 0 24px;
  animation: ui-section-reveal 280ms var(--ease-out-soft);
}
.chat-welcome h3 {
  font-size: 24px;
  color: var(--header-primary);
  margin-bottom: 8px;
}
.chat-welcome p {
  color: var(--text-muted);
  font-size: 14px;
}

.chat-msg {
  display: flex;
  gap: 12px;
  padding: 6px 4px;
  border-radius: var(--radius-sm);
  align-items: flex-start;
  transform-origin: top left;
  animation: ui-message-in 220ms var(--ease-out-soft);
}
.chat-msg:hover {
  background: var(--bg-modifier-hover);
}
.chat-msg-mention {
  background: var(--bg-secondary-alt);
  border-left: 3px solid var(--bg-accent);
  padding-left: 8px;
}
.chat-msg-mention:hover {
  background: var(--bg-modifier-hover);
}

.msg-avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  background: var(--bg-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
  margin-top: 2px;
}

.msg-body { min-width: 0; flex: 1; }

.msg-header {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 2px;
  flex-wrap: wrap;
}
.msg-author {
  font-weight: 600;
  font-size: 15px;
  color: var(--header-primary);
}
.msg-author-self { color: var(--bg-accent); }
.msg-time {
  font-size: 11px;
  color: var(--text-muted);
}

.msg-edited {
  font-size: 11px;
  color: var(--text-muted);
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 999px;
  padding: 1px 6px;
  text-transform: lowercase;
}

.msg-edited-owner {
  color: #f1c36d;
  border-color: rgba(241, 195, 109, 0.45);
}

.msg-content {
  font-size: 15px;
  color: var(--text-normal);
  line-height: 1.375;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.msg-image-wrap {
  margin-top: 8px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: rgba(0, 0, 0, 0.24);
  width: fit-content;
  max-width: min(560px, 100%);
}

.msg-image {
  display: block;
  width: auto;
  height: auto;
  max-width: min(560px, 100%);
  max-height: 420px;
}

.msg-image.msg-image-pending {
  min-width: 220px;
  min-height: 120px;
  background: linear-gradient(110deg, rgba(255,255,255,0.04) 25%, rgba(255,255,255,0.14) 45%, rgba(255,255,255,0.04) 65%);
  background-size: 220% 100%;
  animation: msg-image-pending-shimmer 1.2s linear infinite;
}

@keyframes msg-image-pending-shimmer {
  to { background-position: -120% 0; }
}

.chat-image-overlay {
  position: fixed;
  inset: 0;
  z-index: 700;
  background: rgba(4, 6, 10, 0.82);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.chat-image-overlay-card {
  position: relative;
  max-width: min(96vw, 1280px);
  max-height: 92vh;
  border-radius: 12px;
}

.chat-image-overlay-img {
  display: block;
  max-width: min(96vw, 1280px);
  max-height: 92vh;
  width: auto;
  height: auto;
  border-radius: 12px;
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.5);
}

.chat-image-overlay-close {
  position: absolute;
  top: -12px;
  right: -12px;
  width: 34px;
  height: 34px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}

.chat-image-overlay-close:hover {
  background: rgba(255, 255, 255, 0.2);
}

.msg-action-wrap {
  position: relative;
  margin-top: 2px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s ease;
}

.chat-msg:hover .msg-action-wrap,
.chat-msg.msg-menu-open .msg-action-wrap {
  opacity: 1;
  pointer-events: auto;
}

.msg-menu-btn {
  width: 24px;
  height: 24px;
  border: 1px solid rgba(255,255,255,0.16);
  border-radius: 7px;
  background: rgba(0,0,0,0.34);
  color: var(--text-normal);
  cursor: pointer;
  line-height: 1;
  font-size: 16px;
  font-weight: 700;
}

.msg-menu-btn:hover {
  background: rgba(255,255,255,0.08);
}

.msg-action-popover {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  min-width: 116px;
  padding: 6px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(20, 22, 29, 0.98);
  box-shadow: 0 10px 28px rgba(0,0,0,0.35);
  display: flex;
  flex-direction: column;
  gap: 6px;
  z-index: 30;
  animation: ui-popover-in 140ms var(--ease-out-soft);
}

.msg-action-btn {
  border: 1px solid rgba(255,255,255,0.16);
  background: rgba(0,0,0,0.3);
  color: var(--text-normal);
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 7px;
  cursor: pointer;
}

.msg-action-btn:hover {
  background: rgba(255,255,255,0.08);
}

.msg-action-btn.msg-action-delete {
  color: #ffb2b2;
  border-color: rgba(255,120,120,0.4);
}

.msg-editing .msg-content {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.msg-edit-input {
  width: 100%;
  min-height: 72px;
  resize: vertical;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255,255,255,0.18);
  background: rgba(0,0,0,0.26);
  color: var(--text-normal);
  font: inherit;
  line-height: 1.35;
  padding: 8px 10px;
}

.msg-edit-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.msg-save-edit {
  border-color: rgba(111, 183, 255, 0.5);
  color: #bcdfff;
}

.msg-content a {
  color: var(--text-link);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.msg-content a:hover {
  color: #65c4ff;
}

.chat-unfurls {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.chat-unfurl {
  width: min(520px, 100%);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-md);
  background: rgba(0, 0, 0, 0.35);
  overflow: hidden;
}

.chat-unfurl iframe {
  display: block;
  width: 100%;
  border: 0;
}

.chat-unfurl video {
  display: block;
  width: 100%;
  max-height: 360px;
  background: #000;
}

.chat-unfurl audio {
  display: block;
  width: 100%;
  height: 54px;
}

.chat-unfurl-youtube iframe {
  aspect-ratio: 16 / 9;
}

.chat-unfurl-spotify iframe {
  height: 152px;
}

/* Typing indicator */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 16px 4px;
  font-size: 13px;
  color: var(--text-muted);
  height: 24px;
  flex-shrink: 0;
  flex-shrink: 0;
  position: relative;
  z-index: 1;
}

.typing-dots {
  display: flex;
  gap: 3px;
}
.typing-dots span {
  width: 6px;
  height: 6px;
  border-radius: var(--radius-full);
  background: var(--text-muted);
  animation: typing 1.4s infinite;
}
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-4px); opacity: 1; }
}

/* Chat input */
.chat-input-container {
  padding: 6px 12px 12px;
  padding-bottom: calc(12px + var(--sab));
  flex-shrink: 0;
  position: relative;
  z-index: 1;
}
.chat-composer-attachments {
  margin-top: 8px;
}

.chat-composer-attachment {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(0, 0, 0, 0.26);
}

.chat-composer-attachment-thumb {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.04);
}

.chat-composer-attachment-thumb-loading {
  position: relative;
  overflow: hidden;
}

.chat-composer-attachment-thumb-loading::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(110deg, rgba(255,255,255,0.03) 25%, rgba(255,255,255,0.16) 45%, rgba(255,255,255,0.03) 65%);
  transform: translateX(-100%);
  animation: composer-attachment-shimmer 1.1s linear infinite;
}

.chat-composer-attachment-meta {
  min-width: 0;
  flex: 1;
}

.chat-composer-attachment-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--header-primary);
}

.chat-composer-attachment-subtitle {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-composer-attachment-remove {
  width: 26px;
  height: 26px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 7px;
  background: rgba(0, 0, 0, 0.24);
  color: var(--text-muted);
  cursor: pointer;
  line-height: 1;
  font-size: 18px;
  flex-shrink: 0;
}

.chat-composer-attachment-remove:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--interactive-hover);
}

@keyframes composer-attachment-shimmer {
  to { transform: translateX(100%); }
}

.chat-input-form {
  display: flex;
  align-items: flex-end;
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  padding: 6px 4px 6px 12px;
  transition: box-shadow 0.2s ease, transform 0.16s ease;
}

.chat-input-form:focus-within {
  box-shadow: 0 0 0 1px rgba(88, 101, 242, 0.42), 0 10px 18px rgba(0, 0, 0, 0.2);
  transform: translateY(-1px);
}
.chat-input-form textarea {
  flex: 1;
  padding: 8px 0;
  background: none;
  border: none;
  color: var(--text-normal);
  font-size: 16px;
  line-height: 1.35;
  font-family: var(--font-primary);
  outline: none;
  min-width: 0;
  min-height: 24px;
  max-height: 160px;
  overflow-y: auto;
  resize: none;
  white-space: pre-wrap;
  word-break: break-word;
}
.chat-input-form textarea::placeholder {
  color: var(--text-muted);
}
.send-btn {
  width: 40px;
  height: 40px;
  border: none;
  background: none;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  transition: color 0.1s;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}
.send-btn:hover { color: var(--bg-accent); }
.send-btn:active { color: var(--bg-accent); transform: scale(0.9); }

/* ── Members Sidebar ─────────────────────────────────── */
.members-sidebar {
  background: var(--bg-secondary);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  box-shadow: var(--scroll-shadow-top), var(--scroll-shadow-bottom);
}

.members-header {
  height: 48px;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 700;
  color: var(--header-secondary);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  box-shadow: 0 1px 0 rgba(0,0,0,0.15);
  flex-shrink: 0;
}

.members-header-actions {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.members-header-actions .control-btn {
  width: 28px;
  height: 28px;
}

.members-list {
  padding: 8px;
}

.member-category {
  padding: 16px 8px 4px;
  font-size: 12px;
  font-weight: 700;
  color: var(--channel-icon);
  text-transform: uppercase;
}

.member-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px;
  border-radius: var(--radius-sm);
  transition: background 0.12s, transform 0.16s ease, box-shadow 0.2s ease;
  min-height: 44px;
}
.member-item:hover {
  background: var(--bg-modifier-hover);
  transform: translateX(2px);
}
.member-item.speaking {
  background: rgba(35, 165, 90, 0.12);
  box-shadow: inset 0 0 0 1px rgba(35, 165, 90, 0.22);
}

.member-avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  background: var(--bg-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
  transform: scale(1);
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.member-item.speaking .member-avatar {
  transform: scale(1.08);
  border: 1px solid rgba(103, 226, 148, 0.8);
  box-shadow: 0 0 0 3px rgba(35, 165, 90, 0.2);
  animation: speaking-pulse 1.15s ease-in-out infinite;
}

.member-name {
  font-size: 15px;
  font-weight: 500;
  color: var(--channel-icon);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
  flex: 1;
}

.member-name-wrap {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1;
}

.member-owner-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #f6ca63;
  background: rgba(240, 178, 50, 0.14);
  border: 1px solid rgba(240, 178, 50, 0.45);
  flex-shrink: 0;
}

.member-owner-badge::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.member-media-actions {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.media-watch-btn {
  width: 24px;
  height: 24px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--interactive-normal);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.media-watch-btn:hover {
  background: var(--bg-modifier-hover);
  color: var(--interactive-hover);
}

.media-watch-btn.watching {
  color: var(--text-positive);
}

.media-watch-btn.available {
  color: #f0b232;
}

.tooltip-target {
  position: relative;
}

.tooltip-target::after {
  content: attr(data-tooltip);
  position: absolute;
  left: 50%;
  bottom: calc(100% + 8px);
  transform: translateX(-50%) translateY(4px);
  opacity: 0;
  pointer-events: none;
  white-space: nowrap;
  font-size: 11px;
  line-height: 1;
  color: #fff;
  background: rgba(17, 18, 20, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 6px;
  padding: 5px 7px;
  z-index: 320;
  transition: opacity 0.12s ease, transform 0.12s ease;
}

.tooltip-target:hover::after,
.tooltip-target:focus-visible::after {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.member-empty {
  text-align: center;
  color: var(--text-muted);
  padding: 20px;
  font-size: 14px;
}

/* ── Voice Bar ───────────────────────────────────────── */
.voice-bar {
  background: transparent;
  padding: 0;
  border-top: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  min-width: 0;
  margin-top: 1px;
}

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

.voice-status {
  display: flex;
  align-items: center;
  padding: 0 5px;
  gap: 5px;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-positive);
}

.voice-dot {
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
  background: var(--text-positive);
  animation: pulse 2s infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

#voice-channel-name {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.voice-disconnect {
  width: 28px;
  height: 28px;
  border: none;
  background: none;
  color: var(--text-danger);
  cursor: pointer;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.1s, color 0.1s;
  -webkit-tap-highlight-color: transparent;
}
.voice-disconnect:hover { background: rgba(242,63,67,0.1); }

/* ── Screen Share Overlay ────────────────────────────── */
.screen-share-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  z-index: 200;
  display: flex;
  flex-direction: column;
}
.screen-share-header {
  padding: 12px 20px;
  padding-top: calc(12px + var(--sat));
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-floating);
  color: var(--header-primary);
  font-weight: 600;
}
.screen-share-overlay > video {
  flex: 1;
  width: 100%;
  object-fit: contain;
  background: #000;
}

.media-stage-grid {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
  padding: 12px;
  overflow: auto;
}

.media-tile {
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.media-tile video {
  width: 100%;
  height: 220px;
  object-fit: cover;
  background: #000;
}

.media-tile-meta {
  padding: 8px 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
}

.media-kind {
  color: var(--text-muted);
  text-transform: uppercase;
  font-size: 11px;
}

.voice-settings-modal {
  position: fixed;
  inset: 0;
  z-index: 220;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 16px;
  padding-top: calc(16px + var(--sat));
  padding-bottom: calc(16px + var(--sab));
  animation: ui-overlay-fade 180ms ease;
  overflow: auto;
}

.voice-settings-card {
  width: 100%;
  max-width: 460px;
  max-height: min(86dvh, 860px);
  background: var(--bg-primary);
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 16px;
  animation: ui-modal-pop 210ms var(--ease-out-std);
  overflow-y: auto;
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.45);
}

.voice-settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  position: sticky;
  top: 0;
  z-index: 1;
  background: linear-gradient(to bottom, rgba(49, 51, 56, 0.98), rgba(49, 51, 56, 0.92));
  backdrop-filter: blur(2px);
  padding-bottom: 8px;
}

.voice-settings-header h3 {
  font-size: 15px;
  color: var(--header-primary);
}

.settings-row {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-normal);
  margin-bottom: 12px;
  min-width: 0;
}

.settings-row > span {
  flex: 1;
  min-width: 0;
}

.settings-row select {
  margin-left: 0;
  background: var(--bg-tertiary);
  color: var(--text-normal);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-sm);
  padding: 6px 8px;
  min-width: 0;
  width: 52%;
  max-width: 230px;
  min-height: 34px;
}

.settings-row input[type="color"] {
  margin-left: auto;
  width: 42px;
  height: 30px;
  border: none;
  padding: 0;
  background: transparent;
  cursor: pointer;
}

.settings-note {
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.35;
  margin-bottom: 12px;
}

.settings-chat-history-actions {
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.settings-chat-history-actions > button {
  min-height: 32px;
}

.settings-data-section {
  margin-bottom: 12px;
  padding: 10px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.03);
}

.settings-data-title {
  color: var(--header-primary);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-bottom: 8px;
}

#chat-local-data-usage {
  word-break: break-word;
}

#chat-history-status {
  min-height: 16px;
}

.avatar-preview {
  width: 100%;
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: #000;
  image-rendering: pixelated;
  margin-top: 6px;
}

#invite-link {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg-tertiary);
  color: var(--text-normal);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: var(--radius-sm);
}

#rename-modal-input {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg-tertiary);
  color: var(--text-normal);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: var(--radius-sm);
  outline: none;
}

#rename-modal-input:focus {
  border-color: rgba(88, 101, 242, 0.8);
  box-shadow: 0 0 0 2px rgba(88, 101, 242, 0.28);
}

.settings-webcam-row {
  justify-content: flex-start;
}

.webcam-test-video {
  width: 100%;
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: #000;
  margin-top: 8px;
}

@media (max-width: 768px) {
  .voice-settings-modal {
    padding: 10px;
    padding-top: calc(10px + var(--sat));
    padding-bottom: calc(10px + var(--sab));
  }

  .voice-settings-card {
    max-width: none;
    max-height: calc(100dvh - 20px - var(--sat) - var(--sab));
    padding: 14px;
    border-radius: 12px;
  }

  .settings-row {
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
  }

  .settings-row > span {
    flex: 1 1 100%;
  }

  .settings-row select,
  .settings-row input[type="text"],
  .settings-row input[type="number"] {
    width: 100%;
    max-width: none;
  }

  .settings-row input[type="color"] {
    margin-left: 0;
  }

  .settings-chat-history-actions > button {
    width: 100%;
  }
}

.boot-loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(8, 9, 12, 0.76);
  backdrop-filter: blur(6px);
}

.boot-loading-card {
  min-width: 280px;
  max-width: 420px;
  padding: 18px 20px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: linear-gradient(165deg, rgba(28, 31, 40, 0.96), rgba(16, 18, 24, 0.96));
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.45);
}

.boot-loading-spinner {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.22);
  border-top-color: var(--bg-accent);
  animation: adharc-spin 0.85s linear infinite;
  flex-shrink: 0;
}

.boot-loading-text {
  color: var(--header-primary);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.01em;
}

@keyframes adharc-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@keyframes speaking-pulse {
  0% {
    filter: brightness(1);
  }
  50% {
    filter: brightness(1.14);
  }
  100% {
    filter: brightness(1);
  }
}

@keyframes ui-screen-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes ui-surface-rise {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes ui-section-reveal {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes ui-message-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes ui-popover-in {
  from {
    opacity: 0;
    transform: translateY(-4px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes ui-overlay-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes ui-modal-pop {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.context-menu {
  position: fixed;
  z-index: 260;
  min-width: 220px;
  background: var(--bg-floating);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-sm);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  padding: 8px;
}

.context-item {
  padding: 8px;
  border-radius: var(--radius-sm);
  color: var(--text-normal);
  font-size: 13px;
}

button.context-item {
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  cursor: pointer;
}

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

.context-item input[type="range"] {
  width: 100%;
}

.media-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 210;
}

.media-card {
  position: absolute;
  width: 320px;
  height: 200px;
  min-width: 200px;
  min-height: 140px;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: rgba(0, 0, 0, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.45);
  pointer-events: auto;
  display: flex;
  flex-direction: column;
}

.media-card video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  flex: 1;
  background: #000;
  transform-origin: center center;
  transition: transform 0.08s linear;
}

.media-card[data-kind="screen"] video {
  object-fit: contain;
}

.media-card[data-kind="avatar"] video {
  object-fit: contain;
  image-rendering: pixelated;
}

.media-video-wrap {
  position: relative;
  flex: 1;
  overflow: hidden;
  background: #000;
  touch-action: none;
}

.media-video-wrap.zoomed {
  cursor: grab;
}

.media-video-wrap.zoomed:active {
  cursor: grabbing;
}

.media-card-header {
  cursor: move;
  user-select: none;
  touch-action: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  padding: 6px 8px;
  background: rgba(0, 0, 0, 0.42);
}

.media-card-header-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.media-card-kind {
  text-transform: uppercase;
  color: var(--text-muted);
  font-size: 10px;
}

.media-card-close {
  width: 18px;
  height: 18px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.media-card-settings {
  width: 18px;
  height: 18px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.media-card-close:hover {
  background: rgba(255, 255, 255, 0.16);
  color: var(--interactive-active);
}

.media-card-settings:hover {
  background: rgba(255, 255, 255, 0.16);
  color: var(--interactive-active);
}

.media-zoom-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(0, 0, 0, 0.45);
}

.media-zoom-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
}

.media-zoom-slider {
  flex: 1;
}

.media-zoom-reset {
  border: none;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-normal);
  padding: 3px 7px;
  font-size: 11px;
  cursor: pointer;
}

.media-zoom-reset:hover {
  background: rgba(255, 255, 255, 0.2);
}

.media-card-resizer {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 14px;
  height: 14px;
  cursor: nwse-resize;
  touch-action: none;
  background: linear-gradient(135deg, transparent 0%, transparent 40%, rgba(255,255,255,0.55) 40%, rgba(255,255,255,0.55) 48%, transparent 48%, transparent 62%, rgba(255,255,255,0.55) 62%, rgba(255,255,255,0.55) 70%, transparent 70%);
}

.media-dock {
  position: relative;
  width: 100%;
  height: var(--media-dock-height);
  min-height: 110px;
  max-height: 52vh;
  border-bottom: 1px solid rgba(255,255,255,0.12);
  background: rgba(0, 0, 0, 0.18);
  flex-shrink: 0;
}

.media-dock-grid {
  width: 100%;
  height: calc(100% - 10px);
  padding: 8px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  grid-auto-rows: minmax(110px, 160px);
  align-items: start;
  gap: 8px;
  overflow: auto;
}

.media-dock .media-card {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 0;
}

.media-dock .media-card-header {
  cursor: default;
}

.media-dock .media-card-resizer {
  display: none;
}

.media-dock .media-zoom-controls {
  padding: 4px 6px;
}

.media-dock-resizer {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 10px;
  cursor: row-resize;
  background: rgba(255,255,255,0.08);
}

.media-dock-resizer:hover {
  background: rgba(255,255,255,0.14);
}

@media (min-width: 1101px) {
  .mobile-members-btn {
    display: none !important;
  }
}

/* ── Scrollbar ───────────────────────────────────────── */
::-webkit-scrollbar {
  width: 8px;
}
::-webkit-scrollbar-track {
  background: var(--scrollbar-thin-track);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thin-thumb);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: #232428;
}

/* ── Theme Dropdown ─────────────────────────────────── */
.theme-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 8px;
  width: 200px;
  background: var(--bg-floating);
  border-radius: var(--radius-md);
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
  z-index: 400;
  overflow: hidden;
  padding: 6px;
}

.theme-dropdown.open {
  display: block;
}

.theme-dropdown-header {
  padding: 8px 10px 6px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--header-secondary);
  letter-spacing: 0.02em;
}

.theme-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--interactive-normal);
  font-size: 14px;
  font-weight: 500;
  transition: background 0.12s, color 0.12s, transform 0.14s ease;
  -webkit-tap-highlight-color: transparent;
}

.theme-option:hover {
  background: var(--bg-modifier-hover);
  color: var(--interactive-hover);
  transform: translateX(2px);
}

.theme-option.active {
  color: var(--interactive-active);
}

.theme-swatch {
  width: 16px;
  height: 16px;
  border-radius: var(--radius-full);
  flex-shrink: 0;
  border: 2px solid rgba(255,255,255,0.1);
}

.theme-check {
  margin-left: auto;
  font-size: 14px;
  color: var(--text-positive);
  display: none;
}

.theme-option.active .theme-check {
  display: inline;
}

.download-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--interactive-normal);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  transition: background 0.12s, color 0.12s, transform 0.14s ease;
}

.download-option:hover {
  background: var(--bg-modifier-hover);
  color: var(--interactive-hover);
  transform: translateX(2px);
}

/* ═══════════════════════════════════════════════════════
   RESPONSIVE — Tablet
   ═══════════════════════════════════════════════════════ */
@media (max-width: 1100px) {
  .desktop-sidebar-toggle {
    display: none !important;
  }

  .app-layout {
    grid-template-columns: 72px 240px 1fr;
  }

  /* Members sidebar becomes a right-side drawer on tablet */
  .members-sidebar {
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: var(--drawer-width);
    z-index: 150;
    transform: translateX(100%);
    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
    will-change: transform;
    padding-top: var(--sat);
  }
  .members-sidebar.drawer-open {
    transform: translateX(0);
  }

  .drawer-backdrop {
    display: block;
    pointer-events: none;
  }
  .drawer-backdrop.active {
    pointer-events: auto;
  }

  .mobile-members-btn {
    display: flex;
  }

  .mobile-back-servers-btn {
    display: flex;
  }

  .members-sidebar .mobile-close-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: none;
    background: none;
    color: var(--interactive-normal);
    cursor: pointer;
    border-radius: var(--radius-sm);
    flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
  }
  .members-sidebar .mobile-close-btn:active {
    color: var(--interactive-active);
  }
}

/* ═══════════════════════════════════════════════════════
   RESPONSIVE — Mobile (<= 768px)
   ═══════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  /* Pin the app screen to the viewport; JS will override
     height when the soft-keyboard opens via visualViewport */
  #app-screen {
    position: fixed !important;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    height: 100dvh;
    height: 100%;           /* fallback */
    overflow: hidden;
  }

  /* Grid fills whatever height #app-screen gives it */
  .app-layout {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr;
    position: relative;
    overflow: hidden;
    height: 100%;            /* inherit from parent, not viewport */
  }

  /* Hide server rail on mobile */
  .server-rail { display: none; }

  /* Main content fills the single grid cell */
  .main-content {
    height: 100%;
    min-height: 0;
    max-height: none;        /* parent already constrains us */
  }

  /* ── Channel Sidebar as Left Drawer ── */
  .channel-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--drawer-width);
    z-index: 150;
    transform: translateX(-100%);
    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
    will-change: transform;
    padding-top: var(--sat);
  }
  .channel-sidebar.drawer-open {
    transform: translateX(0);
  }
  .sidebar-music-player {
    width: 100%;
    margin: 0 0 6px;
    padding-left: 12px;
    padding-right: 12px;
  }
  .user-panel {
    padding: 12px;
  }

  /* ── Members Sidebar as Right Drawer ── */
  .members-sidebar {
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: var(--drawer-width);
    z-index: 150;
    transform: translateX(100%);
    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
    will-change: transform;
    padding-top: var(--sat);
  }
  .members-sidebar.drawer-open {
    transform: translateX(0);
  }

  /* Backdrop visible on mobile when drawers are open */
  .drawer-backdrop {
    display: block;
    pointer-events: none;
  }
  .drawer-backdrop.active {
    pointer-events: auto;
  }

  /* Show mobile buttons */
  .mobile-menu-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: none;
    background: none;
    color: var(--interactive-normal);
    cursor: pointer;
    border-radius: var(--radius-sm);
    flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
  }
  .mobile-menu-btn:active { color: var(--interactive-active); }

  .mobile-members-btn {
    display: flex;
  }

  .mobile-close-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: none;
    background: none;
    color: var(--interactive-normal);
    cursor: pointer;
    border-radius: var(--radius-sm);
    flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
  }
  .mobile-close-btn:active { color: var(--interactive-active); }

  /* Chat header — with safe area */
  .chat-header {
    padding-top: var(--sat);
    height: calc(48px + var(--sat));
    padding-left: 8px;
    padding-right: 8px;
  }

  .chat-connection-indicator {
    max-width: 44vw;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  /* Chat input — safe area bottom */
  .chat-input-container {
    padding: 6px 8px 8px;
    padding-bottom: calc(8px + var(--sab));
  }

  /* Chat messages — scroll padding for input area */
  .chat-messages {
    padding: 12px 12px;
  }

  /* Welcome text smaller on mobile */
  .chat-welcome h3 {
    font-size: 20px;
  }

  /* Voice bar — on mobile, break out of the sidebar drawer
     and position at the bottom of the viewport */
  .voice-bar {
    position: static;
    width: auto;
    padding: 0;
    z-index: auto;
  }

  /* When voice bar is visible, push chat input up */
  body.voice-active .chat-input-container {
    padding-bottom: calc(8px + var(--sab));
    margin-bottom: 0;
  }

  /* When keyboard is open, strip safe-area bottom padding */
  body.keyboard-open .chat-input-container {
    padding-bottom: 8px;
  }
  /* body.keyboard-open .voice-bar {
    padding-bottom: 8px;
  } */
  /* Keep voice-bar clearance even with keyboard open */
  body.keyboard-open.voice-active .chat-input-container {
    padding-bottom: 8px;
  }

  /* Message layout: tighter on mobile */
  .chat-msg {
    gap: 10px;
  }
  .msg-avatar {
    width: 32px;
    height: 32px;
    font-size: 13px;
  }
  .msg-author { font-size: 14px; }
  .msg-content { font-size: 15px; }
  .msg-time { font-size: 10px; }

  /* Auth screens — edge to edge on mobile */
  .auth-container {
    border-radius: var(--radius-lg);
    padding: 24px;
  }

  .server-select-container {
    border-radius: var(--radius-lg);
    padding: 24px;
  }

  .server-action-row {
    grid-template-columns: 1fr;
  }

  .server-action-row input[type="text"] {
    min-width: 0;
  }

  .server-action-row button {
    width: 100%;
  }
}

/* ═══════════════════════════════════════════════════════
   RESPONSIVE — Small phones (<= 380px)
   ═══════════════════════════════════════════════════════ */
@media (max-width: 380px) {
  :root {
    --drawer-width: 85vw;
  }

  .auth-container,
  .server-select-container {
    padding: 20px;
  }

  .auth-logo h1 {
    font-size: 20px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}
