/* ============================================================
   ONYX - macOS Dark Mode-inspired stylesheet
   ============================================================ */

:root {
  /* Base surfaces (Apple-style hierarchy) */
  --bg-base: #000000;
  --surface-1: #1c1c1e;   /* sidebars, base panels */
  --surface-2: #2c2c2e;   /* raised content, cards */
  --surface-3: rgba(255, 255, 255, 0.06);  /* hover overlays */
  --surface-active: rgba(255, 255, 255, 0.12);

  /* Text — Apple's translucent whites */
  --text: #ffffff;
  --text-secondary: rgba(235, 235, 245, 0.6);
  --text-tertiary: rgba(235, 235, 245, 0.3);

  /* Accents */
  --accent: #0a84ff;            /* systemBlue dark */
  --accent-hover: #409cff;
  --accent-soft: rgba(10, 132, 255, 0.15);
  --indigo: #5e5ce6;
  --success: #30d158;
  --danger: #ff453a;
  --orange: #ff9f0a;

  /* Lines & shadows */
  --separator: rgba(255, 255, 255, 0.08);
  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-2: 0 8px 24px rgba(0, 0, 0, 0.45);
  --shadow-3: 0 20px 60px rgba(0, 0, 0, 0.6);

  /* Shapes */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-pill: 999px;

  /* Motion */
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
}

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

html, body {
  margin: 0; padding: 0; height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display",
               "Helvetica Neue", "Inter", system-ui, sans-serif;
  font-size: 14px;
  font-weight: 400;
  letter-spacing: -0.005em;
  color: var(--text);
  background: var(--bg-base);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

button, input, select, textarea {
  font: inherit;
  color: inherit;
  border: none;
  outline: none;
  background: none;
}
button { cursor: pointer; }
input, select, textarea { -webkit-appearance: none; appearance: none; }
/* But not checkboxes / radios — they need native appearance to show their state */
input[type="checkbox"], input[type="radio"] {
  -webkit-appearance: auto;
  appearance: auto;
  accent-color: var(--accent);
  width: 18px; height: 18px;
  cursor: pointer;
}

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); border-radius: 10px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.18); background-clip: content-box; }

/* ============================================================
   AUTH SCREEN
   ============================================================ */
.auth-screen {
  display: flex; align-items: center; justify-content: center;
  height: 100vh;
  background:
    radial-gradient(circle at 25% 10%, rgba(94, 92, 230, 0.18), transparent 50%),
    radial-gradient(circle at 75% 90%, rgba(10, 132, 255, 0.14), transparent 50%),
    var(--bg-base);
}
.auth-box {
  background: rgba(28, 28, 30, 0.85);
  backdrop-filter: blur(40px) saturate(180%);
  -webkit-backdrop-filter: blur(40px) saturate(180%);
  border: 1px solid var(--separator);
  padding: 40px 36px 32px;
  border-radius: var(--radius-lg);
  min-width: 380px;
  max-width: 400px;
  box-shadow: var(--shadow-3);
  display: flex; flex-direction: column; gap: 14px;
}
.auth-box h1 {
  margin: 0;
  font-size: 32px; font-weight: 700; letter-spacing: 0.2em;
  text-align: center;
  background: linear-gradient(135deg, #fff 0%, #98989d 100%);
  -webkit-background-clip: text; background-clip: text;
  color: transparent;
}
.auth-box .tag {
  margin: -8px 0 12px;
  color: var(--text-secondary);
  font-size: 13px; text-align: center; letter-spacing: 0.01em;
}
.auth-box input {
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--separator);
  color: var(--text);
  border-radius: var(--radius-md);
  font-size: 14px;
  transition: border-color 150ms var(--ease), background 150ms var(--ease);
}
.auth-box input:focus {
  border-color: var(--accent);
  background: rgba(255, 255, 255, 0.08);
}
.auth-buttons { display: flex; gap: 8px; margin-top: 6px; }
.auth-buttons button {
  flex: 1; padding: 12px;
  border-radius: var(--radius-md);
  font-weight: 600; font-size: 14px;
  transition: all 150ms var(--ease);
}
#btn-enter {
  background: var(--accent); color: white;
}
#btn-enter:hover { background: var(--accent-hover); transform: translateY(-1px); }
#btn-enter:active { transform: translateY(0); }
.hint { color: var(--text-tertiary); font-size: 12px; text-align: center; margin: 6px 0 0; line-height: 1.5; }
.error { color: var(--danger); font-size: 13px; min-height: 18px; margin: 4px 0 0; text-align: center; }
.lang-row { display: flex; align-items: center; gap: 8px; justify-content: center; margin-top: 16px; font-size: 12px; color: var(--text-tertiary); padding-top: 14px; border-top: 1px solid var(--separator); }

