.server-header-btn {
  cursor: pointer;
  gap: 8px;
  user-select: none;
}
.server-header-btn:hover { background: var(--bg-hover); }

.server-dropdown {
  position: absolute;
  left: 8px;
  top: 52px;
  width: calc(var(--sidebar) - 16px);
  background: var(--bg-0);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 6px;
  z-index: 40;
  box-shadow: var(--shadow);
}
.server-dropdown button {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 6px;
  color: var(--text);
  font-weight: 500;
  text-align: left;
}
.server-dropdown button:hover { background: var(--bg-hover); }
.dd-sep {
  height: 1px;
  background: var(--border);
  margin: 4px 6px;
}

.ch-type-pick {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.ch-type-card {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-1);
  color: var(--text-muted);
  text-align: left;
  cursor: pointer;
}
.ch-type-card:hover {
  background: var(--bg-2);
  color: var(--text);
}
.ch-type-card.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--text);
}
.ch-type-ico {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: var(--bg-3);
  color: var(--text);
  flex-shrink: 0;
}
.ch-type-card.active .ch-type-ico {
  background: var(--accent);
  color: #0b0d10;
}
.ch-type-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.ch-type-meta strong {
  font-size: 14px;
  color: var(--text);
}
.ch-type-meta span {
  font-size: 12px;
  color: var(--text-dim);
  line-height: 1.35;
}

.cat-head {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 10px 4px 4px;
}
.cat-toggle {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-dim);
  text-align: left;
  padding: 2px 4px;
  border-radius: 4px;
}
.cat-toggle:hover { color: var(--text); }
.cat-toggle.collapsed .nx-icon { transform: rotate(-90deg); }
.cat-add {
  opacity: 0;
  color: var(--text-dim);
  padding: 2px;
  border-radius: 4px;
}
.cat-head:hover .cat-add { opacity: 1; }
.cat-add:hover { color: var(--text); background: var(--bg-hover); }
.cat-channels.collapsed { display: none; }

.sidebar { position: relative; }

/* Full server settings */
.srv-settings-overlay {
  position: fixed;
  inset: 0;
  z-index: 1600;
  background: #1e1f22;
  display: flex;
  justify-content: center;
  overflow: hidden;
  animation: fadeIn 0.15s ease;
}
.srv-settings-overlay .settings-close {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 1601;
}
.srv-settings-app {
  display: grid;
  grid-template-columns: 232px minmax(0, 1fr);
  width: 100%;
  max-width: 1080px;
  height: 100%;
  position: relative;
  background: #1e1f22;
}
.srv-side {
  background: #2b2d31;
  padding: 20px 12px;
  overflow-y: auto;
  border-right: 1px solid var(--border);
  min-height: 0;
}
.srv-side-head {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  padding: 4px 10px 12px;
}
.srv-main {
  overflow-y: auto;
  padding: 40px 48px 64px;
  max-width: none;
  min-height: 0;
  background: #1e1f22;
}
.srv-main h1 {
  font-family: var(--font-display);
  font-size: 26px;
  margin-bottom: 6px;
}

.srv-profile-grid {
  display: grid;
  grid-template-columns: 1fr 260px;
  gap: 24px;
  margin-top: 16px;
}
.srv-preview-card {
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--bg-1);
  height: fit-content;
}
.spc-banner {
  height: 72px;
  background: linear-gradient(120deg, #1a3a2a, #16304a);
  position: relative;
  overflow: hidden;
  display: block;
}
.spc-banner.is-editable {
  cursor: pointer;
}
.spc-banner .media-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  opacity: 0;
  transition: opacity 0.15s ease;
  pointer-events: none;
}
.spc-banner.is-editable:hover .media-overlay,
.spc-banner.is-editable:focus-within .media-overlay {
  opacity: 1;
}
.spc-banner-media {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.spc-body { padding: 0 14px 16px; }
.spc-icon {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  margin-top: -28px;
  background: var(--bg-3);
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 22px;
  border: 4px solid var(--bg-1);
  overflow: hidden;
  position: relative;
}
.spc-icon.is-editable {
  cursor: pointer;
}
.spc-icon-media {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  overflow: hidden;
}
.spc-icon img { width: 100%; height: 100%; object-fit: cover; }
.spc-icon .media-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.5);
  color: #fff;
  opacity: 0;
  transition: opacity 0.15s ease;
  pointer-events: none;
  border-radius: 12px;
}
.spc-icon.is-editable:hover .media-overlay,
.spc-icon.is-editable:focus-within .media-overlay {
  opacity: 1;
}

