/* PulseChat presentation layer — no external fonts or assets. */

/* ---------------------------------------------------------------- tokens */
:root,
html[data-theme="dark"],
body[data-theme="dark"] {
  color-scheme: dark;
  --font-ui: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;

  --bg-app: #313338;
  --bg-rail: #1e1f22;
  --bg-sidebar: #2b2d31;
  --bg-main: #313338;
  --bg-floating: #111214;
  --bg-input: #1e1f22;
  --bg-hover: #35373c;
  --bg-active: #404249;
  --bg-selected: #404249;
  --bg-message-hover: #2e3035;
  --bg-code: #232428;
  --bg-badge: #f23f43;

  --text-normal: #dbdee1;
  --text-muted: #949ba4;
  --text-faint: #6d6f78;
  --text-bright: #f2f3f5;
  --text-link: #00a8fc;

  --brand: #5865f2;
  --brand-hover: #4752c4;
  --brand-soft: rgba(88, 101, 242, 0.18);
  --green: #23a55a;
  --green-soft: rgba(35, 165, 90, 0.18);
  --yellow: #f0b232;
  --red: #f23f43;
  --red-hover: #da373c;
  --red-soft: rgba(242, 63, 67, 0.15);
  --orange: #d83c42;

  --border: #3f4147;
  --border-subtle: rgba(255, 255, 255, 0.06);
  --divider: #3f4147;
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.24);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 18px 48px rgba(0, 0, 0, 0.48);
  --scrim: rgba(0, 0, 0, 0.62);
  --mention-bg: rgba(88, 101, 242, 0.12);
  --mention-border: rgba(88, 101, 242, 0.65);

  --radius-xs: 3px;
  --radius-sm: 5px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 18px;
  --radius-pill: 999px;

  --rail-width: 72px;
  --sidebar-width: 240px;
  --members-width: 240px;
  --header-height: 48px;

  --z-rail: 30;
  --z-sidebar: 25;
  --z-panel: 40;
  --z-overlay: 60;
  --z-modal: 80;
  --z-toast: 90;
}

html[data-theme="midnight"],
body[data-theme="midnight"] {
  color-scheme: dark;
  --bg-app: #000000;
  --bg-rail: #050506;
  --bg-sidebar: #09090b;
  --bg-main: #000000;
  --bg-floating: #0b0b0e;
  --bg-input: #08080a;
  --bg-hover: #151518;
  --bg-active: #1d1d22;
  --bg-selected: #222228;
  --bg-message-hover: #101013;
  --bg-code: #121216;
  --text-normal: #d7d9dd;
  --text-muted: #8a8d95;
  --text-faint: #61636a;
  --text-bright: #ffffff;
  --border: #202126;
  --border-subtle: rgba(255, 255, 255, 0.045);
  --divider: #1b1c20;
  --shadow-sm: 0 2px 10px rgba(0, 0, 0, 0.8);
  --shadow-md: 0 10px 30px rgba(0, 0, 0, 0.9);
  --shadow-lg: 0 20px 56px rgba(0, 0, 0, 0.95);
  --scrim: rgba(0, 0, 0, 0.8);
  --mention-bg: rgba(88, 101, 242, 0.16);
}

html[data-theme="ash"],
body[data-theme="ash"] {
  color-scheme: dark;
  --bg-app: #3a3c3f;
  --bg-rail: #25272a;
  --bg-sidebar: #313336;
  --bg-main: #3a3c3f;
  --bg-floating: #1c1d1f;
  --bg-input: #25272a;
  --bg-hover: #3e4044;
  --bg-active: #4a4c51;
  --bg-selected: #4a4c51;
  --bg-message-hover: #36383b;
  --bg-code: #2a2c2f;
  --text-normal: #dfe1e3;
  --text-muted: #a3a6ab;
  --text-faint: #787b80;
  --text-bright: #ffffff;
  --border: #4b4d52;
  --border-subtle: rgba(255, 255, 255, 0.05);
  --divider: #4b4d52;
  --brand: #7b84f5;
  --brand-hover: #6973e8;
  --mention-bg: rgba(123, 132, 245, 0.14);
}

html[data-theme="light"],
body[data-theme="light"] {
  color-scheme: light;
  --bg-app: #ffffff;
  --bg-rail: #f2f3f5;
  --bg-sidebar: #f7f8fa;
  --bg-main: #ffffff;
  --bg-floating: #ffffff;
  --bg-input: #ffffff;
  --bg-hover: #e8eaee;
  --bg-active: #dde0e6;
  --bg-selected: #e3e6ec;
  --bg-message-hover: #f5f6f8;
  --bg-code: #f0f1f4;
  --text-normal: #2e3338;
  --text-muted: #6b7280;
  --text-faint: #9aa1ac;
  --text-bright: #111418;
  --text-link: #0068d9;
  --brand: #5865f2;
  --brand-hover: #4752c4;
  --brand-soft: rgba(88, 101, 242, 0.1);
  --green: #1a7f43;
  --red: #d32f34;
  --red-soft: rgba(211, 47, 52, 0.1);
  --border: #d8dbe0;
  --border-subtle: rgba(0, 0, 0, 0.05);
  --divider: #e1e4e8;
  --shadow-sm: 0 2px 8px rgba(20, 30, 50, 0.1);
  --shadow-md: 0 8px 24px rgba(20, 30, 50, 0.14);
  --shadow-lg: 0 18px 48px rgba(20, 30, 50, 0.2);
  --scrim: rgba(18, 22, 30, 0.45);
  --mention-bg: rgba(88, 101, 242, 0.08);
  --mention-border: rgba(88, 101, 242, 0.5);
}

html[data-spacing="cozy"],
body[data-spacing="cozy"] {
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --channel-height: 34px;
  --message-gap: 16px;
  --message-avatar: 40px;
  --message-pad-y: 8px;
  --rail-gap: 8px;
  --list-pad: 8px;
}

html[data-spacing="compact"],
body[data-spacing="compact"] {
  --space-1: 2px;
  --space-2: 5px;
  --space-3: 8px;
  --space-4: 11px;
  --space-5: 14px;
  --space-6: 17px;
  --channel-height: 28px;
  --message-gap: 7px;
  --message-avatar: 32px;
  --message-pad-y: 4px;
  --rail-gap: 5px;
  --list-pad: 5px;
}

/* ------------------------------------------------------------------ base */
*,
*::before,
*::after { box-sizing: border-box; }

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
}

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.4;
  color: var(--text-normal);
  background: var(--bg-app);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overscroll-behavior: none;
}

body.modal-open { overflow: hidden; }

button,
input,
textarea,
select { font: inherit; color: inherit; }

button {
  border: 0;
  margin: 0;
  padding: 0;
  background: none;
  cursor: pointer;
}

button:disabled { cursor: not-allowed; opacity: 0.5; }

button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

a { color: var(--text-link); text-decoration: none; }
a:hover { text-decoration: underline; }

svg {
  display: block;
  width: 18px;
  height: 18px;
  flex: none;
  fill: currentColor;
  pointer-events: none;
}

button svg,
.icon-button svg,
.mobile-tab svg,
.composer-tool svg,
.voice-control svg { width: 18px; height: 18px; }

img { max-width: 100%; display: block; }

[hidden],
.hidden { display: none !important; }

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

::selection { background: var(--brand); color: #fff; }

:where(.scrollable, .message-list, .channel-list, .member-list-scroll, .rail-scroll, .dm-list, .panel-body, .home-content-body) {
  scrollbar-width: thin;
  scrollbar-color: var(--bg-rail) transparent;
}

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg-rail); border-radius: var(--radius-pill); }
::-webkit-scrollbar-thumb:hover { background: var(--bg-active); }