/* ============================================================
   APP LAYOUT
   ============================================================ */
.app {
  display: grid;
  grid-template-columns: 76px 240px 1fr;
  height: 100vh;
  background: var(--bg-base);
}
.app[data-voice="on"] { grid-template-columns: 76px 240px 1fr 280px; }

/* ============================================================
   SERVERS BAR
   ============================================================ */
.servers-bar {
  background: var(--bg-base);
  padding: 16px 0 14px;
  display: flex; flex-direction: column; align-items: center;
  gap: 14px; overflow-y: auto;
  border-right: 1px solid var(--separator);
}
.servers-bar::-webkit-scrollbar { display: none; }
.servers-bar > #server-list { display: flex; flex-direction: column; gap: 14px; align-items: center; }
.servers-bar > #server-list:empty { display: none; }

/* Separator line between special icons and server list */
.servers-bar::before, .servers-bar::after { display: none; }

.server-icon {
  width: 48px; height: 48px;
  border-radius: 14px;
  background: var(--surface-1);
  color: var(--text);
  font-size: 14px; font-weight: 600; letter-spacing: 0.04em;
  display: flex; align-items: center; justify-content: center;
  position: relative;
  transition: border-radius 200ms var(--ease), background 150ms var(--ease), transform 100ms var(--ease), color 150ms var(--ease);
  flex-shrink: 0;
}
.server-icon svg { width: 22px; height: 22px; display: block; }
.server-icon:hover { background: var(--surface-2); border-radius: 12px; }
.server-icon:active { transform: scale(0.94); }

/* Active indicator pill on left */
.server-icon::before {
  content: '';
  position: absolute;
  left: -14px; top: 50%; transform: translateY(-50%) scaleY(0);
  width: 4px; height: 24px; border-radius: 2px;
  background: var(--text);
  transition: transform 180ms var(--ease);
}
.server-icon:hover::before { transform: translateY(-50%) scaleY(0.4); }
.server-icon.active::before { transform: translateY(-50%) scaleY(1); }
.server-icon.active { background: var(--accent); color: white; }

.server-icon.add { color: var(--success); }
.server-icon.add:hover { background: var(--success); color: white; border-radius: 12px; }
.server-icon.join { color: var(--accent); }
.server-icon.join:hover { background: var(--accent); color: white; border-radius: 12px; }
.server-icon.home { color: var(--text); }
.server-icon.home:hover { background: var(--indigo); color: white; }
.server-icon.home svg { width: 24px; height: 24px; }
.server-icon.add svg { width: 26px; height: 26px; }
.server-icon.join svg { width: 24px; height: 24px; }

/* Subtle horizontal separator above the "+" button */
.server-icon.add::after {
  content: '';
  position: absolute;
  top: -10px; left: 50%; transform: translateX(-50%);
  width: 32px; height: 2px;
  background: var(--separator);
  border-radius: 2px;
  pointer-events: none;
}

.server-icon.has-img { background: transparent; padding: 0; overflow: hidden; }
.server-icon .server-img { width: 100%; height: 100%; object-fit: cover; }