.perm-default-card {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: 10px;
  text-align: left;
  color: var(--text);
  margin: 12px 0 18px;
}
.perm-default-card p { color: var(--text-dim); font-size: 13px; margin-top: 4px; }
.perm-default-card:hover { background: var(--bg-hover); }

.roles-toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 12px;
}
.roles-table {
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}
.roles-thead, .roles-row {
  display: grid;
  grid-template-columns: 1fr 100px 80px;
  gap: 8px;
  align-items: center;
  padding: 10px 12px;
}
.roles-thead {
  background: var(--bg-1);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-dim);
}
.roles-row { border-top: 1px solid var(--border); }
.roles-row:hover { background: var(--bg-hover); }
.roles-name {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-weight: 600;
  text-align: left;
}
.roles-count {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
  font-size: 13px;
}
.roles-actions { display: flex; justify-content: flex-end; gap: 2px; }

.role-editor {
  display: grid;
  grid-template-columns: 200px minmax(0, 1fr);
  gap: 16px;
  min-height: 420px;
  width: 100%;
}
.role-editor-main {
  min-width: 0;
}
.role-list-side {
  background: var(--bg-0);
  border-radius: 10px;
  padding: 10px;
  border: 1px solid var(--border);
}
.role-list-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.role-side-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 6px;
  color: var(--text-muted);
  text-align: left;
}
.role-side-item:hover, .role-side-item.active {
  background: var(--bg-active);
  color: var(--text);
}
.role-tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin: 12px 0 18px;
}
.role-tabs button {
  padding: 10px 14px;
  color: var(--text-muted);
  font-weight: 600;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.role-tabs button.active {
  color: var(--text);
  border-bottom-color: var(--accent);
}
.color-swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.color-swatch {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid transparent;
}
.color-swatch.active {
  border-color: #fff;
  box-shadow: 0 0 0 2px var(--accent);
}
.member-assign-list { display: flex; flex-direction: column; }

.drag-handle {
  color: var(--text-dim);
  font-size: 12px;
  width: 14px;
  cursor: grab;
}
.roles-row.dragging { opacity: 0.55; background: var(--bg-2); }
.roles-row.draggable { cursor: grab; }

.audit-list { display: flex; flex-direction: column; gap: 10px; }
.audit-item {
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-1);
}
.audit-title { font-size: 14px; margin-bottom: 4px; }
.audit-diff { font-size: 13px; color: var(--text-muted); margin-top: 4px; }
.audit-diff code {
  background: rgba(62, 207, 142, 0.12);
  color: var(--accent);
  padding: 1px 6px;
  border-radius: 4px;
}
.audit-time { font-size: 12px; color: var(--text-dim); margin-top: 8px; }

.perm-group { margin-top: 18px; }

.ch-perm-layout {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 16px;
  min-height: 320px;
  max-height: min(60vh, 520px);
}
.ch-perm-targets {
  overflow: auto;
  border-right: 1px solid var(--border);
  padding-right: 10px;
}
.ch-perm-editor { overflow: auto; }

.tri-state {
  width: 36px;
  height: 28px;
  border-radius: 6px;
  font-weight: 700;
  border: 1px solid var(--border);
  background: var(--bg-2);
  color: var(--text-muted);
}
.tri-state.allow { background: rgba(62, 207, 142, 0.2); color: #3ecf8e; border-color: #3ecf8e; }
.tri-state.deny { background: rgba(231, 76, 60, 0.2); color: #e74c3c; border-color: #e74c3c; }
.tri-state.neutral { color: var(--text-dim); }

.nx-ctx {
  position: fixed;
  z-index: 9999;
  min-width: 180px;
  background: var(--bg-elevated, var(--bg-1));
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px;
  box-shadow: 0 12px 40px rgba(0,0,0,.45);
}
.nx-ctx button {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 10px;
  border-radius: 6px;
  color: var(--text);
  text-align: left;
}
.nx-ctx button:hover { background: var(--bg-hover); }

.modal.modal-lg, .modal.ch-settings {
  width: min(860px, 96vw);
  max-height: 90vh;
  overflow: auto;
}

.role-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  font-size: 12px;
  margin: 2px;
}
.role-pill .role-x {
  margin-left: 2px;
  color: var(--text-dim);
  font-size: 14px;
  line-height: 1;
}
.role-pill.add {
  border-style: dashed;
  cursor: pointer;
  color: var(--accent);
}

@media (max-width: 900px) {
  .srv-settings-app, .role-editor, .srv-profile-grid { grid-template-columns: 1fr; }
  .srv-side, .role-list-side { display: none; }
  .ch-perm-layout { grid-template-columns: 1fr; }
}