/* --------------------------------------------------------------- helpers */
.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); }
.bright { color: var(--text-bright); }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.row { display: flex; align-items: center; gap: var(--space-2); min-width: 0; }
.col { display: flex; flex-direction: column; min-width: 0; }
.spacer { flex: 1 1 auto; }
.divider { height: 1px; background: var(--divider); margin: var(--space-3) 0; }

.badge,
.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 18px;
  padding: 1px 7px;
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.2;
  background: var(--bg-active);
  color: var(--text-normal);
}

.badge--brand,
.chip--brand { background: var(--brand); color: #fff; }
.badge--green { background: var(--green); color: #fff; }
.badge--red { background: var(--red); color: #fff; }

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: 220px;
  padding: var(--space-6);
  text-align: center;
  color: var(--text-muted);
}

.empty-state-icon {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--bg-hover);
  color: var(--brand);
  font-size: 28px;
  font-weight: 800;
}

.empty-state h3 { margin: var(--space-2) 0 0; color: var(--text-bright); font-size: 17px; }
.empty-state p { margin: 0; max-width: 360px; font-size: 14px; }

.primary-button,
.secondary-button,
.danger-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: 38px;
  padding: 0 var(--space-4);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 700;
  transition: background 120ms ease, transform 120ms ease, border-color 120ms ease;
}

.primary-button { background: var(--brand); color: #fff; }
.primary-button:hover:not(:disabled) { background: var(--brand-hover); }
.primary-button:active:not(:disabled) { transform: translateY(1px); }

.secondary-button {
  background: var(--bg-hover);
  color: var(--text-bright);
  border: 1px solid var(--border-subtle);
}
.secondary-button:hover:not(:disabled) { background: var(--bg-active); }

.danger-button { background: var(--red); color: #fff; }
.danger-button:hover:not(:disabled) { background: var(--red-hover); }

.primary-button.small,
.secondary-button.small,
.danger-button.small { min-height: 30px; padding: 0 var(--space-3); font-size: 12px; }

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  flex: none;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  transition: background 120ms ease, color 120ms ease;
}
.icon-button:hover { background: var(--bg-hover); color: var(--text-bright); }
.icon-button.danger { color: var(--red); }

.link-button {
  color: var(--text-link);
  font-size: 12px;
  font-weight: 600;
}
.link-button:hover { text-decoration: underline; }

[data-tooltip] { position: relative; }
[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  z-index: var(--z-toast);
  left: 50%;
  bottom: calc(100% + 8px);
  transform: translateX(-50%) translateY(4px);
  max-width: 220px;
  padding: 6px 9px;
  border-radius: var(--radius-sm);
  background: var(--bg-floating);
  color: var(--text-bright);
  box-shadow: var(--shadow-md);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 100ms ease, transform 100ms ease;
}
[data-tooltip]:hover::after,
[data-tooltip]:focus-visible::after { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ------------------------------------------------------------------ auth */
.auth-view {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  overflow: auto;
  padding: max(24px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom));
  background: var(--bg-app);
}

.auth-backdrop { position: fixed; inset: 0; overflow: hidden; pointer-events: none; }
.auth-orb {
  position: absolute;
  width: 46vw;
  height: 46vw;
  min-width: 360px;
  min-height: 360px;
  border-radius: 50%;
  filter: blur(70px);
  opacity: 0.28;
}
.auth-orb--one { top: -18vw; left: -12vw; background: #5865f2; }
.auth-orb--two { right: -16vw; bottom: -20vw; background: #a56cf6; }
.auth-grid {
  position: absolute;
  inset: 0;
  opacity: 0.18;
  background-image: linear-gradient(var(--border-subtle) 1px, transparent 1px), linear-gradient(90deg, var(--border-subtle) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(circle at center, #000 10%, transparent 72%);
}

.auth-card {
  position: relative;
  z-index: 1;
  width: min(100%, 440px);
  padding: var(--space-6);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  background: var(--bg-sidebar);
  box-shadow: var(--shadow-lg);
}

.auth-brand { display: flex; align-items: center; gap: var(--space-4); margin-bottom: var(--space-6); }
.brand-mark { flex: none; }
.brand-mark svg { width: 48px; height: 48px; }
.auth-brand-copy h1 { margin: 0; font-size: 24px; line-height: 1.15; letter-spacing: -0.02em; color: var(--text-bright); }
.auth-brand-copy p { margin: 4px 0 0; font-size: 13px; color: var(--text-muted); }

.auth-modes {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  margin-bottom: var(--space-5);
  border-radius: var(--radius-md);
  background: var(--bg-input);
}
.auth-mode {
  min-height: 36px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 700;
  transition: background 120ms ease, color 120ms ease;
}
.auth-mode:hover { color: var(--text-bright); }
.auth-mode.active { background: var(--bg-active); color: var(--text-bright); box-shadow: var(--shadow-sm); }

.auth-form { display: flex; flex-direction: column; gap: var(--space-3); }
.form-field { display: flex; flex-direction: column; gap: 6px; }
.form-field label { font-size: 12px; font-weight: 800; letter-spacing: 0.02em; color: var(--text-muted); text-transform: uppercase; }
.label-row { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); }
.label-row label { margin-right: auto; }
.form-field input {
  width: 100%;
  min-height: 42px;
  padding: 0 var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  color: var(--text-bright);
  font-size: 14px;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}
.form-field input::placeholder { color: var(--text-faint); }
.form-field input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); outline: none; }
.form-field input[type="date"] { color-scheme: inherit; }

.auth-hint { margin: 0; min-height: 18px; font-size: 12px; color: var(--text-muted); }
.auth-error {
  margin: 0;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--red);
  border-radius: var(--radius-sm);
  background: var(--red-soft);
  color: var(--text-bright);
  font-size: 13px;
}
.auth-submit { width: 100%; margin-top: var(--space-1); }
.auth-back { width: 100%; }

.recovery-codes-box {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin-top: var(--space-5);
  padding: var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-input);
}
.recovery-codes-box h2 { margin: 0; font-size: 15px; color: var(--text-bright); }
.recovery-codes-box p { margin: 0; font-size: 12px; color: var(--text-muted); }
.recovery-code-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  padding: var(--space-3);
  border-radius: var(--radius-sm);
  background: var(--bg-code);
  color: var(--text-bright);
  font-family: var(--font-mono);
  font-size: 12px;
  word-break: break-all;
}

/* ------------------------------------------------------------ app shell */
.app-view {
  position: fixed;
  inset: 0;
  z-index: 20;
  overflow: hidden;
  background: var(--bg-app);
}

.app-shell {
  display: flex;
  width: 100%;
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  background: var(--bg-app);
}

.server-rail {
  position: relative;
  z-index: var(--z-rail);
  width: var(--rail-width);
  flex: 0 0 var(--rail-width);
  background: var(--bg-rail);
  border-right: 1px solid var(--border-subtle);
}

.rail-scroll {
  height: 100%;
  overflow-x: hidden;
  overflow-y: auto;
  padding: var(--space-3) var(--space-2) calc(var(--space-6) + env(safe-area-inset-bottom));
  scrollbar-width: none;
}
.rail-scroll::-webkit-scrollbar { display: none; }

.server-list {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--rail-gap);
}