/* ============================================================
   CHANNELS BAR
   ============================================================ */
.channels-bar {
  background: var(--surface-1);
  display: flex; flex-direction: column; min-height: 0;
  border-right: 1px solid var(--separator);
}
.server-banner {
  height: 96px;
  background-size: cover; background-position: center;
  border-bottom: 1px solid var(--separator);
  position: relative;
}
.server-banner::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(to bottom, transparent 60%, rgba(0,0,0,0.4));
  pointer-events: none;
}
.channels-header {
  padding: 14px 16px;
  font-weight: 600; font-size: 15px;
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--separator);
}
.channels-header #btn-server-menu {
  padding: 4px 8px; font-size: 16px;
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
}
.channels-header #btn-server-menu:hover { background: var(--surface-3); color: var(--text); }

.channels-list { flex: 1; padding: 10px 8px; overflow-y: auto; }
.section-label {
  font-size: 11px; text-transform: uppercase;
  color: var(--text-tertiary);
  padding: 12px 8px 4px;
  font-weight: 600; letter-spacing: 0.08em;
}

.channel-item {
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text-secondary);
  display: flex; align-items: center; gap: 8px;
  user-select: none;
  transition: background 100ms var(--ease), color 100ms var(--ease);
  margin: 1px 0;
}
.channel-item:hover { background: var(--surface-3); color: var(--text); }
.channel-item.active { background: var(--surface-active); color: var(--text); }
.channel-item .ic { color: var(--text-tertiary); font-weight: 500; font-size: 13px; min-width: 14px; text-align: center; }
.channel-item .avatar-sm { width: 22px; height: 22px; font-size: 11px; flex-shrink: 0; }

.channel-add-row { padding: 6px 8px; }
.channel-add-row button {
  width: 100%; padding: 6px 10px;
  background: transparent;
  color: var(--text-tertiary);
  border: 1px dashed var(--separator);
  border-radius: var(--radius-sm);
  font-size: 12px;
  transition: all 150ms var(--ease);
}
.channel-add-row button:hover { color: var(--text); border-color: rgba(255,255,255,0.2); background: var(--surface-3); }

/* Voice presence row */
.voice-presence-row {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 10px 4px 30px;
  font-size: 13px; color: var(--text-secondary);
  border-radius: var(--radius-sm);
  margin: 1px 0;
}
.voice-presence-row:hover { background: var(--surface-3); color: var(--text); }
.voice-presence-row .avatar-sm { width: 20px; height: 20px; font-size: 10px; }

/* DM search */
.dm-search { padding: 8px 8px 4px; }
.dm-search input {
  width: 100%; padding: 7px 12px;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--separator);
  border-radius: var(--radius-md);
  color: var(--text); font-size: 13px;
  transition: border-color 150ms var(--ease);
}
.dm-search input:focus { border-color: var(--accent); }
#dm-search-results { margin-top: 4px; }
.dm-result {
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 13px;
}
.dm-result:hover { background: var(--surface-3); color: var(--text); }

/* User bar (bottom of channels-bar) */
.user-bar {
  padding: 10px 12px;
  background: rgba(0, 0, 0, 0.3);
  display: flex; align-items: center; gap: 8px;
  border-top: 1px solid var(--separator);
}
.me-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--success); }
#me-name { flex: 1; font-weight: 600; font-size: 13px; }
.ghost-btn {
  padding: 6px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  transition: all 100ms var(--ease);
}
.ghost-btn:hover { background: var(--surface-3); color: var(--text); }

.lang-select, .lang-mini {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--separator);
  border-radius: var(--radius-sm);
  padding: 4px 6px; font-size: 12px;
}
.lang-mini { width: 64px; }
/* Force dropdown options to use dark theme colors (Chromium-based browsers). */
.lang-select option, select option {
  background: var(--surface-1);
  color: var(--text);
}
.lang-select option:hover,
.lang-select option:checked,
select option:checked {
  background: var(--accent);
  color: white;
}

