/* Server settings: a quiet workspace with the selected role as its focal point. */
.msg-settings {
  --msg-accent: var(--ct-accent, #abb4ff);
  --msg-surface: var(--ct-float, #222733);
  --msg-nav: var(--ct-panel, #1a1d24);
  --msg-soft: var(--ct-soft, #292e38);
  --msg-input: var(--ct-input, #15191f);
  --msg-line: var(--ct-line, #3b414f);
  --msg-text: var(--ct-text, #edf0f6);
  --msg-muted: var(--ct-muted, #a4adbe);
  --msg-primary: #626bd9;
  --msg-danger: #ffadb4;
  --msg-danger-bg: #ce53651a;
  --msg-success: #8cddb5;
  --msg-success-bg: #4da87818;
  box-sizing: border-box;
  position: fixed;
  inset: 0;
  margin: auto;
  padding: 0;
  width: min(580px, calc(100vw - 32px));
  max-width: none;
  max-height: min(820px, calc(100dvh - 40px));
  overflow: hidden;
  border: 1px solid var(--msg-line);
  border-radius: 18px;
  background: var(--msg-surface);
  color: var(--msg-text);
  box-shadow: 0 30px 110px #0005;
  font: 400 14px/1.5 'Segoe UI', sans-serif;
  text-align: left;
  color-scheme: dark;
}
html[data-community-theme=white] .msg-settings {
  --msg-primary: #535fc1;
  --msg-danger: #b12842;
  --msg-danger-bg: #bb29400a;
  --msg-success: #20764d;
  --msg-success-bg: #28784d0c;
  color-scheme: light;
}
.msg-settings[open] { display: flex; flex-direction: column; }
.msg-settings *, .msg-settings *::before, .msg-settings *::after { box-sizing: border-box; }
.msg-settings [hidden] { display: none !important; }
.msg-settings::backdrop { background: #070a14b8; backdrop-filter: blur(5px); }
.msg-settings.msg-settings-wide { width: min(1120px, calc(100vw - 48px)); height: min(820px, calc(100dvh - 48px)); }
.msg-settings > header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex: 0 0 auto;
  gap: 20px;
  padding: 23px 28px;
  border-bottom: 1px solid var(--msg-line);
}
.msg-settings .msg-dialog-heading { min-width: 0; }
.msg-settings h2 { margin: 0; color: var(--msg-text); font-size: 22px; font-weight: 650; line-height: 1.25; letter-spacing: -.025em; overflow-wrap: anywhere; }
.msg-settings .msg-dialog-subtitle { margin: 6px 0 0; color: var(--msg-muted); font-size: 12px; line-height: 1.5; }
.msg-settings .msg-settings-body { min-width: 0; min-height: 0; padding: 26px 28px 28px; overflow: auto; scrollbar-width: thin; scrollbar-color: var(--msg-line) transparent; }
.msg-settings-wide .msg-settings-body { display: flex; flex: 1 1 0; padding: 0; overflow: hidden; }
.msg-settings button, .msg-settings .msg-upload-button {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  width: auto;
  min-height: 44px;
  margin: 0;
  padding: 10px 15px;
  border: 1px solid var(--msg-line);
  border-radius: 8px;
  background: var(--msg-soft);
  color: var(--msg-text);
  box-shadow: none;
  font: 600 13px/1.4 'Segoe UI', sans-serif;
  text-decoration: none;
  text-align: center;
  cursor: pointer;
  transition: background-color .15s ease, border-color .15s ease, color .15s ease;
}
.msg-settings button:hover, .msg-settings .msg-upload-button:hover { background: color-mix(in srgb, var(--msg-soft) 84%, var(--msg-text)); border-color: color-mix(in srgb, var(--msg-line) 55%, var(--msg-muted)); }
.msg-settings button:active { transform: none; }
.msg-settings button:disabled, .msg-settings input:disabled, .msg-settings select:disabled, .msg-settings .msg-upload-button:has(input:disabled) { opacity: .48; cursor: not-allowed; }
.msg-settings :focus-visible { outline: 2px solid var(--msg-accent); outline-offset: 3px; }
.msg-settings .msg-primary { background: var(--msg-primary); border-color: transparent; color: #fff; }
.msg-settings .msg-primary:hover { background: color-mix(in srgb, var(--msg-primary) 87%, #fff); border-color: transparent; }
.msg-settings .msg-secondary { background: transparent; }
.msg-settings .msg-secondary:hover { background: var(--msg-soft); }
.msg-settings .msg-danger { background: var(--msg-danger-bg); color: var(--msg-danger); border-color: color-mix(in srgb, var(--msg-danger) 25%, transparent); }
.msg-settings .msg-danger:hover { background: color-mix(in srgb, var(--msg-danger) 15%, var(--msg-surface)); border-color: var(--msg-danger); }
.msg-settings button.msg-close { width: 44px; height: 44px; padding: 0; border: 0; background: transparent; color: var(--msg-muted); border-radius: 50%; }
.msg-settings button.msg-close:hover { background: var(--msg-soft); color: var(--msg-text); }
.msg-settings .msg-icon { display: block; width: 20px; height: 20px; flex: 0 0 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.msg-settings .msg-error { flex: 0 0 auto; margin: 0; padding: 12px 28px; background: var(--msg-danger-bg); border-bottom: 1px solid var(--msg-line); color: var(--msg-danger); font-size: 13px; overflow-wrap: anywhere; }
.msg-settings .msg-error:empty { display: none; }
.msg-settings .msg-error[data-kind=success] { background: var(--msg-success-bg); color: var(--msg-success); }
.msg-settings .msg-muted { color: var(--msg-muted); font-size: 13px; line-height: 1.6; }
.msg-settings .msg-note { margin: 20px 0; padding: 12px 15px; border-left: 2px solid var(--msg-accent); background: var(--msg-soft); color: var(--msg-muted); font-size: 13px; line-height: 1.65; }
.msg-settings .msg-empty { margin: 0; padding: 36px 22px; color: var(--msg-muted); text-align: center; font-size: 13px; line-height: 1.7; }

/* The left column provides orientation; only the editing area scrolls. */
.msg-settings .msg-workspace { display: grid; grid-template-columns: 188px minmax(0, 1fr); flex: 1; min-width: 0; min-height: 0; }
.msg-settings .msg-settings-nav { display: flex; flex-direction: column; gap: 5px; min-width: 0; padding: 23px 12px; background: var(--msg-nav); border-right: 1px solid var(--msg-line); overflow-y: auto; scrollbar-width: thin; }
.msg-settings .msg-server-identity { display: flex; align-items: center; gap: 11px; padding: 0 6px 23px; margin-bottom: 10px; border-bottom: 1px solid var(--msg-line); min-width: 0; }
.msg-settings .msg-server-avatar, .msg-settings .msg-member-avatar { display: inline-grid; place-items: center; flex: 0 0 auto; width: 40px; height: 40px; overflow: hidden; border: 1px solid var(--msg-line); border-radius: 12px; background: var(--msg-soft); color: var(--msg-accent); font-size: 14px; font-weight: 650; }
.msg-settings .msg-server-avatar img, .msg-settings .msg-member-avatar img { display: block; width: 100%; height: 100%; object-fit: cover; }
.msg-settings .msg-server-identity > :last-child { min-width: 0; }
.msg-settings .msg-server-name { display: block; min-width: 0; color: var(--msg-text); font-size: 13px; font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-settings .msg-server-identity small { display: block; margin-top: 3px; color: var(--msg-muted); font-size: 11px; }
.msg-settings .msg-nav-caption { margin: 10px 11px 6px; color: var(--msg-muted); font-size: 11px; font-weight: 600; }
.msg-settings .msg-nav-item { justify-content: flex-start; flex-shrink: 0; gap: 11px; width: 100%; min-height: 46px; padding: 11px 12px; border: 0; background: transparent; color: var(--msg-muted); text-align: left; font-weight: 500; }
.msg-settings .msg-nav-item:hover { background: var(--msg-soft); color: var(--msg-text); }
.msg-settings .msg-nav-item[data-active=true] { background: var(--msg-soft); color: var(--msg-accent); font-weight: 650; }
.msg-settings .msg-nav-count { margin-left: auto; color: var(--msg-muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.msg-settings .msg-settings-panel { min-width: 0; min-height: 0; padding: 28px; overflow-y: auto; overflow-x: hidden; scrollbar-width: thin; scrollbar-color: var(--msg-line) transparent; overscroll-behavior: contain; }
.msg-settings .msg-page-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 28px; }
.msg-settings .msg-page-heading > div { min-width: 0; }
.msg-settings h3 { margin: 0; color: var(--msg-text); font-size: 25px; font-weight: 650; letter-spacing: -.035em; line-height: 1.25; overflow-wrap: anywhere; }
.msg-settings .msg-page-heading p { max-width: 65ch; margin: 8px 0 0; color: var(--msg-muted); font-size: 13px; line-height: 1.65; }
.msg-settings .msg-form { min-width: 0; margin: 0; }
.msg-settings .msg-section { min-width: 0; margin: 0 0 28px; padding: 0 0 28px; border-bottom: 1px solid var(--msg-line); }
.msg-settings .msg-section:last-child { margin-bottom: 0; border-bottom: 0; }
.msg-settings h4 { margin: 0 0 7px; color: var(--msg-text); font-size: 15px; font-weight: 650; line-height: 1.4; }
.msg-settings .msg-section > p { margin: 0 0 20px; color: var(--msg-muted); font-size: 13px; line-height: 1.65; max-width: 65ch; }
.msg-settings label { color: var(--msg-text); }
.msg-settings .msg-field { display: flex; flex-direction: column; gap: 8px; min-width: 0; margin: 0 0 20px; }
.msg-settings .msg-field-label { color: var(--msg-text); font-size: 12px; font-weight: 600; line-height: 1.4; }
.msg-settings .msg-field small { color: var(--msg-muted); font-size: 11px; line-height: 1.6; }
.msg-settings input:not([type=checkbox]):not([type=color]):not([type=file]), .msg-settings select, .msg-settings textarea {
  display: block;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  min-height: 44px;
  margin: 0;
  padding: 11px 13px;
  border: 1px solid var(--msg-line);
  border-radius: 8px;
  background: var(--msg-input);
  color: var(--msg-text);
  box-shadow: none;
  font: 400 13px/1.5 'Segoe UI', sans-serif;
}
.msg-settings input::placeholder, .msg-settings textarea::placeholder { color: var(--msg-muted); opacity: .8; }
.msg-settings input[readonly] { color: var(--msg-muted) !important; }
.msg-settings input:focus, .msg-settings select:focus, .msg-settings textarea:focus { border-color: var(--msg-accent); }
.msg-settings input[type=checkbox] { flex: 0 0 auto; width: 18px; height: 18px; min-height: 18px; margin: 0; accent-color: var(--msg-primary); cursor: pointer; }
.msg-settings .msg-form-grid, .msg-settings .msg-media-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; min-width: 0; }
.msg-settings .msg-form-grid .msg-field { margin-bottom: 0; }
.msg-settings .msg-form-grid { margin-bottom: 22px; }
.msg-settings .msg-media-card { min-width: 0; overflow: hidden; border: 1px solid var(--msg-line); border-radius: 10px; }
.msg-settings .msg-media-preview { display: grid; place-items: center; height: 128px; padding: 0; overflow: hidden; background: var(--msg-input); border-bottom: 1px solid var(--msg-line); color: var(--msg-muted); }
.msg-settings .msg-media-preview > img { display: block; width: 100%; height: 100%; object-fit: cover; }
.msg-settings .msg-media-preview > .msg-icon { width: 30px; height: 30px; opacity: .7; }
.msg-settings .msg-media-preview .msg-media-icon { display: grid; place-items: center; width: 72px; height: 72px; overflow: hidden; border-radius: 20px; background: var(--msg-soft); color: var(--msg-accent); font-size: 23px; font-weight: 600; }
.msg-settings .msg-media-icon img { display: block; width: 100%; height: 100%; object-fit: cover; }
.msg-settings .msg-media-preview.msg-media-icon > img,
.msg-settings .msg-media-preview.msg-media-icon > span { display: grid; place-items: center; width: 72px; height: 72px; border-radius: 20px; background: var(--msg-soft); color: var(--msg-accent); font-size: 23px; font-weight: 600; object-fit: cover; }
.msg-settings .msg-media-info { padding: 17px 18px 18px; }
.msg-settings .msg-media-info strong { display: block; font-size: 13px; font-weight: 600; }
.msg-settings .msg-media-info p, .msg-settings .msg-media-info small { display: block; margin: 5px 0 14px; color: var(--msg-muted); font-size: 11px; line-height: 1.65; }
.msg-settings .msg-upload-button { position: relative; margin: 0; overflow: hidden; font-size: 12px; }
.msg-settings .msg-upload-button input[type=file] { position: absolute; inset: 0; width: 100%; height: 100%; padding: 0; margin: 0; opacity: 0; cursor: pointer; }
.msg-settings .msg-upload-button:focus-within { outline: 2px solid var(--msg-accent); outline-offset: 3px; }
.msg-settings .msg-server-media-preview { display: block; max-width: 100%; max-height: 180px; object-fit: contain; border-radius: 10px; margin: 10px 0; }
.msg-settings .msg-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 20px; }
.msg-settings .msg-savebar { position: sticky; bottom: 0; z-index: 3; display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 10px; margin-top: 28px; padding: 14px 16px; border: 1px solid var(--msg-line); border-radius: 10px; background: var(--msg-surface); box-shadow: 0 8px 24px #0002; }
.msg-settings .msg-savebar p { flex: 1 1 140px; margin: 0; color: var(--msg-muted); font-size: 12px; line-height: 1.5; }
.msg-settings .msg-savebar .msg-actions { margin: 0; }

/* Roles: a compact index and a full editor, rather than a list of checkboxes. */
.msg-settings .msg-roles-layout { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 26px; min-width: 0; align-items: start; }
.msg-settings .msg-role-list { min-width: 0; padding-right: 20px; border-right: 1px solid var(--msg-line); }
.msg-settings .msg-role-list > input { margin-bottom: 13px !important; }
.msg-settings .msg-role-items { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.msg-settings .msg-role-item { position: relative; justify-content: flex-start; gap: 10px; width: 100%; min-height: 58px; padding: 10px 12px; border: 1px solid transparent; background: transparent; text-align: left; }
.msg-settings .msg-role-item:hover { background: var(--msg-soft); border-color: transparent; }
.msg-settings .msg-role-item[aria-selected=true] { background: var(--msg-soft); border-color: var(--msg-line); }
.msg-settings .msg-role-item[aria-selected=true]::before { content: ''; position: absolute; top: 14px; bottom: 14px; left: -1px; width: 3px; border-radius: 0 3px 3px 0; background: var(--msg-accent); }
.msg-settings .msg-role-dot { display: inline-block; flex: 0 0 10px; width: 10px; height: 10px; border-radius: 50%; background: var(--msg-accent); box-shadow: inset 0 0 0 1px #ffffff26; }
.msg-settings .msg-role-label { display: block; min-width: 0; flex: 1; }
.msg-settings .msg-role-label strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--msg-text); font-size: 12px; font-weight: 600; }
.msg-settings .msg-role-label small { display: block; margin-top: 3px; color: var(--msg-muted); font-size: 10px; font-weight: 400; }
.msg-settings .msg-badge { display: inline-flex; align-items: center; flex-shrink: 0; gap: 4px; padding: 3px 6px; border: 1px solid var(--msg-line); border-radius: 5px; color: var(--msg-muted); font-size: 9px; line-height: 1.4; font-weight: 500; white-space: nowrap; }
.msg-settings .msg-role-editor { min-width: 0; }
.msg-settings .msg-role-preview { display: grid; grid-template-columns: 40px minmax(0, 1fr); align-items: center; gap: 6px 11px; min-width: 0; margin-bottom: 23px; padding: 15px; border: 1px solid var(--msg-line); border-radius: 10px; background: var(--msg-input); }
.msg-settings .msg-role-preview > div { min-width: 0; }
.msg-settings .msg-role-preview > .msg-server-avatar { grid-row: span 2; }
.msg-settings .msg-role-preview strong { display: block; font-size: 13px; overflow-wrap: anywhere; }
.msg-settings .msg-role-preview small { display: block; margin-top: 3px; color: var(--msg-muted); font-size: 11px; line-height: 1.6; }
.msg-settings .msg-role-preview > .msg-role-chip { grid-column: 2; justify-self: start; margin: 0; }
.msg-settings .msg-role-chip { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; padding: 3px 8px; border: 1px solid var(--msg-line); border-radius: 6px; background: var(--msg-soft); font-size: 10px; font-weight: 500; line-height: 1.5; overflow-wrap: anywhere; }
.msg-settings .msg-role-chip .msg-role-dot { flex-basis: 7px; width: 7px; height: 7px; }
.msg-settings .msg-color-control { display: grid; grid-template-columns: 52px minmax(0, 1fr); gap: 9px; min-width: 0; }
.msg-settings input[type=color] { width: 52px; height: 44px; min-height: 44px; margin: 0; padding: 5px; border: 1px solid var(--msg-line); border-radius: 8px; background: var(--msg-input); cursor: pointer; }
.msg-settings input[type=color]::-webkit-color-swatch-wrapper { padding: 0; }
.msg-settings input[type=color]::-webkit-color-swatch { border: 0; border-radius: 4px; }
.msg-settings input[type=color]::-moz-color-swatch { border: 0; border-radius: 4px; }
.msg-settings .msg-color-presets { display: flex; flex-wrap: wrap; gap: 7px; margin: 0 0 22px; }
.msg-settings .msg-color-presets button { min-width: 44px; width: 44px; min-height: 44px; height: 44px; padding: 0; border: 5px solid var(--msg-surface); border-radius: 12px; box-shadow: 0 0 0 1px var(--msg-line); }
.msg-settings .msg-color-presets button:hover, .msg-settings .msg-color-presets button[aria-pressed=true] { box-shadow: 0 0 0 2px var(--msg-accent); }
.msg-settings .msg-permission-search { margin: 23px 0 21px !important; }
.msg-settings .msg-permission-group { margin-top: 23px; }
.msg-settings .msg-permission-group > h4 { font-size: 13px; }
.msg-settings .msg-permission-group > p { margin: 5px 0 12px; color: var(--msg-muted); font-size: 11px; line-height: 1.6; }
.msg-settings .msg-permission { display: flex; flex-direction: row; align-items: center; justify-content: space-between; gap: 18px; min-width: 0; min-height: 76px; margin: 0; padding: 14px 0; border-bottom: 1px solid var(--msg-line); cursor: pointer; }
.msg-settings .msg-permission-copy { display: block; flex: 1; min-width: 0; }
.msg-settings .msg-permission-copy strong { display: block; font-size: 12px; line-height: 1.5; font-weight: 600; overflow-wrap: anywhere; }
.msg-settings .msg-permission-copy small { display: block; margin-top: 5px; color: var(--msg-muted); font-size: 11px; line-height: 1.6; }
.msg-settings .msg-permission input[type=checkbox] { position: relative; appearance: none; -webkit-appearance: none; flex: 0 0 40px; width: 40px; height: 24px; min-height: 24px; margin: 0; padding: 0; border: 1px solid color-mix(in srgb, var(--msg-line) 60%, var(--msg-muted)); border-radius: 20px; background: var(--msg-soft); box-shadow: none; transition: background-color .15s ease; }
.msg-settings .msg-permission input[type=checkbox]::after { content: ''; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: var(--msg-muted); transition: transform .15s ease, background-color .15s ease; }
.msg-settings .msg-permission input[type=checkbox]:checked { border-color: var(--msg-primary); background: var(--msg-primary); }
.msg-settings .msg-permission input[type=checkbox]:checked::after { transform: translateX(16px); background: #fff; }
.msg-settings .msg-permission-danger { margin-top: 15px; padding: 14px; border: 1px solid color-mix(in srgb, var(--msg-danger) 22%, transparent); border-radius: 9px; background: var(--msg-danger-bg); }
.msg-settings .msg-permission-danger .msg-permission-copy strong { color: var(--msg-danger); }
.msg-settings .msg-permission-count { margin: 8px 0 0; color: var(--msg-muted); font-size: 11px; line-height: 1.5; }

/* Members and channel overrides keep the same visual rhythm as the role editor. */
.msg-settings .msg-member-search { margin-bottom: 20px !important; }
.msg-settings .msg-member-list, .msg-settings .msg-channel-list { min-width: 0; border-top: 1px solid var(--msg-line); }
.msg-settings .msg-member { margin: 0; padding: 0; border-bottom: 1px solid var(--msg-line); }
.msg-settings .msg-member > summary { display: flex; align-items: center; gap: 12px; min-width: 0; min-height: 76px; padding: 14px 4px; list-style: none; cursor: pointer; }
.msg-settings .msg-member > summary::-webkit-details-marker { display: none; }
.msg-settings .msg-member > summary::after { content: ''; flex: 0 0 7px; width: 7px; height: 7px; margin: 0 8px 0 auto; border-right: 1.5px solid var(--msg-muted); border-bottom: 1.5px solid var(--msg-muted); transform: rotate(45deg); }
.msg-settings .msg-member[open] > summary::after { transform: rotate(225deg); }
.msg-settings .msg-member > summary > div { min-width: 0; }
.msg-settings .msg-member > summary strong { display: block; font-size: 13px; font-weight: 600; overflow-wrap: anywhere; }
.msg-settings .msg-member > summary small { color: var(--msg-muted); font-size: 11px; }
.msg-settings .msg-member .msg-role-chip { margin: 5px 4px 0 0; }
.msg-settings .msg-member-roles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 3px 20px; padding: 0 14px 18px 56px; }
.msg-settings .msg-check { display: flex; flex-direction: row; align-items: center; gap: 10px; min-width: 0; min-height: 44px; margin: 0; padding: 9px 0; font-size: 12px; overflow-wrap: anywhere; cursor: pointer; }
.msg-settings .msg-check > span { min-width: 0; }
.msg-settings .msg-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; min-width: 0; padding: 15px 0; border-bottom: 1px solid var(--msg-line); }
.msg-settings .msg-channel-icon { display: grid; place-items: center; flex: 0 0 40px; width: 40px; height: 40px; border: 1px solid var(--msg-line); border-radius: 10px; background: var(--msg-soft); color: var(--msg-muted); font-size: 20px; }
.msg-settings .msg-row-copy { flex: 1; min-width: 0; }
.msg-settings .msg-row-copy strong { display: block; color: var(--msg-text); font-size: 13px; font-weight: 600; overflow-wrap: anywhere; }
.msg-settings .msg-row-copy small { display: block; margin-top: 3px; color: var(--msg-muted); font-size: 11px; }
.msg-settings .msg-overwrite { min-width: 0; margin: 10px 0; padding: 0; border: 1px solid var(--msg-line); border-radius: 9px; }
.msg-settings .msg-overwrite > summary { min-height: 48px; padding: 13px 16px; color: var(--msg-text); font-size: 12px; font-weight: 600; cursor: pointer; overflow-wrap: anywhere; }
.msg-settings .msg-overwrite > summary::marker { color: var(--msg-muted); }
.msg-settings .msg-overwrite[open] > summary { border-bottom: 1px solid var(--msg-line); }
.msg-settings .msg-overwrite-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; padding: 18px 16px; }
.msg-settings .msg-overwrite-fields label { display: grid; gap: 7px; min-width: 0; margin: 0; font-size: 12px; }
.msg-settings .msg-overwrite-fields .msg-field { margin: 0; }

/* Server rail remains compatible with the messenger's existing navigation. */
.com-server-rail { overflow-y: auto; }
#community .com-channels > .com-channel-scroll > details { display: none; }
#community .msg-server-icon { font-size: 14px; }
#community .com-server-rail .msg-server-icon:has(img) { padding: 0; overflow: hidden; }
#community .com-server-rail .msg-server-icon img { display: block; width: 100%; height: 100%; object-fit: cover; border-radius: inherit; }

@media (max-width: 1000px) {
  .msg-settings .msg-workspace { grid-template-columns: 164px minmax(0, 1fr); }
  .msg-settings .msg-settings-panel { padding: 24px; }
  .msg-settings .msg-roles-layout { grid-template-columns: 180px minmax(0, 1fr); gap: 20px; }
  .msg-settings .msg-role-list { padding-right: 15px; }
  .msg-settings .msg-roles-layout .msg-form-grid { grid-template-columns: 1fr; }
  .msg-settings .msg-role-item { padding-inline: 9px; gap: 8px; }
  .msg-settings .msg-role-item .msg-badge { display: none; }
}
@media (max-width: 760px) {
  .msg-settings, .msg-settings.msg-settings-wide { width: calc(100vw - 20px); max-height: calc(100dvh - 20px); border-radius: 13px; }
  .msg-settings.msg-settings-wide { height: calc(100dvh - 20px); }
  .msg-settings > header { gap: 12px; padding: 16px 18px; }
  .msg-settings h2 { font-size: 19px; }
  .msg-settings .msg-dialog-subtitle { font-size: 11px; }
  .msg-settings .msg-settings-body { padding: 20px 18px; }
  .msg-settings-wide .msg-settings-body { padding: 0; }
  .msg-settings .msg-error { padding: 11px 18px; font-size: 12px; }
  .msg-settings .msg-workspace { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }
  .msg-settings .msg-settings-nav { flex-direction: row; align-items: center; gap: 5px; padding: 9px 12px; border-right: 0; border-bottom: 1px solid var(--msg-line); overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
  .msg-settings .msg-settings-nav::-webkit-scrollbar { display: none; }
  .msg-settings .msg-server-identity, .msg-settings .msg-nav-caption { display: none; }
  .msg-settings .msg-nav-item { flex: 0 0 auto; width: auto; min-height: 44px; padding: 10px 12px; gap: 7px; font-size: 12px; white-space: nowrap; }
  .msg-settings .msg-nav-item .msg-icon { width: 17px; height: 17px; flex-basis: 17px; }
  .msg-settings .msg-nav-count { margin-left: 2px; font-size: 10px; }
  .msg-settings .msg-settings-panel { padding: 23px 18px; }
  .msg-settings .msg-page-heading { gap: 14px; margin-bottom: 23px; }
  .msg-settings h3 { font-size: 23px; }
  .msg-settings .msg-page-heading p { font-size: 12px; }
  .msg-settings .msg-page-heading > button { padding-inline: 12px; font-size: 12px; }
  .msg-settings .msg-section { margin-bottom: 24px; padding-bottom: 24px; }
  .msg-settings .msg-form-grid, .msg-settings .msg-media-grid { gap: 16px; }
  .msg-settings .msg-roles-layout { display: block; }
  .msg-settings .msg-role-list { margin-bottom: 25px; padding: 0 0 18px; border-right: 0; border-bottom: 1px solid var(--msg-line); }
  .msg-settings .msg-role-items { flex-direction: row; gap: 7px; padding: 2px; overflow-x: auto; overflow-y: hidden; scrollbar-width: thin; scrollbar-color: var(--msg-line) transparent; }
  .msg-settings .msg-role-item { flex: 0 0 156px; width: 156px; min-height: 59px; }
  .msg-settings .msg-role-list > input { margin-bottom: 10px !important; }
  .msg-settings .msg-roles-layout .msg-form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .msg-settings .msg-role-preview { margin-bottom: 23px; }
  .msg-settings .msg-permission { gap: 16px; min-height: 80px; }
  .msg-settings .msg-savebar { margin-top: 24px; padding: 12px; gap: 8px; }
  .msg-settings .msg-savebar p { flex-basis: 100%; }
  .msg-settings .msg-savebar button { flex-grow: 1; }
  .msg-settings .msg-savebar .msg-actions { flex: 1; flex-wrap: nowrap; }
  .msg-settings .msg-member-roles { padding-left: 4px; padding-right: 4px; }
}
@media (max-width: 480px) {
  .msg-settings > header { padding: 14px 15px; }
  .msg-settings .msg-settings-panel { padding: 22px 15px; }
  .msg-settings .msg-settings-body { padding: 20px 15px; }
  .msg-settings-wide .msg-settings-body { padding: 0; }
  .msg-settings .msg-page-heading { flex-wrap: wrap; }
  .msg-settings .msg-page-heading > div { flex: 1 1 100%; }
  .msg-settings .msg-page-heading > button { margin-top: 0; }
  .msg-settings .msg-form-grid, .msg-settings .msg-media-grid, .msg-settings .msg-roles-layout .msg-form-grid, .msg-settings .msg-overwrite-fields { grid-template-columns: minmax(0, 1fr); }
  .msg-settings .msg-media-card { display: grid; grid-template-columns: 94px minmax(0, 1fr); }
  .msg-settings .msg-media-preview { height: 100%; min-height: 155px; border-bottom: 0; border-right: 1px solid var(--msg-line); }
  .msg-settings .msg-media-preview .msg-media-icon { width: 58px; height: 58px; border-radius: 16px; font-size: 20px; }
  .msg-settings .msg-media-preview.msg-media-icon > img, .msg-settings .msg-media-preview.msg-media-icon > span { width: 58px; height: 58px; border-radius: 16px; font-size: 20px; }
  .msg-settings .msg-media-info { padding: 15px 13px; }
  .msg-settings .msg-media-info p, .msg-settings .msg-media-info small { margin-bottom: 12px; }
  .msg-settings .msg-upload-button { padding-inline: 10px; font-size: 11px; }
  .msg-settings .msg-actions { gap: 8px; }
  .msg-settings .msg-actions > button { flex: 1 1 auto; }
  .msg-settings .msg-member-roles { grid-template-columns: minmax(0, 1fr); }
  .msg-settings .msg-member > summary { gap: 9px; }
  .msg-settings .msg-row { gap: 10px; flex-wrap: wrap; }
  .msg-settings .msg-row > button { margin-left: 50px; }
  .msg-settings .msg-row-copy { flex-basis: calc(100% - 54px); }
  .msg-settings .msg-savebar { position: sticky; bottom: 0; }
  .msg-settings .msg-note { padding: 11px 12px; font-size: 12px; }
}
@media (prefers-reduced-motion: reduce) {
  .msg-settings *, .msg-settings *::before, .msg-settings *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}


.msg-settings .msg-server-name strong { display: block; overflow: hidden; text-overflow: ellipsis; }
.msg-settings .msg-server-name small { white-space: normal; font-weight: 400; }
.msg-settings .msg-savebar[data-dirty=true] { border-color: var(--msg-accent); }

@media (min-width: 761px) { .msg-settings .msg-role-list { position: sticky; top: 0; max-height: calc(100dvh - 250px); overflow-y: auto; scrollbar-width: thin; scrollbar-color: var(--msg-line) transparent; } }

/* Timed mute and ban controls. */
.msg-settings .msg-member-moderation{margin:0 14px 18px 56px;padding:14px;border:1px solid var(--msg-line);border-radius:10px;background:var(--msg-soft)}
.msg-settings .msg-member-moderation h4{margin:0 0 4px;color:var(--msg-text);font-size:12px}
.msg-settings .msg-member-moderation p{margin:0 0 12px;font-size:11px}
.msg-settings .msg-sanction-duration{margin-bottom:10px}
.msg-settings .msg-member-moderation .msg-actions{margin-top:8px}
.msg-settings .msg-banned-row{padding-inline:4px}
@media(max-width:760px){.msg-settings .msg-member-moderation{margin-left:4px;margin-right:4px}.msg-settings .msg-member-moderation .msg-actions>button{flex:1 1 120px}}