.server-button {
  position: relative;
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  flex: none;
  border-radius: var(--radius-xl);
  background: var(--bg-sidebar);
  color: var(--text-bright);
  font-size: 15px;
  font-weight: 800;
  transition: border-radius 160ms ease, background 160ms ease, color 160ms ease, transform 120ms ease;
}
.server-button:hover { border-radius: 16px; background: var(--brand); color: #fff; transform: translateY(-1px); }
.server-button:active { transform: translateY(0); }
.server-button.active,
.server-button.selected { border-radius: 16px; background: var(--brand); color: #fff; }
.server-button.unread { border-radius: 16px; }
.server-button svg { width: 22px; height: 22px; }
.server-button.server-home svg,
.server-button.server-add svg,
.server-button.server-explore svg { width: 22px; height: 22px; }
.server-button.server-add,
.server-button.server-explore { color: var(--green); background: var(--bg-sidebar); }
.server-button.server-add:hover,
.server-button.server-explore:hover { background: var(--green); color: #fff; }

.server-button .server-avatar,
.server-button .server-icon-image {
  width: 100%;
  height: 100%;
  border-radius: inherit;
  object-fit: cover;
}

.server-button::before {
  content: "";
  position: absolute;
  left: -12px;
  top: 50%;
  width: 4px;
  height: 0;
  border-radius: 0 4px 4px 0;
  background: var(--text-bright);
  transform: translateY(-50%);
  transition: height 140ms ease;
}
.server-button:hover::before { height: 20px; }
.server-button.active::before,
.server-button.unread::before { height: 40px; }
.server-button.active::before { height: 40px; }

.unread-pill,
.mention-badge,
.server-pill {
  position: absolute;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border: 3px solid var(--bg-rail);
  border-radius: var(--radius-pill);
  background: var(--text-bright);
  color: #111214;
  font-size: 10px;
  font-weight: 800;
  line-height: 1;
  pointer-events: none;
}
.unread-pill,
.server-pill { left: -12px; top: 50%; transform: translateY(-50%); height: 8px; min-width: 8px; padding: 0; border-width: 2px; }
.mention-badge { right: -4px; bottom: -3px; background: var(--bg-badge); color: #fff; }

.rail-separator { width: 32px; height: 2px; margin: 2px 0; border-radius: 2px; background: var(--border); }

.server-folder {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  width: 100%;
}
.folder-button {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: var(--radius-xl);
  background: var(--bg-sidebar);
  color: var(--green);
  transition: background 140ms ease, color 140ms ease, border-radius 140ms ease;
}
.folder-button:hover,
.server-folder.open .folder-button { background: var(--green); color: #fff; border-radius: 16px; }
.folder-name { max-width: 56px; font-size: 10px; font-weight: 700; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.folder-content { display: flex; flex-direction: column; align-items: center; gap: var(--rail-gap); padding: var(--space-2) 0; }
.server-folder.collapsed .folder-content { display: none; }
.folder-count { color: var(--text-faint); font-size: 10px; }

.channel-sidebar {
  position: relative;
  z-index: var(--z-sidebar);
  display: flex;
  flex-direction: column;
  width: var(--sidebar-width);
  flex: 0 0 var(--sidebar-width);
  min-width: 0;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-subtle);
}

.server-header {
  display: flex;
  align-items: center;
  min-height: var(--header-height);
  height: var(--header-height);
  flex: none;
  padding: 0 var(--space-3);
  box-shadow: 0 1px 0 var(--border-subtle), 0 2px 6px rgba(0, 0, 0, 0.12);
}
.server-header-title {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  min-width: 0;
  min-height: 34px;
  padding: 0 var(--space-2);
  border-radius: var(--radius-sm);
  font-weight: 800;
  color: var(--text-bright);
  text-align: left;
}
.server-header-title:hover { background: var(--bg-hover); }
.server-header-title svg { color: var(--text-muted); }
.server-title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.channel-list {
  flex: 1 1 auto;
  min-height: 0;
  padding: var(--space-3) var(--space-2) var(--space-2);
  overflow-x: hidden;
  overflow-y: auto;
}
.sidebar-placeholder { padding: var(--space-3); color: var(--text-faint); font-size: 13px; }

.channel-category { margin-bottom: var(--space-3); }
.category-header {
  display: flex;
  align-items: center;
  gap: 4px;
  width: 100%;
  min-height: 24px;
  padding: 0 var(--space-1);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}
.category-header:hover { color: var(--text-bright); }
.category-arrow {
  width: 12px;
  height: 12px;
  transition: transform 140ms ease;
}
.channel-category.collapsed .category-arrow { transform: rotate(-90deg); }
.category-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: left; }
.category-actions { display: flex; align-items: center; gap: 2px; opacity: 0; }
.category-header:hover .category-actions,
.category-header:focus-visible .category-actions { opacity: 1; }
.category-actions .icon-button { width: 20px; height: 20px; }
.category-actions svg { width: 14px; height: 14px; }
.channel-category.collapsed .category-channels { display: none; }
.category-channels { display: flex; flex-direction: column; gap: 2px; margin-top: 2px; }

.channel {
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  min-height: var(--channel-height);
  padding: 0 var(--space-2);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 15px;
  font-weight: 600;
  text-align: left;
}
.channel:hover { background: var(--bg-hover); color: var(--text-normal); }
.channel.active,
.channel.selected,
.channel[aria-selected="true"] { background: var(--bg-selected); color: var(--text-bright); }
.channel.unread { color: var(--text-bright); font-weight: 700; }
.channel.unread::before {
  content: "";
  position: absolute;
  left: -8px;
  top: 50%;
  width: 4px;
  height: 8px;
  border-radius: 0 4px 4px 0;
  background: var(--text-bright);
  transform: translateY(-50%);
}
.channel-icon { width: 18px; height: 18px; flex: none; color: var(--text-faint); }
.channel.active .channel-icon,
.channel.unread .channel-icon { color: var(--text-muted); }
.channel-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.channel-meta { display: flex; align-items: center; gap: 4px; flex: none; }
.channel-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: var(--radius-pill);
  background: var(--bg-badge);
  color: #fff;
  font-size: 10px;
  font-weight: 800;
}
.channel-actions { display: flex; align-items: center; gap: 2px; opacity: 0; }
.channel:hover .channel-actions { opacity: 1; }
.channel-actions .icon-button { width: 22px; height: 22px; }
.channel-actions svg { width: 14px; height: 14px; }
.channel.announcement .channel-icon { color: var(--yellow); }
.channel.voice .channel-icon { color: var(--green); }
.channel.forum .channel-icon,
.channel.stage .channel-icon { color: var(--brand); }
.channel.locked .channel-icon { color: var(--text-faint); }
.channel.nsfw .channel-name { text-decoration: underline dotted var(--red); text-underline-offset: 3px; }

.voice-participant {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 34px;
  margin: 2px 8px 2px 26px;
  padding: 4px 6px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 13px;
}
.voice-participant:hover { background: var(--bg-hover); }
.voice-participant .avatar { width: 24px; height: 24px; font-size: 10px; }
.voice-participant.speaking .avatar { box-shadow: 0 0 0 2px var(--green); }
.voice-participant-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.voice-state-icons { display: flex; gap: 4px; color: var(--red); }
.voice-state-icons svg { width: 14px; height: 14px; }

.voice-dock {
  flex: none;
  margin: 0 var(--space-2) var(--space-2);
  padding: var(--space-2);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: var(--bg-input);
}
.voice-dock-header { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); }
.voice-dock-title { color: var(--green); font-size: 12px; font-weight: 800; }
.voice-dock-body { display: flex; flex-direction: column; max-height: 180px; overflow-y: auto; margin-top: var(--space-1); }
.voice-dock-controls { display: flex; align-items: center; gap: 4px; margin-top: var(--space-2); }
.voice-control {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
}
.voice-control:hover { background: var(--bg-hover); color: var(--text-bright); }
.voice-control.active,
.voice-control.muted { color: var(--red); background: var(--red-soft); }

.user-bar {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 52px;
  flex: none;
  padding: 0 var(--space-2);
  background: var(--bg-rail);
}
.user-avatar-button {
  position: relative;
  flex: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
}
.user-avatar-button .avatar { width: 32px; height: 32px; }
.user-avatar-button .presence-dot { position: absolute; right: -2px; bottom: -2px; }
.user-bar-name {
  display: flex;
  flex: 1;
  flex-direction: column;
  align-items: flex-start;
  min-width: 0;
  padding: 2px 4px;
  border-radius: var(--radius-sm);
  text-align: left;
}
.user-bar-name:hover { background: var(--bg-hover); }
.user-display-name { max-width: 100%; color: var(--text-bright); font-size: 13px; font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-status { max-width: 100%; color: var(--text-muted); font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-bar-actions { display: flex; align-items: center; gap: 1px; flex: none; }
.user-bar-actions .icon-button { width: 28px; height: 28px; }

.avatar {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  flex: none;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
  overflow: hidden;
  object-fit: cover;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar--user { width: 32px; height: 32px; }
.presence-dot {
  display: inline-block;
  width: 12px;
  height: 12px;
  border: 3px solid var(--bg-rail);
  border-radius: 50%;
  background: var(--text-faint);
}
.presence-online { background: var(--green); }
.presence-idle { background: var(--yellow); }
.presence-dnd { background: var(--red); }
.presence-offline,
.presence-invisible { background: var(--text-faint); }
.presence-streaming { background: #9146ff; }

/* -------------------------------------------------------------- main view */
.main-view {
  position: relative;
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-width: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg-main);
}
.view { display: flex; flex: 1 1 auto; min-height: 0; min-width: 0; flex-direction: column; }

/* Home */
.home-view { flex-direction: row; }
.home-sidebar {
  display: flex;
  flex-direction: column;
  width: var(--sidebar-width);
  flex: 0 0 var(--sidebar-width);
  min-width: 0;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-subtle);
}
.home-sidebar-header { flex: none; padding: var(--space-3); box-shadow: 0 1px 0 var(--border-subtle); }
.home-search {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  min-height: 34px;
  padding: 0 var(--space-2);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  color: var(--text-muted);
  font-size: 12px;
  text-align: left;
}
.home-search:hover { color: var(--text-bright); }
.home-nav { display: flex; flex-direction: column; padding: var(--space-2); gap: 2px; }
.home-nav-item {
  display: flex;
  align-items: center;
  min-height: 34px;
  padding: 0 var(--space-2);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 700;
}
.home-nav-item:hover { background: var(--bg-hover); color: var(--text-bright); }
.home-nav-item.active { background: var(--bg-selected); color: var(--text-bright); }
.home-nav-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-2) var(--space-3);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}
.dm-list { flex: 1 1 auto; min-height: 0; padding: 0 var(--space-2) var(--space-3); overflow-y: auto; }
.dm-row,
.friend-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  min-height: 42px;
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
  text-align: left;
}
.dm-row:hover,
.friend-row:hover { background: var(--bg-hover); }
.dm-row.active { background: var(--bg-selected); }
.dm-row .avatar,
.friend-row .avatar { width: 32px; height: 32px; }
.dm-name,
.friend-name { flex: 1; min-width: 0; color: var(--text-normal); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dm-subtext,
.friend-subtext { color: var(--text-muted); font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.unread-dot { width: 8px; height: 8px; flex: none; border-radius: 50%; background: var(--text-bright); }
.home-content { display: flex; flex: 1 1 auto; flex-direction: column; min-width: 0; }
.home-content-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: var(--header-height);
  flex: none;
  padding: 0 var(--space-4);
  box-shadow: 0 1px 0 var(--border-subtle);
}
.home-content-header h2 { margin: 0; font-size: 16px; font-weight: 800; color: var(--text-bright); }
.home-content-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: var(--space-3) var(--space-4); }

/* Chat */
.chat-header {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-height: var(--header-height);
  flex: none;
  padding: 0 var(--space-3);
  box-shadow: 0 1px 0 var(--border-subtle), 0 2px 6px rgba(0, 0, 0, 0.1);
}
.mobile-menu-button { display: none; place-items: center; width: 32px; height: 32px; border-radius: var(--radius-sm); color: var(--text-muted); }
.mobile-menu-button:hover { background: var(--bg-hover); color: var(--text-bright); }
.chat-header-info { display: flex; align-items: center; gap: var(--space-2); min-width: 0; flex: 1; }
.chat-header-icon { color: var(--text-faint); font-size: 22px; font-weight: 700; line-height: 1; }
.chat-header-name { color: var(--text-bright); font-size: 16px; font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-header-topic {
  max-width: 46%;
  padding-left: var(--space-3);
  border-left: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chat-header-actions { display: flex; align-items: center; gap: 2px; flex: none; }

.message-list {
  position: relative;
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-height: 0;
  gap: var(--message-gap);
  padding: var(--space-4) 0 var(--space-3);
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scroll-behavior: smooth;
}
.message-list > .empty-state { margin: auto; }

.date-divider {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin: var(--space-3) var(--space-4) 0;
  color: var(--text-faint);
  font-size: 11px;
  font-weight: 700;
}
.date-divider::before,
.date-divider::after { content: ""; height: 1px; flex: 1; background: var(--divider); }

.new-messages-divider {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin: 0 var(--space-4);
  color: var(--red);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}
.new-messages-divider::after { content: ""; height: 1px; flex: 1; background: var(--red); opacity: 0.6; }

.message {
  position: relative;
  display: grid;
  grid-template-columns: var(--message-avatar) minmax(0, 1fr);
  column-gap: var(--space-3);
  padding: var(--message-pad-y) calc(var(--space-4) + 48px) var(--message-pad-y) var(--space-4);
  min-height: 44px;
}
.message:hover { background: var(--bg-message-hover); }
.message.is-mention,
.message.mention,
.message--mention { background: var(--mention-bg); box-shadow: inset 3px 0 0 var(--mention-border); }
.message.pending { opacity: 0.65; }
.message.failed .message-content { color: var(--red); }
.message.grouped { padding-top: 2px; padding-bottom: 2px; }
.message.grouped .message-avatar-slot { visibility: hidden; }
.message-avatar-slot { grid-column: 1; grid-row: 1 / span 3; padding-top: 2px; }
.message-avatar-slot .avatar { width: var(--message-avatar); height: var(--message-avatar); font-size: 14px; }
.message-body { grid-column: 2; min-width: 0; }
.message-heading { display: flex; align-items: baseline; gap: var(--space-2); flex-wrap: wrap; }
.message-author { color: var(--text-bright); font-size: 15px; font-weight: 800; }
.message-author[role-color],
.message-author[style*="color"] { cursor: pointer; }
.message-timestamp { color: var(--text-faint); font-size: 11px; }
.message-edited { color: var(--text-faint); font-size: 10px; }
.message-role-badge { color: var(--text-muted); font-size: 10px; font-weight: 700; text-transform: uppercase; }
.message-text {
  margin: 2px 0 0;
  color: var(--text-normal);
  font-size: 15px;
  line-height: 1.42;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}
.message-text a { color: var(--text-link); }
.message-text code {
  padding: 1px 4px;
  border-radius: var(--radius-xs);
  background: var(--bg-code);
  font-family: var(--font-mono);
  font-size: 13px;
}
.message-text pre {
  margin: var(--space-2) 0;
  padding: var(--space-3);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  background: var(--bg-code);
  overflow-x: auto;
}
.message-text pre code { padding: 0; background: none; }
.message-text blockquote {
  margin: var(--space-2) 0;
  padding-left: var(--space-3);
  border-left: 3px solid var(--border);
  color: var(--text-muted);
}

.mention,
.message-mention {
  padding: 0 2px;
  border-radius: var(--radius-xs);
  background: var(--mention-bg);
  color: #c9cdfb;
  font-weight: 700;
  cursor: pointer;
}
html[data-theme="light"] .mention,
html[data-theme="light"] .message-mention { color: #3f45a8; }
.mention:hover,
.message-mention:hover { background: var(--brand); color: #fff; }

.reply-bar {
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0 0 4px calc(calc(var(--message-avatar) + var(--space-3)) * -1);
  padding-left: calc(var(--message-avatar) + var(--space-3));
  color: var(--text-muted);
  font-size: 12px;
  cursor: pointer;
}
.reply-bar::before {
  content: "";
  position: absolute;
  left: calc(var(--message-avatar) / 2);
  top: -12px;
  width: 22px;
  height: 22px;
  border-left: 2px solid var(--border);
  border-top: 2px solid var(--border);
  border-top-left-radius: 8px;
}
.reply-bar:hover { color: var(--text-normal); }
.reply-bar .avatar { width: 16px; height: 16px; font-size: 8px; }
.reply-author { color: var(--text-link); font-weight: 800; }
.reply-preview { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }

.message-actions {
  position: absolute;
  top: -14px;
  right: var(--space-4);
  z-index: 2;
  display: none;
  align-items: center;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  background: var(--bg-floating);
  box-shadow: var(--shadow-md);
}
.message:hover .message-actions,
.message:focus-within .message-actions { display: flex; }
.message-actions .icon-button { width: 28px; height: 28px; }

.reactions { display: flex; flex-wrap: wrap; gap: 4px; margin-top: var(--space-2); }
.reaction {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 26px;
  padding: 2px 8px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-pill);
  background: var(--bg-input);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
}
.reaction:hover { border-color: var(--brand); }
.reaction.me { background: var(--brand-soft); border-color: var(--brand); color: var(--text-bright); }
.reaction-emoji { font-size: 15px; line-height: 1; }
.reaction-count { font-variant-numeric: tabular-nums; }
.reaction-add { padding: 2px 7px; opacity: 0.7; }

.embed {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: var(--space-3);
  max-width: 520px;
  margin-top: var(--space-2);
  padding: var(--space-3);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  overflow: hidden;
}
.embed.is-colorful { border-left: 4px solid var(--brand); }
.embed-author { display: flex; align-items: center; gap: 6px; color: var(--text-bright); font-size: 12px; font-weight: 800; }
.embed-title { margin: 4px 0 0; color: var(--text-link); font-size: 14px; font-weight: 800; }
.embed-description { margin: 4px 0 0; color: var(--text-normal); font-size: 13px; line-height: 1.4; }
.embed-fields { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: var(--space-2); }
.embed-field { min-width: 140px; flex: 1; }
.embed-field-name { color: var(--text-bright); font-size: 12px; font-weight: 800; }
.embed-field-value { color: var(--text-normal); font-size: 12px; }
.embed-footer { grid-column: 1 / -1; display: flex; align-items: center; gap: 6px; color: var(--text-muted); font-size: 11px; }
.embed-thumbnail { width: 80px; height: 80px; border-radius: var(--radius-sm); object-fit: cover; }
.embed-image { grid-column: 1 / -1; width: 100%; max-height: 320px; border-radius: var(--radius-sm); object-fit: cover; }

.attachment { display: flex; align-items: center; gap: var(--space-2); max-width: 520px; margin-top: var(--space-2); padding: var(--space-2) var(--space-3); border: 1px solid var(--border-subtle); border-radius: var(--radius-sm); background: var(--bg-input); }
.attachment-icon { display: grid; place-items: center; width: 32px; height: 32px; border-radius: var(--radius-sm); background: var(--bg-active); color: var(--text-bright); font-size: 10px; font-weight: 800; }
.attachment-name { flex: 1; min-width: 0; color: var(--text-link); font-size: 13px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attachment-size { color: var(--text-muted); font-size: 11px; }
.attachment-image { width: min(100%, 420px); max-height: 360px; margin-top: var(--space-2); border-radius: var(--radius-md); object-fit: cover; cursor: zoom-in; }

.thread-summary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: var(--space-2);
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  background: var(--brand-soft);
  color: #c9cdfb;
  font-size: 12px;
  font-weight: 700;
}
.thread-summary:hover { background: var(--brand); color: #fff; }

.typing-indicator {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  height: 22px;
  flex: none;
  padding: 0 var(--space-4);
  color: var(--text-muted);
  font-size: 12px;
}
.typing-dots { display: inline-flex; align-items: flex-end; gap: 3px; height: 12px; }
.typing-dots i {
  display: block;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: typing-bounce 1.2s infinite ease-in-out;
}
.typing-dots i:nth-child(2) { animation-delay: 0.16s; }
.typing-dots i:nth-child(3) { animation-delay: 0.32s; }
@keyframes typing-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.55; }
  30% { transform: translateY(-4px); opacity: 1; }
}

.composer { position: relative; flex: none; padding: 0 var(--space-4) calc(var(--space-3) + env(safe-area-inset-bottom)); }
.composer-box {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: var(--bg-input);
  transition: border-color 120ms ease;
}
.composer-box:focus-within { border-color: var(--border); }
.composer-attachments { display: flex; flex-wrap: wrap; gap: var(--space-2); padding: var(--space-2) var(--space-3) 0; }
.composer-reply { display: flex; align-items: center; gap: var(--space-2); padding: var(--space-2) var(--space-3) 0; color: var(--text-muted); font-size: 12px; }
.composer #messageInput {
  width: 100%;
  min-height: 44px;
  max-height: 200px;
  padding: 12px var(--space-3) 6px;
  border: 0;
  background: transparent;
  color: var(--text-bright);
  font-size: 15px;
  line-height: 1.4;
  resize: none;
  overflow-y: auto;
  outline: none;
  field-sizing: content;
}
.composer #messageInput::placeholder { color: var(--text-faint); }
.composer-toolbar { display: flex; align-items: center; justify-content: space-between; min-height: 40px; padding: 0 var(--space-2) var(--space-2); }
.composer-tools { display: flex; align-items: center; gap: 2px; }
.composer-tool {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
}
.composer-tool:hover { background: var(--bg-hover); color: var(--text-bright); }
.composer-tool.active { color: var(--brand); background: var(--brand-soft); }
.composer-divider { width: 1px; height: 20px; margin: 0 4px; background: var(--border); }
.send-button {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  background: var(--brand);
  color: #fff;
}
.send-button:hover:not(:disabled) { background: var(--brand-hover); }
.send-button:disabled { background: var(--bg-active); color: var(--text-faint); }
.composer-hint { margin-top: 4px; padding: 0 2px; color: var(--text-faint); font-size: 10px; text-align: right; }

.mention-menu {
  position: absolute;
  left: var(--space-4);
  bottom: calc(100% - var(--space-2));
  z-index: 30;
  width: min(360px, calc(100% - var(--space-6)));
  max-height: 320px;
  padding: var(--space-1);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: var(--bg-floating);
  box-shadow: var(--shadow-lg);
  overflow-y: auto;
}
.mention-menu-title { padding: var(--space-2); color: var(--text-muted); font-size: 10px; font-weight: 800; letter-spacing: 0.04em; text-transform: uppercase; }
.mention-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  min-height: 36px;
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
  color: var(--text-normal);
  text-align: left;
}
.mention-item:hover,
.mention-item.active,
.mention-item[aria-selected="true"] { background: var(--brand); color: #fff; }
.mention-item .avatar { width: 24px; height: 24px; font-size: 10px; }
.mention-item-name { flex: 1; min-width: 0; font-size: 13px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mention-item-hint { color: var(--text-muted); font-size: 11px; }
.mention-item:hover .mention-item-hint,
.mention-item.active .mention-item-hint { color: rgba(255, 255, 255, 0.8); }

/* ----------------------------------------------------------- side panels */
.side-panel {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: var(--z-panel);
  display: flex;
  flex-direction: column;
  width: min(380px, 100%);
  background: var(--bg-sidebar);
  border-left: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-md);
}
.search-panel { width: min(460px, 100%); }
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: var(--header-height);
  flex: none;
  padding: 0 var(--space-3);
  box-shadow: 0 1px 0 var(--border-subtle);
}
.panel-header h2 { margin: 0; color: var(--text-bright); font-size: 15px; font-weight: 800; }
.panel-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: var(--space-3); }
.search-input-wrap { display: flex; align-items: center; gap: var(--space-2); flex: none; margin: var(--space-3); padding: 0 var(--space-2); border-radius: var(--radius-sm); background: var(--bg-input); color: var(--text-muted); }
.search-field { width: 100%; min-height: 34px; border: 0; background: transparent; color: var(--text-bright); outline: none; }