/* ============================================================
   CONTENT (chat area)
   ============================================================ */
.content {
  display: flex; flex-direction: column;
  background: var(--bg-base);
  min-width: 0;
}
.content-header {
  padding: 14px 22px;
  display: flex; align-items: center; gap: 12px;
  border-bottom: 1px solid var(--separator);
  background: rgba(28, 28, 30, 0.5);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}
.content-header #content-header-title { font-weight: 600; font-size: 15px; }
.content-header .sub { color: var(--text-tertiary); font-size: 12px; }

.messages {
  flex: 1; padding: 18px 22px; overflow-y: auto;
  display: flex; flex-direction: column; gap: 14px;
}
.msg { display: flex; gap: 14px; padding: 2px 0; }
.msg .avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--indigo);
  color: white;
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 14px;
  flex-shrink: 0;
  box-shadow: 0 0 0 2px var(--bg-base);
}
.msg .avatar.has-img { background: transparent; padding: 0; overflow: hidden; }
.msg .avatar.has-img img,
.msg .avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.msg .body { flex: 1; min-width: 0; }
.msg .head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 2px; }
.msg .author { font-weight: 600; color: var(--text); font-size: 14px; }
.msg .time { color: var(--text-tertiary); font-size: 11px; }
.msg .text {
  color: var(--text);
  white-space: pre-wrap; word-break: break-word;
  line-height: 1.5;
}
.msg.system .text { color: var(--text-tertiary); font-style: italic; }

.composer {
  padding: 14px 22px 22px;
  display: flex; gap: 10px;
}
.composer input {
  flex: 1; padding: 12px 16px;
  background: var(--surface-2);
  border: 1px solid var(--separator);
  border-radius: var(--radius-md);
  color: var(--text); font-size: 14px;
  transition: border-color 150ms var(--ease);
}
.composer input:focus { border-color: var(--accent); }
.composer button {
  padding: 0 20px;
  background: var(--accent);
  color: white;
  border-radius: var(--radius-md);
  font-weight: 600; font-size: 14px;
  transition: background 100ms var(--ease), transform 80ms var(--ease);
}
.composer button:hover { background: var(--accent-hover); }
.composer button:active { transform: scale(0.97); }

/* ============================================================
   VOICE BAR
   ============================================================ */
.voice-bar {
  background: var(--surface-1);
  padding: 18px 16px;
  display: flex; flex-direction: column; gap: 14px;
  border-left: 1px solid var(--separator);
  min-height: 0;
}
.voice-header {
  display: flex; flex-direction: column; gap: 2px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--separator);
}
.voice-header > span:first-child { font-size: 12px; color: var(--success); font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; }
.voice-header .sub { color: var(--text-secondary); font-size: 14px; font-weight: 500; }

.voice-members { display: flex; flex-direction: column; gap: 4px; }
.voice-member {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px;
  background: var(--surface-2);
  border-radius: var(--radius-md);
  transition: box-shadow 100ms ease;
  font-size: 13px;
}
.voice-member .avatar-sm {
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--indigo);
  color: white;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 600;
  transition: box-shadow 100ms ease;
}
.voice-member .avatar-sm.has-img { background: transparent; overflow: hidden; padding: 0; }
.voice-member .avatar-sm img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.voice-member.speaking { box-shadow: inset 0 0 0 1px var(--success); }
.voice-member.speaking .avatar-sm { box-shadow: 0 0 0 2px var(--success); }

