﻿/* â”€â”€â”€ Modals (shared overlay) â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal {
  background: var(--surface0);
  border: 1px solid var(--surface1);
  border-radius: calc(var(--radius) * 1.5);
  padding: 1.5rem;
  width: 380px;
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
  box-shadow: 0 8px 40px rgba(0,0,0,0.4);
  animation: modal-in 0.15s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-header h2 { font-size: 1.05rem; font-weight: 700; }

.modal form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.modal-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
}

.modal-label {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--subtext0);
  margin-bottom: -0.25rem;
}

/* â”€â”€â”€ Settings modal â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€ */
.settings-modal { width: 420px; }

.settings-section h3 {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--subtext0);
  margin-bottom: 0.75rem;
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--surface1);
  gap: 1rem;
}
.setting-row:last-child { border-bottom: none; }

.setting-row input[type="text"] {
  width: 160px;
  flex-shrink: 0;
}

.setting-label { font-weight: 600; font-size: 0.9rem; }
.setting-desc  { font-size: 0.78rem; color: var(--subtext0); margin-top: 2px; }
.setting-label-group { display: flex; flex-direction: column; }

/* Toggle switch */
.toggle-btn {
  width: 44px;
  height: 24px;
  border-radius: 999px;
  background: var(--surface2);
  border: none;
  cursor: pointer;
  position: relative;
  flex-shrink: 0;
  transition: background 0.2s;
}
.toggle-btn[aria-checked="true"] { background: var(--primary); }
.toggle-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.2s;
  pointer-events: none;
}
.toggle-btn[aria-checked="true"] .toggle-thumb { transform: translateX(20px); }

/* â”€â”€â”€ Scrollbar â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€ */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--surface2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--overlay0); }

/* â”€â”€â”€ Server Settings page-modal â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€ */
.server-settings-modal {
  display: flex;
  width: 860px;
  max-width: 96vw;
  height: 660px;
  max-height: 92vh;
  background: var(--surface0);
  border: 1px solid var(--surface1);
  border-radius: calc(var(--radius) * 1.5);
  box-shadow: 0 8px 40px rgba(0,0,0,0.4);
  animation: modal-in 0.15s cubic-bezier(0.34, 1.56, 0.64, 1) both;
  overflow: hidden;
}

.server-settings-sidebar {
  width: 192px;
  flex-shrink: 0;
  background: var(--base);
  display: flex;
  flex-direction: column;
  padding: 1.5rem 0.5rem 1rem;
  gap: 0.1rem;
  overflow-y: auto;
}

.ss-server-name {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--subtext0);
  padding: 0 0.75rem;
  margin-bottom: 0.4rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ss-nav-section-label {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--subtext0);
  padding: 0.75rem 0.75rem 0.15rem;
  margin: 0;
}

.ss-nav-item {
  display: flex;
  align-items: center;
  width: 100%;
  padding: 0.4rem 0.75rem;
  border: none;
  background: none;
  font-family: inherit;
  font-size: 0.88rem;
  color: var(--subtext1);
  text-align: left;
  border-radius: calc(var(--radius) * 0.75);
  cursor: pointer;
  transition: background 0.1s, color 0.1s;
}
.ss-nav-item:hover { background: var(--surface1); color: var(--text); }
.ss-nav-item.active { background: var(--surface1); color: var(--text); font-weight: 600; }
.ss-nav-item--danger { color: var(--red); margin-top: auto; }
.ss-nav-item--danger:hover { background: var(--red); color: #fff; }

.ss-nav-divider {
  height: 1px;
  background: var(--surface1);
  margin: 0.5rem 0.75rem;
}

.server-settings-content {
  flex: 1;
  overflow: hidden;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
}

.ss-panel-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 1.5rem;
}

.ss-panel { display: flex; flex-direction: column; flex: 1; min-height: 0; overflow-y: auto; }
.ss-panel.hidden { display: none; }
#ss-panel-roles    { overflow: hidden; }
#ss-panel-channels { overflow: hidden; }

.ss-textarea {
  width: 200px;
  resize: vertical;
  min-height: 72px;
  max-width: 200px;
  background: var(--surface1);
  border: 1px solid var(--surface2);
  border-radius: var(--radius);
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
  padding: 0.45rem 0.6rem;
  transition: border-color 0.15s;
}
.ss-textarea:focus { outline: none; border-color: var(--primary); }