.member-list {
  position: relative;
  z-index: 24;
  width: var(--members-width);
  flex: 0 0 var(--members-width);
  min-width: 0;
  background: var(--bg-sidebar);
  border-left: 1px solid var(--border-subtle);
}
.member-list-scroll { height: 100%; padding: var(--space-3) var(--space-2); overflow-x: hidden; overflow-y: auto; }
.member-group { margin-bottom: var(--space-4); }
.member-group-header {
  padding: 0 var(--space-2) 4px;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}
.member-group-header .group-count { color: var(--text-faint); font-weight: 600; text-transform: none; }
.member-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  min-height: 42px;
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
  text-align: left;
}
.member-row:hover { background: var(--bg-hover); }
.member-row.offline { opacity: 0.5; }
.member-row .avatar { width: 32px; height: 32px; }
.member-info { flex: 1; min-width: 0; }
.member-name { display: flex; align-items: center; gap: 4px; color: var(--text-normal); font-size: 14px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.member-activity { color: var(--text-muted); font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.role-dot { width: 8px; height: 8px; flex: none; border-radius: 50%; background: var(--brand); }
.member-crown { color: var(--yellow); font-size: 12px; }
.hoisted-role { color: var(--text-bright); }
.member-actions { display: flex; gap: 2px; opacity: 0; }
.member-row:hover .member-actions { opacity: 1; }
.member-actions .icon-button { width: 24px; height: 24px; }
.member-actions svg { width: 14px; height: 14px; }

/* --------------------------------------------------------------- overlays */
.modal-root,
.popout-root {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  pointer-events: none;
}
.popout-root { z-index: calc(var(--z-modal) - 5); }
.modal-root > *,
.popout-root > * { pointer-events: auto; }

.modal-backdrop {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
  background: var(--scrim);
  animation: fade-in 140ms ease;
}
.modal {
  display: flex;
  flex-direction: column;
  width: min(100%, 460px);
  max-height: min(90vh, 760px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: var(--bg-sidebar);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: modal-in 160ms ease;
}
.modal--wide { width: min(100%, 740px); }
.modal--danger { border-top: 4px solid var(--red); }
.modal-header { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); flex: none; padding: var(--space-4); }
.modal-header h2,
.modal-title { margin: 0; color: var(--text-bright); font-size: 17px; font-weight: 800; }
.modal-body { flex: 1 1 auto; min-height: 0; padding: 0 var(--space-4) var(--space-4); overflow-y: auto; }
.modal-body.is-flush { padding: 0; }
.modal-footer { display: flex; align-items: center; justify-content: flex-end; gap: var(--space-2); flex: none; padding: var(--space-3) var(--space-4); background: var(--bg-rail); }
.modal-field { display: flex; flex-direction: column; gap: 6px; margin-bottom: var(--space-3); }
.modal-field label { color: var(--text-muted); font-size: 12px; font-weight: 800; text-transform: uppercase; }
.modal-field input,
.modal-field textarea,
.modal-field select {
  width: 100%;
  min-height: 38px;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  color: var(--text-bright);
  outline: none;
}
.modal-field input:focus,
.modal-field textarea:focus,
.modal-field select:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.modal-field textarea { min-height: 90px; resize: vertical; }
.modal-note { margin: 0; color: var(--text-muted); font-size: 12px; }

.settings-modal {
  display: grid;
  grid-template-columns: 190px minmax(0, 1fr);
  width: min(100%, 860px);
  max-height: min(92vh, 780px);
}
.settings-sidebar { padding: var(--space-4) var(--space-2); background: var(--bg-rail); overflow-y: auto; }
.settings-sidebar-title { padding: 0 var(--space-3) var(--space-3); color: var(--text-muted); font-size: 11px; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; }
.settings-nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  min-height: 34px;
  padding: 0 var(--space-3);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 700;
  text-align: left;
}
.settings-nav-item svg { width: 16px; height: 16px; }
.settings-nav-item:hover { background: var(--bg-hover); color: var(--text-bright); }
.settings-nav-item.active { background: var(--bg-active); color: var(--text-bright); }
.settings-nav-item.danger { color: var(--red); }
.settings-content { display: flex; flex-direction: column; min-width: 0; }
.settings-content > .modal-header { border-bottom: 1px solid var(--border-subtle); }
.settings-content > .modal-body { padding: var(--space-4); }
.settings-section { margin-bottom: var(--space-5); }
.settings-section h3 { margin: 0 0 var(--space-2); color: var(--text-bright); font-size: 13px; font-weight: 800; }
.settings-row { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); min-height: 46px; padding: var(--space-2) 0; border-bottom: 1px solid var(--border-subtle); }
.settings-row:last-child { border-bottom: 0; }
.settings-row-copy { flex: 1; min-width: 0; }
.settings-row-title { color: var(--text-normal); font-size: 14px; font-weight: 700; }
.settings-row-desc { color: var(--text-muted); font-size: 12px; }
.switch {
  position: relative;
  width: 40px;
  height: 22px;
  flex: none;
  border-radius: var(--radius-pill);
  background: var(--bg-active);
  transition: background 120ms ease;
}
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: var(--text-bright); transition: transform 120ms ease; }
.switch[aria-checked="true"],
.switch.active,
.switch.on { background: var(--brand); }
.switch[aria-checked="true"]::after,
.switch.active::after,
.switch.on::after { transform: translateX(18px); }
.appearance-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: var(--space-2); }
.appearance-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding: var(--space-2);
  border: 2px solid transparent;
  border-radius: var(--radius-md);
  background: var(--bg-input);
  color: var(--text-normal);
  font-size: 12px;
  font-weight: 700;
  text-align: left;
}
.appearance-card:hover { border-color: var(--border); }
.appearance-card.active { border-color: var(--brand); }
.appearance-swatch { display: flex; height: 48px; border-radius: var(--radius-sm); overflow: hidden; }
.appearance-swatch span { flex: 1; }
.color-swatch { width: 22px; height: 22px; border: 2px solid transparent; border-radius: 50%; cursor: pointer; }
.color-swatch.active { border-color: var(--text-bright); }