.voice-controls {
  display: flex; flex-direction: column; gap: 6px;
  margin-top: auto;
}
.voice-controls button {
  padding: 9px 12px;
  background: var(--surface-2);
  color: var(--text);
  border-radius: var(--radius-md);
  font-size: 13px; font-weight: 500;
  transition: all 100ms var(--ease);
}
.voice-controls button:hover { background: var(--surface-3); }
.voice-controls button.active { background: var(--accent); color: white; }
.voice-controls button.danger { background: var(--danger); color: white; }
.voice-controls button.danger:hover { background: #ff6961; }

/* ============================================================
   SCREEN STAGE
   ============================================================ */
.screen-stage {
  display: grid;
  gap: 10px;
  padding: 14px 22px;
  background: var(--bg-base);
  border-bottom: 1px solid var(--separator);
  overflow: hidden;
  min-height: 0;
}
.screen-stage[data-count="1"] { grid-template-columns: 1fr; max-height: 70vh; }
.screen-stage[data-count="2"] { grid-template-columns: 1fr 1fr; max-height: 60vh; }
.screen-stage[data-count="3"], .screen-stage[data-count="4"] { grid-template-columns: 1fr 1fr; max-height: 60vh; }
.screen-stage[data-count="5"], .screen-stage[data-count="6"] { grid-template-columns: 1fr 1fr 1fr; max-height: 55vh; }
.screen-stage[data-count="7"], .screen-stage[data-count="8"], .screen-stage[data-count="9"] { grid-template-columns: 1fr 1fr 1fr; max-height: 55vh; }
.screen-stage[data-count^="1"]:not([data-count="1"]) { grid-template-columns: repeat(4, 1fr); max-height: 50vh; }
.screen-stage.hide-silent .screen-tile:not(.has-stream) { display: none; }

.screen-tile {
  background: var(--surface-1);
  border-radius: var(--radius-md);
  overflow: hidden;
  position: relative;
  cursor: pointer;
  aspect-ratio: 16 / 9;
  min-height: 0;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--separator);
  transition: border-color 150ms var(--ease), transform 100ms var(--ease);
}
.screen-tile:hover { border-color: var(--accent); transform: translateY(-1px); }
.screen-tile video {
  width: 100%; height: 100%;
  object-fit: contain;
  display: block; background: var(--surface-1);
}
.screen-tile .label {
  position: absolute; bottom: 8px; left: 8px;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(10px);
  padding: 4px 10px; font-size: 12px;
  border-radius: var(--radius-sm);
  color: white; font-weight: 500;
  pointer-events: none;
}
.screen-tile .hint {
  position: absolute; top: 8px; right: 8px;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(10px);
  padding: 3px 8px; font-size: 10px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  pointer-events: none;
  opacity: 0; transition: opacity 200ms var(--ease);
}
.screen-tile:hover .hint { opacity: 1; }
.screen-tile:fullscreen { aspect-ratio: auto; border: none; border-radius: 0; }

/* ============================================================
   DIALOGS (modal + settings)
   ============================================================ */
dialog {
  background: rgba(28, 28, 30, 0.85);
  backdrop-filter: blur(40px) saturate(180%);
  -webkit-backdrop-filter: blur(40px) saturate(180%);
  color: var(--text);
  border: 1px solid var(--separator);
  border-radius: var(--radius-lg);
  padding: 24px;
  min-width: 380px;
  box-shadow: var(--shadow-3);
}
dialog::backdrop { background: rgba(0, 0, 0, 0.5); backdrop-filter: blur(10px); }
dialog[open] { animation: dialogIn 200ms var(--ease); }
@keyframes dialogIn {
  from { opacity: 0; transform: scale(0.96) translateY(8px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}
dialog h3 { margin: 0 0 14px; font-size: 17px; font-weight: 600; }
dialog input {
  width: 100%; padding: 10px 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--separator);
  border-radius: var(--radius-md);
  color: var(--text); font-size: 14px;
  margin-bottom: 8px;
  transition: border-color 150ms var(--ease);
}
dialog input:focus { border-color: var(--accent); }
dialog menu {
  display: flex; gap: 8px; justify-content: flex-end;
  margin: 18px 0 0; padding: 0;
}
dialog menu button {
  padding: 9px 16px;
  border-radius: var(--radius-md);
  background: var(--surface-2);
  color: var(--text);
  font-size: 14px; font-weight: 500;
  transition: all 100ms var(--ease);
}
dialog menu button:hover { background: var(--surface-3); }
dialog menu button#modal-ok {
  background: var(--accent); color: white;
}
dialog menu button#modal-ok:hover { background: var(--accent-hover); }