.ss-members-list { display: flex; flex-direction: column; }

.ss-member-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.45rem 0.25rem;
  border-bottom: 1px solid var(--surface1);
}
.ss-member-row:last-child { border-bottom: none; }

.ss-member-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 700;
  color: #fff;
  overflow: hidden;
}
.ss-member-avatar img { width: 100%; height: 100%; object-fit: cover; }

.ss-member-name {
  flex: 1;
  font-size: 0.9rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ss-member-role-select {
  background: var(--surface1);
  border: 1px solid var(--surface2);
  color: var(--text);
  font-family: inherit;
  font-size: 0.82rem;
  padding: 0.2rem 0.35rem;
  border-radius: calc(var(--radius) * 0.75);
  cursor: pointer;
  transition: border-color 0.15s;
}
.ss-member-role-select:focus { outline: none; border-color: var(--primary); }
.ss-member-role-select:disabled { opacity: 0.5; cursor: default; }

/* ─── User Settings page-modal ───────────────────────────────── */
.user-settings-modal {
  display: flex;
  width: 700px;
  max-width: 96vw;
  height: 520px;
  max-height: 90vh;
  background: var(--surface0);
  border: 1px solid var(--surface1);
  border-radius: calc(var(--radius) * 1.5);
  box-shadow: 0 8px 40px rgba(0,0,0,0.4);
  animation: modal-in 0.15s cubic-bezier(0.34, 1.56, 0.64, 1) both;
  overflow: hidden;
}

.user-settings-sidebar {
  width: 192px;
  flex-shrink: 0;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  padding: 1.5rem 0.5rem 1rem;
  gap: 0.1rem;
  overflow-y: auto;
}

.us-section-label {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--subtext0);
  padding: 0 0.75rem;
  margin-bottom: 0.15rem;
  margin-top: 0.75rem;
}
.us-section-label:first-child { margin-top: 0; }

.us-nav-item {
  display: flex;
  align-items: center;
  width: 100%;
  padding: 0.4rem 0.75rem;
  border: none;
  background: none;
  font-family: inherit;
  font-size: 0.88rem;
  color: var(--subtext1);
  text-align: left;
  border-radius: calc(var(--radius) * 0.75);
  cursor: pointer;
  transition: background 0.1s, color 0.1s;
}
.us-nav-item:hover { background: var(--surface1); color: var(--text); }
.us-nav-item.active { background: var(--surface1); color: var(--text); font-weight: 600; }

.user-settings-content {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem 2rem;
  display: flex;
  flex-direction: column;
}

.us-content-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}

.us-panel-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text);
}

.us-panel { display: flex; flex-direction: column; flex: 1; }
.us-panel.hidden { display: none; }

.us-setting-section-title {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--subtext0);
  margin-bottom: 0.75rem;
}

/* Theme picker */
.theme-picker {
  display: flex;
  gap: 1.25rem;
  flex-wrap: wrap;
}

.theme-swatch {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.5rem;
  border-radius: var(--radius);
  transition: background 0.15s;
  position: relative;
}
.theme-swatch:hover { background: var(--surface1); }
.theme-swatch.active { background: var(--surface1); }

.theme-swatch-circle {
  display: block;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
  transition: transform 0.15s, box-shadow 0.15s;
}
.theme-swatch:hover .theme-swatch-circle { transform: scale(1.08); }
.theme-swatch.active .theme-swatch-circle { outline: 3px solid var(--text); outline-offset: 3px; }

.theme-swatch-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--subtext1);
}
.theme-swatch.active .theme-swatch-label { color: var(--text); }

.theme-swatch-check {
  position: absolute;
  top: 6px;
  right: 6px;
  font-size: 0.65rem;
  font-weight: 900;
  color: var(--text);
  opacity: 0;
  transition: opacity 0.15s;
}
.theme-swatch.active .theme-swatch-check { opacity: 1; }

.setting-value {
  font-size: 0.9rem;
  color: var(--subtext0);
  font-weight: 500;
}

/* ============================================================
   Server Settings — split layout, role editor, permission UX
   ============================================================ */

.ss-split-layout {
  display: flex;
  flex: 1;
  min-height: 0;
  border: 1px solid var(--surface1);
  border-radius: var(--radius);
  overflow: hidden;
}