.profile-popout {
  position: absolute;
  width: 300px;
  max-width: calc(100vw - 24px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: var(--bg-floating);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: pop-in 120ms ease;
}
.profile-banner { height: 60px; background: linear-gradient(120deg, var(--brand), #a56cf6); }
.profile-avatar { width: 72px; height: 72px; margin: -36px 0 0 var(--space-4); border: 6px solid var(--bg-floating); border-radius: 50%; }
.profile-popout-body { padding: var(--space-3); }
.profile-name { margin: 0; color: var(--text-bright); font-size: 17px; font-weight: 800; }
.profile-handle { color: var(--text-muted); font-size: 12px; }
.profile-badges { display: flex; flex-wrap: wrap; gap: 4px; margin-top: var(--space-2); }
.profile-section { margin-top: var(--space-3); padding-top: var(--space-3); border-top: 1px solid var(--border-subtle); }
.profile-section-title { color: var(--text-bright); font-size: 11px; font-weight: 800; text-transform: uppercase; }
.profile-section-copy { margin-top: 4px; color: var(--text-normal); font-size: 13px; white-space: pre-wrap; overflow-wrap: anywhere; }
.profile-note { width: 100%; min-height: 34px; margin-top: var(--space-2); padding: var(--space-2); border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg-input); color: var(--text-bright); font-size: 12px; }
.profile-actions { display: flex; gap: var(--space-2); margin-top: var(--space-3); }

.context-menu {
  position: absolute;
  min-width: 180px;
  max-width: calc(100vw - 24px);
  padding: var(--space-1);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  background: var(--bg-floating);
  box-shadow: var(--shadow-lg);
}
.context-menu-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  min-height: 32px;
  padding: 0 var(--space-2);
  border-radius: var(--radius-xs);
  color: var(--text-normal);
  font-size: 13px;
  text-align: left;
}
.context-menu-item:hover { background: var(--brand); color: #fff; }
.context-menu-item.danger { color: var(--red); }
.context-menu-item.danger:hover { background: var(--red); color: #fff; }
.context-menu-separator { height: 1px; margin: var(--space-1) 0; background: var(--border-subtle); }

.toast-root {
  position: fixed;
  z-index: var(--z-toast);
  right: max(16px, env(safe-area-inset-right));
  bottom: max(16px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  width: min(360px, calc(100vw - 32px));
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  padding: var(--space-3);
  border: 1px solid var(--border-subtle);
  border-left: 3px solid var(--brand);
  border-radius: var(--radius-md);
  background: var(--bg-floating);
  box-shadow: var(--shadow-md);
  color: var(--text-bright);
  font-size: 13px;
  pointer-events: auto;
  animation: toast-in 180ms ease;
}
.toast.success { border-left-color: var(--green); }
.toast.error { border-left-color: var(--red); }
.toast.warning { border-left-color: var(--yellow); }
.toast-icon { font-size: 16px; line-height: 1.2; }
.toast-copy { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.toast-title { font-weight: 800; }
.toast-message { color: var(--text-muted); font-size: 12px; }
.toast-close { color: var(--text-muted); }
.toast-progress { position: absolute; left: 0; bottom: 0; height: 2px; background: var(--brand); }

.voice-overlay {
  position: fixed;
  inset: 0;
  z-index: calc(var(--z-overlay) + 10);
  display: flex;
  flex-direction: column;
  padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  background: rgba(8, 9, 11, 0.94);
}
.voice-overlay-header { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); color: var(--text-bright); }
.voice-overlay-title { font-size: 15px; font-weight: 800; }
.voice-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--space-3);
  flex: 1 1 auto;
  min-height: 0;
  margin: var(--space-4) 0;
  overflow-y: auto;
}
.voice-tile {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 180px;
  border: 2px solid transparent;
  border-radius: var(--radius-md);
  background: var(--bg-rail);
  overflow: hidden;
}
.voice-tile.speaking { border-color: var(--green); box-shadow: 0 0 0 3px var(--green-soft); }
.voice-tile .avatar { width: 72px; height: 72px; font-size: 24px; }
.voice-video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.voice-tile-name {
  position: absolute;
  left: var(--space-2);
  bottom: var(--space-2);
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
}
.voice-controls { display: flex; align-items: center; justify-content: center; gap: var(--space-2); flex: none; }
.voice-control-button {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: var(--bg-active);
  color: var(--text-bright);
}
.voice-control-button:hover { background: var(--bg-hover); }
.voice-control-button.active { background: var(--red); color: #fff; }
.voice-control-button.leave { background: var(--red); color: #fff; }

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes modal-in { from { opacity: 0; transform: translateY(8px) scale(0.985); } to { opacity: 1; transform: none; } }
@keyframes pop-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@keyframes toast-in { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; transform: none; } }

/* -------------------------------------------------------------- drawers */
.mobile-tabs { display: none; }
.app-shell::after { display: none; }

@media (max-width: 1180px) {
  :root { --sidebar-width: 220px; --members-width: 210px; }
}

@media (max-width: 980px) {
  :root { --members-width: 200px; }
  .chat-header-topic { max-width: 30%; }
  .message { padding-right: var(--space-4); }
}

@media (max-width: 860px) {
  :root { --rail-width: 64px; }
  .app-shell::after {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 34;
    display: block;
    background: var(--scrim);
    opacity: 0;
    pointer-events: none;
    transition: opacity 160ms ease;
  }
  body.drawer-left .app-shell::after,
  body.drawer-right .app-shell::after,
  .app-shell.drawer-left::after,
  .app-shell.drawer-right::after,
  .app-shell.drawer-rail::after,
  .app-shell.drawer-channels::after,
  .app-shell.drawer-members::after { opacity: 1; pointer-events: auto; }

  .server-rail {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    width: var(--rail-width);
    transform: translateX(-100%);
    transition: transform 180ms ease;
    z-index: var(--z-rail);
  }
  .channel-sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    width: min(86vw, 320px);
    flex-basis: auto;
    transform: translateX(-105%);
    transition: transform 180ms ease;
    z-index: calc(var(--z-rail) + 2);
    box-shadow: var(--shadow-lg);
  }
  .member-list {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(86vw, 300px);
    flex-basis: auto;
    transform: translateX(105%);
    transition: transform 180ms ease;
    z-index: calc(var(--z-rail) + 2);
    box-shadow: var(--shadow-lg);
  }

  body.drawer-left .server-rail,
  .app-shell.drawer-left .server-rail,
  .app-shell.drawer-rail .server-rail { transform: translateX(0); }
  body.drawer-left .channel-sidebar,
  .app-shell.drawer-left .channel-sidebar,
  .app-shell.drawer-channels .channel-sidebar { transform: translateX(0); }
  body.drawer-right .member-list,
  .app-shell.drawer-right .member-list,
  .app-shell.drawer-members .member-list { transform: translateX(0); }

  body.drawer-left .channel-sidebar,
  .app-shell.drawer-left .channel-sidebar { left: var(--rail-width); }

  .main-view { width: 100%; }
  .mobile-menu-button { display: grid; }
  .mobile-tabs {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: calc(var(--z-overlay) + 5);
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    height: calc(56px + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    background: var(--bg-rail);
    border-top: 1px solid var(--border-subtle);
  }
  .mobile-tab {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    color: var(--text-muted);
    font-size: 10px;
    font-weight: 700;
  }
  .mobile-tab.active { color: var(--text-bright); background: var(--bg-hover); }
  .app-shell { padding-bottom: calc(56px + env(safe-area-inset-bottom)); }
  .composer { padding-bottom: calc(var(--space-3) + 2px); }
  .side-panel { width: min(92vw, 420px); bottom: calc(56px + env(safe-area-inset-bottom)); }
  .voice-overlay { bottom: calc(56px + env(safe-area-inset-bottom)); }
  .toast-root { bottom: calc(72px + env(safe-area-inset-bottom)); }
}

@media (max-width: 680px) {
  .home-sidebar { display: none; }
  .home-view .home-content { width: 100%; }
  .chat-header-topic { display: none; }
  .message { padding-left: var(--space-3); padding-right: var(--space-3); }
  .author-avatar,
  .message-avatar-slot .avatar { width: 34px; height: 34px; }
  .embed { grid-template-columns: minmax(0, 1fr); }
  .embed-thumbnail { width: 100%; height: 140px; }
  .settings-modal { grid-template-columns: 1fr; width: min(100%, 560px); }
  .settings-sidebar { display: flex; flex-wrap: wrap; gap: 2px; padding: var(--space-2); }
  .settings-sidebar-title { width: 100%; padding: 4px var(--space-2); }
  .settings-nav-item { width: auto; min-height: 30px; padding: 0 var(--space-2); font-size: 12px; }
  .voice-grid { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
  .voice-tile { min-height: 140px; }
}

@media (max-width: 480px) {
  .auth-card { padding: var(--space-4); border-radius: var(--radius-md); }
  .auth-brand { margin-bottom: var(--space-4); }
  .brand-mark svg { width: 40px; height: 40px; }
  .auth-brand-copy h1 { font-size: 21px; }
  .recovery-code-list { grid-template-columns: 1fr; }
  .composer-hint { display: none; }
  .chat-header-actions .icon-button:nth-child(n+4) { display: none; }
  .message-actions { right: var(--space-2); }
  .side-panel { width: 100%; }
  .modal { max-height: calc(100dvh - 32px); }
  .profile-popout { width: calc(100vw - 24px); }
}

@media (display-mode: standalone) {
  .app-shell,
  .auth-view { min-height: 100dvh; }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
}

/* PulseChat app-level additions ---------------------------------------- */
.settings-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: var(--space-4) var(--space-2);
  background: var(--bg-rail);
  overflow-y: auto;
}
.settings-nav h3 { margin: 0 0 var(--space-3); padding: 0 var(--space-3); color: var(--text-muted); font-size: 11px; letter-spacing: .06em; text-transform: uppercase; }
.settings-nav button {
  display: flex; align-items: center; gap: var(--space-2); width: 100%; min-height: 34px;
  padding: 0 var(--space-3); border-radius: var(--radius-sm); color: var(--text-muted);
  font-size: 13px; font-weight: 700; text-align: left;
}
.settings-nav button:hover { background: var(--bg-hover); color: var(--text-bright); }
.settings-nav button.active { background: var(--bg-active); color: var(--text-bright); }
.settings-nav button.danger { color: var(--red); }
.settings-nav-spacer { flex: 1; min-height: var(--space-3); }
.settings-body { display: flex; flex-direction: column; min-width: 0; overflow-y: auto; }
.settings-head { flex: none; padding: var(--space-4); border-bottom: 1px solid var(--border-subtle); }
.settings-head h2 { margin: 0; color: var(--text-bright); font-size: 17px; font-weight: 800; }
.settings-card {
  margin: var(--space-3) var(--space-4);
  padding: var(--space-4);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: var(--bg-secondary);
}
.settings-card h4 { margin: 0 0 var(--space-2); color: var(--text-bright); font-size: 14px; }
.settings-card p { margin: 0 0 var(--space-2); font-size: 13px; line-height: 1.5; }
.settings-row { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); min-height: 48px; padding: var(--space-2) 0; border-bottom: 1px solid var(--border-subtle); }
.settings-row:last-child { border-bottom: 0; }
.settings-row > div:first-child { flex: 1; min-width: 0; }
.settings-row label, .settings-row-title { display: block; color: var(--text-normal); font-size: 14px; font-weight: 700; }
.settings-row small, .settings-row-desc { display: block; margin-top: 2px; color: var(--text-muted); font-size: 12px; }
.settings-control { flex: none; min-width: 190px; display: flex; align-items: center; justify-content: flex-end; gap: var(--space-2); }
.settings-control input:not([type="range"]):not([type="checkbox"]), .settings-control select, .settings-control textarea {
  width: min(100%, 280px); min-height: 36px; padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--bg-input); color: var(--text-bright); outline: none;
}
.settings-control textarea { min-height: 88px; resize: vertical; }
.settings-control input[type="color"] { width: 44px; height: 34px; padding: 2px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg-input); }
.settings-control input[type="range"] { width: 180px; accent-color: var(--brand); }
.settings-control input[type="file"] { max-width: 250px; font-size: 11px; color: var(--text-muted); }
.settings-actions { display: flex; justify-content: flex-end; gap: var(--space-2); margin-top: var(--space-3); }
.switch { position: relative; width: 42px; height: 24px; flex: none; border-radius: 999px; background: var(--bg-active); cursor: pointer; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch span { position: absolute; inset: 0; border-radius: inherit; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: var(--text-bright); transition: transform 120ms ease; }
.switch:has(input:checked) { background: var(--brand); }
.switch:has(input:checked) span::after { transform: translateX(18px); }
.range-value { min-width: 38px; color: var(--text-muted); font-size: 12px; }
.theme-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-2); margin-bottom: var(--space-3); }
.theme-card { display: flex; align-items: center; gap: var(--space-2); padding: var(--space-2) var(--space-3); border: 1px solid var(--border-subtle); border-radius: var(--radius-sm); color: var(--text-normal); font-size: 13px; font-weight: 700; }
.theme-card span { width: 20px; height: 20px; border: 1px solid var(--border); border-radius: 6px; }
.theme-card.active { border-color: var(--brand); background: var(--brand-soft); color: var(--text-bright); }
.recovery-codes, .twofa-setup, .twofa-disable { display: flex; flex-direction: column; gap: var(--space-2); margin-top: var(--space-3); padding: var(--space-3); border: 1px solid var(--yellow); border-radius: var(--radius-sm); background: var(--bg-input); }
.recovery-codes code { color: var(--yellow); font-size: 12px; line-height: 1.8; overflow-wrap: anywhere; }
.twofa-setup code { color: var(--brand); font-size: 13px; overflow-wrap: anywhere; }
.twofa-setup input, .twofa-disable input { min-height: 36px; padding: var(--space-2) var(--space-3); border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg-input); color: var(--text-bright); }
.profile-preview { position: relative; height: 130px; margin-bottom: var(--space-4); border-radius: var(--radius-md); background: var(--banner, var(--brand)); overflow: hidden; }
.profile-preview img { width: 100%; height: 100%; object-fit: cover; }
.profile-avatar { position: absolute; left: var(--space-4); bottom: -22px; display: grid; place-items: center; width: 72px; height: 72px; border: 5px solid var(--bg-secondary); border-radius: 50%; background: var(--brand); color: #fff; font-size: 28px; font-weight: 800; overflow: hidden; }
.profile-avatar img { width: 100%; height: 100%; object-fit: cover; }
.saved-account, .blocked-row { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); min-height: 40px; padding: var(--space-2) 0; border-bottom: 1px solid var(--border-subtle); font-size: 13px; }
.saved-account small, .blocked-row small { color: var(--text-muted); }
.saved-account em { color: var(--green); font-size: 11px; font-style: normal; }
.friend-tabs { display: flex; gap: 4px; padding: var(--space-2) var(--space-3); border-bottom: 1px solid var(--border-subtle); }
.friend-tab { padding: 6px 10px; border-radius: var(--radius-sm); color: var(--text-muted); font-size: 12px; font-weight: 800; }
.friend-tab.active { background: var(--bg-active); color: var(--text-bright); }
.friend-actions { display: flex; gap: 4px; }
.role-perm-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px var(--space-3); max-height: 320px; overflow-y: auto; }
.role-perm-grid label { display: flex; align-items: center; gap: var(--space-2); color: var(--text-normal); font-size: 12px; }
.search-result { padding: var(--space-2) var(--space-3); border-radius: var(--radius-sm); cursor: pointer; }
.search-result:hover { background: var(--bg-hover); }
.search-result strong { color: var(--text-link); font-size: 12px; }
.search-result p { margin: 2px 0 0; color: var(--text-normal); font-size: 13px; }
.popout-actions { display: flex; gap: var(--space-2); padding: 0 var(--space-3) var(--space-3); }
.popout-actions input { flex: 1; min-height: 32px; padding: var(--space-2); border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg-input); color: var(--text-bright); }
.volume-popover { position: fixed; z-index: calc(var(--z-modal) + 2); width: 180px; padding: var(--space-3); border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg-sidebar); box-shadow: var(--shadow-lg); }
.volume-popover label { display: block; margin-bottom: var(--space-2); color: var(--text-muted); font-size: 11px; }
.volume-popover input { width: 100%; accent-color: var(--brand); }