.invite-display {
  background: rgba(255, 255, 255, 0.05);
  padding: 10px 12px;
  border-radius: var(--radius-md);
  font-family: "SF Mono", "Menlo", Consolas, monospace;
  font-size: 13px;
  cursor: pointer; user-select: all;
  word-break: break-all;
  border: 1px solid var(--separator);
}

/* Settings dialog (large) */
dialog.big {
  min-width: 720px;
  max-width: 90vw;
  min-height: 520px;
  max-height: 85vh;
  padding: 0;
  display: flex; flex-direction: column;
  position: relative;
  overflow: hidden;
}
dialog.big[open] { display: flex; }

.settings-wrap {
  display: grid;
  grid-template-columns: 200px 1fr;
  flex: 1; min-height: 0;
}
.settings-tabs {
  background: rgba(0, 0, 0, 0.25);
  padding: 24px 12px;
  display: flex; flex-direction: column; gap: 2px;
  border-right: 1px solid var(--separator);
}
.settings-tabs button {
  text-align: left;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  font-weight: 500; font-size: 13px;
  transition: all 100ms var(--ease);
}
.settings-tabs button:hover { background: var(--surface-3); color: var(--text); }
.settings-tabs button.active { background: var(--surface-active); color: var(--text); }

.settings-pane { padding: 28px 32px; overflow-y: auto; }
.settings-pane h3 { margin: 0 0 22px; font-size: 22px; font-weight: 600; letter-spacing: -0.01em; }

.settings-section { margin-bottom: 28px; }
.settings-section label {
  display: block;
  font-size: 11px;
  color: var(--text-tertiary);
  margin-bottom: 8px;
  text-transform: uppercase;
  font-weight: 600;
  letter-spacing: 0.06em;
}
.settings-section input,
.settings-section select {
  width: 100%; padding: 10px 12px;
  background: var(--surface-2);
  border: 1px solid var(--separator);
  border-radius: var(--radius-md);
  color: var(--text); font-size: 14px;
  margin-bottom: 8px;
  transition: border-color 150ms var(--ease);
}
.settings-section input:focus,
.settings-section select:focus { border-color: var(--accent); }
.settings-section input[type=file] { padding: 8px 10px; background: transparent; }
.settings-section input[type=color] { width: 60px; height: 36px; padding: 2px; cursor: pointer; }
.settings-section input[disabled] { opacity: 0.6; }
.settings-section .row { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.settings-section button {
  padding: 9px 16px;
  background: var(--accent);
  color: white;
  border-radius: var(--radius-md);
  font-weight: 500; font-size: 14px;
  transition: all 100ms var(--ease);
}
.settings-section button:hover { background: var(--accent-hover); }
.settings-section button.danger { background: var(--danger); }
.settings-section button.danger:hover { background: #ff6961; }
.settings-section .note { color: var(--text-tertiary); font-size: 12px; margin: 6px 0 10px; line-height: 1.4; }
.settings-section .ok { color: var(--success); font-size: 13px; margin-top: 6px; font-weight: 500; }
.settings-section .err { color: var(--danger); font-size: 13px; margin-top: 6px; font-weight: 500; }

.dialog-close {
  position: absolute; top: 12px; right: 14px;
  background: var(--surface-2);
  color: var(--text-secondary);
  font-size: 20px; line-height: 1;
  width: 28px; height: 28px;
  border-radius: 50%;
  z-index: 10;
  display: flex; align-items: center; justify-content: center;
  transition: all 100ms var(--ease);
}
.dialog-close:hover { background: var(--danger); color: white; }

/* Permission/option checkbox list */
.perm-list { display: flex; flex-direction: column; gap: 6px; }
.perm-list label {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  background: var(--surface-2);
  border-radius: var(--radius-md);
  text-transform: none;
  font-size: 14px;
  cursor: pointer;
  color: var(--text);
  margin-bottom: 0;
  letter-spacing: 0;
  transition: background 100ms var(--ease);
}
.perm-list label:hover { background: var(--surface-3); }
.perm-list input[type=checkbox] {
  width: 18px; height: 18px;
  accent-color: var(--accent);
  cursor: pointer;
  margin: 0;
}

/* Roles & members */
.role-list { display: flex; flex-direction: column; gap: 4px; }
.role-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  background: var(--surface-2);
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: 14px;
  transition: background 100ms var(--ease);
}
.role-row:hover { background: var(--surface-3); }
.role-row.active { background: var(--surface-active); }
.role-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--text-tertiary); flex-shrink: 0; }