.ss-split-left {
  width: 172px;
  flex-shrink: 0;
  background: var(--mantle, var(--base));
  border-right: 1px solid var(--surface1);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.ss-split-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--surface1);
  flex-shrink: 0;
}

.ss-item-list {
  flex: 1;
  overflow-y: auto;
  padding: 0.35rem;
}

.ss-split-right {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 1.25rem;
}

.ss-list-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.35rem 0.6rem;
  border: none;
  background: none;
  font-family: inherit;
  font-size: 0.85rem;
  color: var(--subtext1);
  text-align: left;
  border-radius: calc(var(--radius) * 0.75);
  cursor: pointer;
  transition: background 0.1s;
}
.ss-list-item:hover  { background: var(--surface1); color: var(--text); }
.ss-list-item.active { background: var(--surface1); color: var(--text); font-weight: 600; }
.ss-list-item--has-override { color: var(--text); }

.ss-role-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--subtext0);
}

.ss-override-badge {
  margin-left: auto;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--primary);
  color: #fff;
  padding: 0.1rem 0.35rem;
  border-radius: 999px;
}

.ss-placeholder {
  color: var(--subtext0);
  font-size: 0.85rem;
  text-align: center;
  margin-top: 2rem;
}
.ss-loading { color: var(--subtext0); font-size: 0.85rem; }
.ss-error   { color: var(--red);      font-size: 0.85rem; }

.ss-editor-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.ss-editor-title {
  font-size: 1rem;
  font-weight: 700;
  margin: 0;
}

.ss-section-heading {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--subtext0);
  margin: 1rem 0 0.5rem;
}

.ss-field-row {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-bottom: 0.75rem;
}
.ss-field-row label { font-size: 0.82rem; color: var(--subtext1); font-weight: 600; }
.ss-field-row input[type="text"] { width: 100%; max-width: 280px; }

.ss-slider-row {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}
.ss-slider-row input[type="range"] {
  flex: 1;
  max-width: 220px;
  accent-color: var(--primary);
  cursor: pointer;
}
.ss-slider-value {
  min-width: 2.2rem;
  text-align: right;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
}

.ss-color-picker {
  width: 44px;
  height: 32px;
  padding: 2px;
  border-radius: var(--radius);
  border: 1px solid var(--surface2);
  cursor: pointer;
  background: var(--surface1);
}

.ss-perm-note {
  font-size: 0.78rem;
  color: var(--subtext0);
  margin: 0 0 0.75rem;
}

/* Permission rows */
.perm-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--surface1);
  gap: 1rem;
}
.perm-row:last-child { border-bottom: none; }
.perm-info  { display: flex; flex-direction: column; gap: 0.1rem; flex: 1; min-width: 0; }
.perm-label { font-size: 0.88rem; font-weight: 600; }
.perm-desc  { font-size: 0.75rem; color: var(--subtext0); }

/* ON/OFF toggle (role permissions) */
.perm-toggle {
  flex-shrink: 0;
  padding: 0.2rem 0.65rem;
  border-radius: 999px;
  border: none;
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.perm-toggle--on  { background: var(--primary); color: #fff; }
.perm-toggle--off { background: var(--surface2); color: var(--subtext1); }
.perm-toggle--off:hover { background: var(--overlay0); color: var(--text); }

/* 3-state override buttons */
.perm-tristate { display: flex; gap: 2px; flex-shrink: 0; }
.perm-state-btn {
  width: 28px;
  height: 28px;
  border: 1px solid var(--surface2);
  border-radius: calc(var(--radius) * 0.75);
  background: var(--surface1);
  color: var(--subtext1);
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}
.perm-state-btn:hover { background: var(--overlay0); color: var(--text); }
.perm-state--deny.active    { background: var(--red);            color: #fff; border-color: var(--red); }
.perm-state--inherit.active { background: var(--surface2);       color: var(--text); }
.perm-state--allow.active   { background: var(--green, #40a02b); color: #fff; border-color: var(--green, #40a02b); }

/* Save bar */
.ss-save-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 1.25rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--surface1);
}
.ss-save-status { flex: 1; font-size: 0.82rem; margin: 0; }
.btn-sm { font-size: 0.78rem; padding: 0.25rem 0.65rem; }

/* Member role chips */
.ss-member-row {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.6rem 0.25rem;
  border-bottom: 1px solid var(--surface1);
}
.ss-member-row:last-child { border-bottom: none; }

.ss-member-info { display: flex; flex-direction: column; justify-content: center; }
.ss-member-name { font-size: 0.88rem; font-weight: 600; }

.ss-member-roles-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.ss-member-role-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  min-height: 1.5rem;
  align-items: center;
}

.ss-role-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  border: 1px solid var(--surface2);
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--surface1);
}
.ss-chip-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--subtext0);
  flex-shrink: 0;
}
.ss-chip-remove {
  cursor: pointer;
  color: var(--subtext0);
  font-size: 0.85rem;
  line-height: 1;
  padding-left: 0.1rem;
}
.ss-chip-remove:hover { color: var(--red); }