.member-row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px;
  background: var(--surface-2);
  border-radius: var(--radius-md);
  margin-bottom: 4px;
  font-size: 14px;
}
.member-row .avatar-sm {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--indigo);
  color: white;
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 13px;
}
.member-row .avatar-sm.has-img { background: transparent; overflow: hidden; padding: 0; }
.member-row .avatar-sm img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.member-row .role-chips { display: flex; gap: 6px; flex-wrap: wrap; margin-left: auto; align-items: center; }
.role-chip {
  font-size: 11px; padding: 3px 9px;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  display: inline-flex; align-items: center; gap: 5px;
  font-weight: 500;
}
.role-chip .role-dot { width: 7px; height: 7px; }
.role-chip .x { cursor: pointer; opacity: 0.5; padding: 0 2px; }
.role-chip .x:hover { opacity: 1; }
.member-row select {
  background: var(--surface-3);
  color: var(--text);
  border: 1px solid var(--separator);
  border-radius: var(--radius-sm);
  padding: 5px 8px;
  font-size: 12px;
}

/* ============================================================
   AVATARS (universal classes used inline)
   ============================================================ */
.avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: var(--indigo);
  color: white;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 15px;
  overflow: hidden;
  flex-shrink: 0;
}
.avatar-sm {
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--indigo);
  color: white;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 11px;
  overflow: hidden;
  flex-shrink: 0;
}
.avatar.has-img img, .avatar-sm.has-img img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; display: block; }

.avatar-big {
  width: 96px; height: 96px;
  border-radius: 50%;
  background: var(--indigo);
  color: white;
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 36px;
  overflow: hidden;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
}
.avatar-big img, img.avatar-big { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; display: block; }
img.has-img-pure { display: block; }
.avatar-preview { margin-bottom: 12px; }

/* ============================================================
   FRIENDS HUB (content area when @ DM view is open and no DM selected)
   ============================================================ */
.friends-hub {
  flex: 1; display: flex; flex-direction: column;
  padding: 20px 28px; overflow-y: auto;
  min-height: 0;
}
.friends-tabs {
  display: flex; gap: 4px;
  border-bottom: 1px solid var(--separator);
  margin-bottom: 18px;
  padding-bottom: 14px;
}
.friends-tabs button {
  padding: 7px 14px;
  background: transparent;
  color: var(--text-secondary);
  border-radius: var(--radius-md);
  font-weight: 500; font-size: 14px;
  transition: all 100ms var(--ease);
}
.friends-tabs button:hover { background: var(--surface-3); color: var(--text); }
.friends-tabs button.active { background: var(--surface-active); color: var(--text); }
.friends-tabs button.primary { background: var(--success); color: white; margin-left: auto; }
.friends-tabs button.primary:hover { background: #2ec457; color: white; }

.friends-empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 60px 20px; color: var(--text-tertiary);
  text-align: center; font-size: 14px; gap: 8px;
}
.friends-empty svg { width: 80px; height: 80px; opacity: 0.4; margin-bottom: 12px; }

.friend-list { display: flex; flex-direction: column; gap: 1px; }
.friend-section-title {
  font-size: 12px; text-transform: uppercase;
  color: var(--text-tertiary);
  font-weight: 600; letter-spacing: 0.06em;
  padding: 14px 4px 8px;
}
.friend-row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  transition: background 100ms var(--ease);
}
.friend-row:hover { background: var(--surface-3); }
.friend-row .avatar { width: 36px; height: 36px; font-size: 14px; position: relative; }
.friend-row .info { flex: 1; min-width: 0; }
.friend-row .name { font-weight: 600; font-size: 14px; }
.friend-row .status { color: var(--text-tertiary); font-size: 12px; }
.friend-row .actions { display: flex; gap: 6px; }
.friend-row .icon-btn {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--text-secondary);
  display: inline-flex; align-items: center; justify-content: center;
  transition: all 100ms var(--ease);
}
.friend-row .icon-btn:hover { background: var(--surface-3); color: var(--text); }
.friend-row .icon-btn.accept:hover { background: var(--success); color: white; }
.friend-row .icon-btn.danger:hover { background: var(--danger); color: white; }
.friend-row .icon-btn svg { width: 18px; height: 18px; }
.friend-row .pres-dot {
  width: 14px; height: 14px;
  border-radius: 50%;
  position: absolute; bottom: -2px; right: -2px;
  border: 3px solid var(--bg-base);
  background: var(--text-tertiary);
}
.friend-row .pres-dot.online { background: var(--success); }

.friends-add-form {
  display: flex; flex-direction: column; gap: 12px;
  background: var(--surface-2);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  margin-bottom: 18px;
}
.friends-add-form h3 { margin: 0; font-size: 16px; font-weight: 600; }
.friends-add-form p { margin: 0; color: var(--text-secondary); font-size: 13px; }
.friends-add-form .row { display: flex; gap: 8px; }
.friends-add-form input {
  flex: 1; padding: 10px 14px;
  background: rgba(0,0,0,0.3);
  border: 1px solid var(--separator);
  border-radius: var(--radius-md);
  color: var(--text); font-size: 14px;
}
.friends-add-form input:focus { border-color: var(--accent); }
.friends-add-form button {
  padding: 10px 18px;
  background: var(--success);
  color: white;
  border-radius: var(--radius-md);
  font-weight: 600; font-size: 14px;
}
.friends-add-form button:disabled { background: var(--surface-3); color: var(--text-tertiary); cursor: not-allowed; }
.friends-add-form .msg { font-size: 13px; min-height: 18px; }
.friends-add-form .msg.ok { color: var(--success); }
.friends-add-form .msg.err { color: var(--danger); }

.friends-hub-btn {
  display: flex; align-items: center; gap: 8px;
  width: 100%;
  padding: 9px 12px;
  background: var(--surface-2);
  color: var(--text);
  border-radius: var(--radius-md);
  font-weight: 500; font-size: 13px;
  margin-bottom: 8px;
  transition: background 100ms var(--ease);
}
.friends-hub-btn:hover { background: var(--surface-3); }
.friends-hub-btn .badge {
  margin-left: auto;
  background: var(--danger); color: white;
  font-size: 11px; font-weight: 600;
  min-width: 18px; height: 18px; padding: 0 6px;
  border-radius: 9px;
  display: inline-flex; align-items: center; justify-content: center;
}

/* Server-icon pending badge */
.server-icon .badge-corner {
  position: absolute; top: -2px; right: -2px;
  background: var(--danger); color: white;
  font-size: 10px; font-weight: 600;
  min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid var(--bg-base);
}

.banner-preview {
  width: 100%;
  height: 140px;
  background: var(--surface-2);
  border: 1px solid var(--separator);
  border-radius: var(--radius-md);
  background-size: cover; background-position: center;
  margin-bottom: 10px;
}