.ss-you-badge {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 700;
  background: var(--primary);
  color: #fff;
  border-radius: 999px;
  padding: 0.05rem 0.35rem;
  margin-left: 0.35rem;
  vertical-align: middle;
}

.ss-role-add-select {
  background: var(--surface1);
  border: 1px solid var(--surface2);
  color: var(--text);
  font-family: inherit;
  font-size: 0.8rem;
  padding: 0.15rem 0.3rem;
  border-radius: calc(var(--radius) * 0.75);
  cursor: pointer;
  max-width: 180px;
}
.ss-role-add-select:focus { outline: none; border-color: var(--primary); }

/* Channel tree */
.ss-tree-category { margin-bottom: 0.6rem; }

.ss-tree-cat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.3rem 0.5rem;
  border-radius: var(--radius);
  background: var(--surface1);
  font-weight: 700;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--subtext1);
  margin-bottom: 0.15rem;
}
.ss-tree-cat-name { flex: 1; }

.ss-tree-channel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.3rem 0.5rem 0.3rem 1.25rem;
  border-radius: var(--radius);
  font-size: 0.88rem;
  color: var(--subtext1);
}
.ss-tree-channel:hover { background: var(--surface0); color: var(--text); }

/* Channel / Category detail panels */
.ss-detail-section {
  margin-bottom: 1.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--surface1);
}
.ss-detail-section:last-child { border-bottom: none; }

.ss-override-split {
  display: flex;
  border: 1px solid var(--surface1);
  border-radius: var(--radius);
  overflow: hidden;
  min-height: 200px;
}
.ss-override-role-list {
  width: 148px;
  flex-shrink: 0;
  background: var(--mantle, var(--base));
  border-right: 1px solid var(--surface1);
  padding: 0.35rem;
  overflow-y: auto;
}
.ss-override-editor {
  flex: 1;
  padding: 1rem;
  overflow-y: auto;
}

.ss-textarea {
  background: var(--surface1);
  border: 1px solid var(--surface2);
  border-radius: var(--radius);
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
  padding: 0.5rem 0.65rem;
  width: 100%;
  max-width: 360px;
  resize: vertical;
}
.ss-textarea:focus { outline: none; border-color: var(--primary); }

/* ─── CDN / Media panel ─────────────────────────────────────────── */
.ss-icon-upload-row {
  display: flex;
  align-items: flex-end;
  gap: 1rem;
  margin-top: 0.5rem;
}
.ss-icon-preview-wrap {
  width: 72px;
  height: 72px;
  border-radius: var(--radius);
  border: 2px dashed var(--surface2);
  background: var(--surface1);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
}
.ss-icon-preview {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.ss-icon-no-icon {
  font-size: 0.7rem;
  color: var(--subtext0);
  text-align: center;
  padding: 0.25rem;
  line-height: 1.3;
}
.ss-icon-actions {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.ss-icon-upload-label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0.28rem 0.65rem;
  border-radius: var(--radius);
  font-size: 0.78rem;
  font-weight: 600;
  border: 1px solid var(--surface2);
  background: var(--surface1);
  color: var(--text);
  transition: background 0.15s;
}
.ss-icon-upload-label:hover { background: var(--surface2); }

.ss-cdn-stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.5rem;
  margin-top: 0.5rem;
}
.ss-cdn-stat {
  background: var(--surface1);
  border-radius: var(--radius);
  padding: 0.55rem 0.75rem;
}
.ss-cdn-stat-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--subtext0);
}
.ss-cdn-stat-value {
  font-size: 0.9rem;
  font-weight: 700;
  margin-top: 0.15rem;
  color: var(--text);
}
