/* ══════════════════════════════════════
   BMA Manager Dashboard — Global Styles
   Calm Professional Redesign
   ══════════════════════════════════════ */

:root {
  /* ── Premium Black ── */
  --bg-base:        #121214;
  --bg-sidebar:     #161618;
  --bg-card:        #1B1B1E;
  --bg-card-hover:  #222226;
  --bg-hover:       rgba(255, 255, 255, 0.045);
  --bg-active:      rgba(201, 184, 150, 0.12);
  --bg-input:       #141416;
  --bg-modal:       #1B1B1E;
  --server-bar:     #0E0E10;

  --text-primary:   #E6E4E0;
  --text-muted:     #9C9892;
  --text-dimmed:    #6B6762;

  --accent:         #C9B896;
  --accent-secondary: #A8926A;
  --accent-hover:   #E0D4BC;
  --accent-dim:     rgba(201, 184, 150, 0.12);
  --accent-glow:    rgba(201, 184, 150, 0.18);
  --star-color:     #C9B896;
  --star-rgb:       201,184,150;

  --success:        #8FA887;
  --danger:         #C46B5C;
  --warning:        #C4A35A;

  --border:         rgba(255, 255, 255, 0.07);
  --border-active:  rgba(201, 184, 150, 0.38);
  --card-shadow:    0 10px 28px rgba(0, 0, 0, 0.32);

  --font-display:   'Syne', 'Plus Jakarta Sans', sans-serif;
  --font:           'Outfit', 'Plus Jakarta Sans', sans-serif;

  --server-size:    44px;
  --sidebar-w:      244px;
  --radius:         12px;
  --radius-sm:      8px;
  --control-h:      42px;
  --nav-h:          40px;
  --text-xs:        11px;
  --text-sm:        13px;
  --text-md:        14px;
  --text-lg:        16px;
  --text-xl:        20px;
  color-scheme: dark;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  position: relative;
  font-family: var(--font);
  background-color: var(--bg-base);
  background-image:
    radial-gradient(ellipse at 12% 0%, rgba(201, 184, 150, 0.06), transparent 42%),
    radial-gradient(ellipse at 100% 100%, rgba(0, 0, 0, 0.45), transparent 46%);
  color: var(--text-primary);
  height: 100vh;
  overflow: hidden;
  isolation: isolate;
  -webkit-font-smoothing: antialiased;
  letter-spacing: 0.01em;
}

/* ─── SCREEN VISIBILITY ─── */
.screen { display: none; }
.screen.active {
  display: flex;
  animation: fadeIn 0.3s ease-out forwards;
}

.main-content > * {
  animation: fadeInUp 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

#dashboard-view-content {
  animation: fadeIn 0.35s ease-out forwards;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ══════════════════════════════════════
   LOGIN SCREEN
   ══════════════════════════════════════ */
#login-screen {
  position: relative;
  min-height: 100vh;
  justify-content: center;
  align-items: center;
  background: var(--bg-base);
}

.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 48px 40px;
  width: 420px;
  text-align: center;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.4);
}

.login-logo {
  font-size: 56px;
  color: var(--accent);
  margin-bottom: 20px;
  filter: drop-shadow(0 0 16px var(--accent-glow));
}

.login-card h1 {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 800;
  margin-bottom: 10px;
  letter-spacing: -0.3px;
  color: var(--text-primary);
}

.login-card > p {
  color: var(--text-muted);
  font-size: 14px;
  margin-bottom: 30px;
  line-height: 1.6;
}

.btn-login-discord {
  background: linear-gradient(135deg, #5865F2, #4752C4);
  color: #ffffff;
  border: none;
  border-radius: 12px;
  padding: 14px 24px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  transition: all 0.2s ease;
  box-shadow: 0 4px 16px rgba(88, 101, 242, 0.35);
}

.btn-login-discord:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(88, 101, 242, 0.45);
}

.login-note {
  margin-top: 20px;
  color: var(--text-dimmed);
  font-size: 12px;
  line-height: 1.5;
}

/* ══════════════════════════════════════
   DASHBOARD LAYOUT
   ══════════════════════════════════════ */
#dashboard-screen {
  position: relative;
  height: 100vh;
  overflow: hidden;
  background: var(--bg-base);
}

/* SERVER ICON BAR */
.server-list-container {
  display: flex;
  flex-direction: column;
  background: var(--server-bar);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  height: 100vh;
  width: 76px;
  min-width: 76px;
  border-right: 1px solid var(--border);
  justify-content: space-between;
  align-items: center;
  padding: 16px 0;
}

.server-list {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  overflow-y: auto;
  scrollbar-width: none;
  width: 100%;
}

.server-list::-webkit-scrollbar { display: none; }

.user-avatar-container {
  position: relative;
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  width: 100%;
  display: flex;
  justify-content: center;
}

.user-avatar-btn {
  width: var(--server-size);
  height: var(--server-size);
  border-radius: 50%;
  cursor: pointer;
  object-fit: cover;
  transition: all 0.2s ease;
  background: var(--bg-card);
  border: 2px solid transparent;
}

.user-avatar-btn:hover {
  border-radius: 14px;
  border-color: var(--accent);
}

.user-dropdown {
  position: absolute;
  bottom: 0;
  left: 84px;
  background: var(--bg-sidebar);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px;
  display: none;
  min-width: 140px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  z-index: 10000;
}

.user-dropdown.open { display: block; }

.dropdown-logout-btn {
  background: transparent;
  border: none;
  color: var(--danger);
  width: 100%;
  text-align: left;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border-radius: 6px;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: background 0.2s;
}

.dropdown-logout-btn:hover {
  background: var(--bg-hover);
}

.server-icon-wrap {
  position: relative;
  cursor: pointer;
}

.server-icon-wrap::before {
  content: '';
  position: absolute;
  left: -10px;
  top: 50%;
  transform: translateY(-50%) scaleY(0);
  width: 4px;
  height: 8px;
  background: var(--text-muted);
  border-radius: 0 4px 4px 0;
  transition: all 0.2s ease;
}

.server-icon-wrap:hover::before,
.server-icon-wrap.active::before {
  transform: translateY(-50%) scaleY(1);
  height: 20px;
}

.server-icon-wrap.active::before {
  height: 36px;
  background: var(--accent);
}

.server-icon {
  width: var(--server-size);
  height: var(--server-size);
  border-radius: 50%;
  object-fit: cover;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-card);
  font-weight: 700;
  font-size: 16px;
  color: var(--text-primary);
  overflow: hidden;
  border: 1px solid var(--border);
}

.server-icon-wrap:hover .server-icon {
  border-radius: 14px;
  background: var(--bg-hover);
  border-color: var(--accent);
}

.server-icon-wrap.active .server-icon {
  border-radius: 14px;
  border-color: var(--accent);
}

.server-icon img { width: 100%; height: 100%; object-fit: cover; }

.server-icon-tooltip {
  position: absolute;
  left: 80px;
  top: 50%;
  transform: translateY(-50%);
  background: var(--bg-card);
  color: var(--text-primary);
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
  border: 1px solid var(--border);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  z-index: 1000;
}

.server-icon-wrap:hover .server-icon-tooltip { opacity: 1; }

/* SIDEBAR NAVIGATION */
.nav-sidebar {
  width: var(--sidebar-w);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  height: 100vh;
  transition: width 0.3s ease;
  overflow: hidden;
}

.sidebar-guild-header {
  padding: 22px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.15);
}

.sidebar-guild-img {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  object-fit: cover;
  border: 1px solid var(--border);
}

.sidebar-guild-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 15px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-primary);
}

.sidebar-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 20px 12px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.nav-section-title {
  font-size: 11px;
  font-weight: 800;
  color: var(--text-dimmed);
  text-transform: uppercase;
  letter-spacing: 1.2px;
  padding-left: 12px;
  margin-bottom: 10px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s ease;
  border-left: 3px solid transparent;
}

.nav-link:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
  transform: translateX(2px);
}

.nav-link.active {
  color: var(--text-primary);
  background: var(--accent-dim);
  border-left-color: var(--accent);
  box-shadow: inset 3px 0 0 var(--accent);
}

.nav-icon {
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  color: var(--accent);
}

.nav-link.active .nav-icon {
  color: #ffffff;
}

.module-status {
  margin-left: auto;
  font-size: 11px;
}

.module-status.enabled { color: var(--success); }

/* MAIN CONTENT AREA */
.main-content {
  position: relative;
  flex: 1;
  height: 100vh;
  overflow-y: auto;
  padding: 20px 44px 36px;
  background: var(--bg-base);
}


.global-docs-link {
  position: absolute;
  z-index: 5;
  top: 20px;
  right: 28px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 13px;
  border: 1px solid var(--border-active);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .2);
  transition: color .2s ease, background .2s ease, transform .2s ease;
}

.global-docs-link:hover {
  background: var(--accent-dim);
  color: var(--accent-hover);
  transform: translateY(-1px);
}

.view-header {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-bottom: 36px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border);
}

.view-icon {
  font-size: 28px;
  color: var(--accent);
  filter: drop-shadow(0 0 6px var(--accent-glow));
}

.view-header h2 {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.view-subtitle {
  color: var(--text-muted);
  font-size: 14px;
  margin-top: 4px;
}

/* ══════════════════════════════════════
   FORMS & INPUTS
   ══════════════════════════════════════ */
.form-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 20px;
}

.form-field label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.form-field input[type="text"],
.form-field textarea {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text-primary);
  padding: 12px 16px;
  font-family: inherit;
  font-size: 14px;
  outline: none;
  transition: all 0.2s ease;
}

.form-field input:focus,
.form-field textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
  background: #111728;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.form-select {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text-primary);
  padding: 12px 16px;
  font-family: inherit;
  font-size: 14px;
  outline: none;
  transition: all 0.2s ease;
}

.form-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

/* BUTTONS */
.btn-primary {
  background: var(--accent);
  color: #161618;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 11px 22px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: none;
}

.btn-primary:hover {
  background: var(--accent-hover);
  color: #121214;
  border-color: var(--border-active);
  transform: translateY(-1px);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.28);
}

.btn-primary:active {
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

.btn-ghost {
  background: rgba(30, 41, 59, 0.6);
  color: #cbd5e1;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  padding: 11px 22px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: all 0.25s ease;
  backdrop-filter: blur(8px);
}

.btn-ghost:hover {
  color: #ffffff;
  background: rgba(51, 65, 85, 0.8);
  border-color: rgba(255, 255, 255, 0.2);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

/* ══════════════════════════════════════
   MODAL OVERLAY
   ══════════════════════════════════════ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  display: none;
  justify-content: center;
  align-items: center;
  padding: 20px;
  overflow-y: auto;
  z-index: 100000;
}

.modal-overlay.open,
.modal-overlay.active {
  display: flex;
}

.modal-box {
  background: var(--bg-modal);
  border: 1px solid var(--border);
  border-radius: 18px;
  width: 520px;
  max-width: min(90vw, 520px);
  max-height: calc(100vh - 40px);
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.6);
  overflow: auto;
  animation: modalEnter 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalEnter {
  from { opacity: 0; transform: scale(0.96) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-head {
  padding: 22px 26px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(0, 0, 0, 0.15);
}

.modal-head h3 {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 24px;
  cursor: pointer;
  transition: color 0.15s;
}

.modal-close:hover { color: var(--danger); }

.confirm-modal-box .modal-body {
  padding: 24px;
}

.confirm-modal-box .modal-body p {
  margin: 0;
  line-height: 1.6;
  color: var(--text-primary);
}

.confirm-subtle {
  display: block;
  margin-top: 6px;
  color: var(--text-muted);
  font-size: 13px;
}

#autoreply-form { padding: 26px; }

.modal-foot {
  padding: 18px 26px;
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  border-top: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.15);
}

/* ══════════════════════════════════════
   TOASTS
   ══════════════════════════════════════ */
.toast {
  position: fixed;
  top: 24px;
  right: 24px;
  left: auto;
  bottom: auto;
  max-width: 340px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  color: var(--text-primary);
  padding: 16px 24px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  z-index: 999999;
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  transform: translateY(-10px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}

.toast.show { opacity: 1; transform: translateY(0); }
.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--danger); }

/* ─── LOADER ─── */
.view-loader-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 60vh;
  gap: 16px;
  color: var(--text-muted);
}

.view-loader-spinner {
  width: 44px;
  height: 44px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ─── GLOBAL FORM CONTROLS & FIELD INPUTS ─── */
.field-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.field-group label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.field-input {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 14px;
  outline: none;
  width: 100%;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.field-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-glow);
}

.field-input::placeholder {
  color: var(--text-dimmed);
}

/* Textarea specific overrides */
textarea.field-input {
  resize: vertical;
  line-height: 1.5;
  min-height: 90px;
  unicode-bidi: plaintext;
}

/* Select dropdown specific overrides */
select,
select.field-input,
.form-select {
  cursor: pointer;
  background-color: var(--bg-input);
  color: var(--text-primary);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%238892a8'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 16px;
  padding-right: 38px;
  appearance: none;
  -webkit-appearance: none;
}

select option,
.form-select option {
  background: var(--bg-card);
  color: var(--text-primary);
}

/* Field hints */
.field-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
  line-height: 1.4;
}

/* ─── GLOBAL TOGGLE SWITCHES ─── */
.toggle-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.toggle {
  position: relative;
  width: 44px;
  height: 24px;
  display: inline-block;
  flex-shrink: 0;
}

.toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--bg-active);
  border-radius: 24px;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
  border: 1px solid var(--border);
}

.toggle-slider:before {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  left: 2px;
  top: 2px;
  background: var(--text-dimmed);
  border-radius: 50%;
  transition: transform 0.2s, background-color 0.2s;
}

.toggle input:checked + .toggle-slider {
  background: var(--accent-dim);
  border-color: var(--accent);
}

.toggle input:checked + .toggle-slider:before {
  transform: translateX(20px);
  background: var(--accent);
}

.toggle-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(23, 27, 36, 0.3);
}

.toggle-row:last-child {
  border-bottom: none;
}

.toggle-row span {
  font-size: 14px;
  color: var(--text-primary);
}

/* ══════════════════════════════════════
   RESPONSIVE — ALL DEVICES
   ══════════════════════════════════════ */

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  height: 100vh;
  height: 100dvh;
}

#login-screen {
  min-height: 100vh;
  min-height: 100dvh;
  padding: 16px;
}

#dashboard-screen {
  height: 100vh;
  height: 100dvh;
  width: 100%;
  min-width: 0;
  position: relative;
}

.main-content {
  min-width: 0;
  flex: 1;
  -webkit-overflow-scrolling: touch;
}

/* Mobile top bar & sidebar overlay (hidden on desktop) */
.mobile-dash-header,
.sidebar-backdrop {
  display: none;
}

.mobile-dash-header {
  position: fixed;
  top: 0;
  right: 0;
  left: var(--mobile-content-left, 76px);
  z-index: 8500;
  height: var(--mobile-header-h, 52px);
  padding: 0 16px;
  padding-top: env(safe-area-inset-top, 0);
  align-items: center;
  gap: 12px;
  background: rgba(15, 17, 23, 0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.mobile-menu-btn {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-active);
  color: var(--text-primary);
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.2s, border-color 0.2s;
}

.mobile-menu-btn:hover {
  background: var(--bg-hover);
  border-color: var(--text-muted);
}

.mobile-header-title {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 8990;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.sidebar-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

body.mobile-nav-open {
  overflow: hidden;
}

/* Tablet & small laptop */
@media (max-width: 1200px) {
  .main-content {
    padding: 16px 24px 28px;
  }
}

@media (max-width: 1024px) {
  :root {
    --sidebar-w: 220px;
  }

  .main-content {
    padding: 24px 20px;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .view-header {
    flex-wrap: wrap;
    gap: 16px;
  }

  .view-header h2 {
    font-size: 20px;
  }
}

/* iPad portrait & large phones in landscape */
@media (max-width: 768px) {
  :root {
    --mobile-header-h: 52px;
    --mobile-content-left: 76px;
  }

  .mobile-dash-header,
  .sidebar-backdrop {
    display: flex;
  }

  .nav-sidebar {
    position: fixed;
    top: 0;
    left: 76px;
    bottom: 0;
    width: min(280px, calc(100vw - 76px));
    max-width: 280px;
    z-index: 9000;
    transform: translateX(-110%);
    transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 8px 0 32px rgba(0, 0, 0, 0.4);
  }

  .nav-sidebar.open {
    transform: translateX(0);
  }

  .main-content {
    padding: calc(var(--mobile-header-h) + env(safe-area-inset-top, 0) + 12px) 16px 24px;
    padding-bottom: calc(24px + env(safe-area-inset-bottom, 0));
  }

  .view-header {
    margin-bottom: 24px;
    padding-bottom: 16px;
  }

  .view-header > .search-box,
  .view-header > .btn-primary,
  .view-header > [style*="margin-left:auto"] {
    margin-left: 0 !important;
    width: 100%;
  }

  .view-header .search-box {
    width: 100%;
  }

  .view-icon {
    font-size: 24px;
  }

  .modal-foot {
    flex-wrap: wrap;
    justify-content: stretch;
  }

  .modal-foot .btn-primary,
  .modal-foot .btn-ghost {
    flex: 1;
    justify-content: center;
    min-width: 120px;
  }

  .toast {
    left: 16px;
    right: 16px;
    bottom: calc(16px + env(safe-area-inset-bottom, 0));
  }

  .user-dropdown {
    left: auto;
    right: 0;
    bottom: calc(100% + 8px);
    min-width: 160px;
  }

  .server-icon-tooltip {
    display: none;
  }
}

@media (hover: none) {
  .server-icon-wrap:hover .server-icon-tooltip {
    opacity: 0;
  }
}

/* Phones */
@media (max-width: 480px) {
  :root {
    --server-size: 40px;
    --mobile-content-left: 60px;
  }

  .login-card {
    width: 100%;
    max-width: 420px;
    padding: 32px 24px;
  }

  .login-logo {
    font-size: 48px;
  }

  .login-card h1 {
    font-size: 22px;
  }

  .server-list-container {
    width: 60px;
    min-width: 60px;
    padding: 12px 0;
    padding-bottom: calc(12px + env(safe-area-inset-bottom, 0));
  }

  .nav-sidebar {
    left: 60px;
    width: min(260px, calc(100vw - 60px));
  }

  .mobile-dash-header {
    left: 60px;
    padding-left: 12px;
    padding-right: 12px;
  }

  .main-content {
    padding-left: 12px;
    padding-right: 12px;
  }

  .view-header h2 {
    font-size: 18px;
  }

  .view-subtitle {
    font-size: 13px;
  }

  .btn-primary,
  .btn-ghost {
    padding: 10px 16px;
  }

  .command-header {
    flex-wrap: wrap;
  }

  .toggle-row {
    flex-wrap: wrap;
    gap: 10px;
    align-items: flex-start;
  }

  .radio-row {
    flex-direction: column;
    gap: 12px;
  }
}

/* ══════════════════════════════════════
   AI ASSISTANT WIDGET
   ══════════════════════════════════════ */

/* FAB Button */
.ai-assistant-fab {
  position: fixed;
  right: 26px;
  bottom: 26px;
  width: 56px;
  height: 56px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-card);
  border: 1px solid var(--border);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  color: var(--text-primary);
  cursor: pointer;
  z-index: 9999;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s;
}

.ai-assistant-fab:hover {
  transform: translateY(-2px) scale(1.04);
  border-color: var(--accent);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5), 0 0 16px var(--accent-glow);
}

.ai-assistant-fab i {
  font-size: 22px;
  color: var(--accent);
}

/* Main Chat Panel */
.ai-assistant-chat {
  position: fixed;
  right: 26px;
  bottom: 46px;
  width: 320px;
  max-width: calc(100vw - 26px);
  height: 420px;
  max-height: calc(100vh - 80px);
  display: flex;
  flex-direction: column;
  background: var(--bg-sidebar);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.45);
  overflow: hidden;
  z-index: 10000;
  transition: width 0.3s cubic-bezier(0.16,1,0.3,1),
              height 0.3s cubic-bezier(0.16,1,0.3,1),
              right 0.3s cubic-bezier(0.16,1,0.3,1),
              bottom 0.3s cubic-bezier(0.16,1,0.3,1),
              border-radius 0.3s ease;
}

/* Maximized state */
.ai-assistant-chat.is-maximized {
  right: 12px;
  bottom: 12px;
  width: calc(100vw - 24px);
  height: calc(100vh - 24px);
  max-width: none;
  border-radius: 14px;
  background: var(--bg-base);
}

.ai-assistant-chat.is-maximized .ai-chat-messages-wrap,
.ai-assistant-chat.is-maximized .ai-chat-bottom {
  max-width: 860px;
  margin-left: auto;
  margin-right: auto;
  width: 100%;
}

/* Header */
.ai-chat-head {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.01);
}

.ai-chat-title-wrap {
  display: flex;
  align-items: center;
  gap: 11px;
}

.ai-chat-bot-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-dim);
  border: 1px solid var(--accent-glow);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  flex-shrink: 0;
}

.ai-chat-bot-icon i {
  font-size: 15px;
  color: var(--accent);
}

.ai-chat-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.2px;
}

.ai-chat-subtitle {
  color: var(--text-dimmed);
  font-size: 11px;
  margin-top: 1px;
  display: flex;
  align-items: center;
  gap: 5px;
}

.ai-status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 6px rgba(78, 202, 139, 0.5);
  display: inline-block;
  animation: statusPulse 2s ease-in-out infinite;
}

@keyframes statusPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.ai-chat-head-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.ai-chat-maximize,
.ai-chat-close {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: transparent;
  border: none;
  color: var(--text-dimmed);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  transition: background 0.15s, color 0.15s;
}

.ai-chat-maximize:hover { background: var(--bg-hover); color: var(--text-primary); }
.ai-chat-close:hover { background: rgba(229, 96, 77, 0.12); color: var(--danger); }

/* Messages area */
.ai-chat-messages-wrap {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scrollbar-width: thin;
  scrollbar-color: rgba(136, 146, 168, 0.12) transparent;
}

.ai-chat-messages-wrap::-webkit-scrollbar { width: 4px; }
.ai-chat-messages-wrap::-webkit-scrollbar-track { background: transparent; }
.ai-chat-messages-wrap::-webkit-scrollbar-thumb { background: rgba(136, 146, 168, 0.15); border-radius: 4px; }

/* Legacy .ai-chat-body alias */
.ai-chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scrollbar-width: thin;
  scrollbar-color: rgba(136, 146, 168, 0.12) transparent;
}

.ai-chat-body::-webkit-scrollbar { width: 4px; }
.ai-chat-body::-webkit-scrollbar-track { background: transparent; }
.ai-chat-body::-webkit-scrollbar-thumb { background: rgba(136, 146, 168, 0.15); border-radius: 4px; }

/* Bubbles */
.ai-chat-bubble {
  border-radius: 14px;
  padding: 11px 14px;
  font-size: 13px;
  line-height: 1.65;
  max-width: 94%;
  word-break: break-word;
  animation: bubbleIn 0.2s cubic-bezier(0.16,1,0.3,1);
}

@keyframes bubbleIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.ai-chat-bubble-bot {
  background: var(--bg-hover);
  border: 1px solid var(--border);
  color: var(--text-primary);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}

.ai-chat-bubble-me {
  background: var(--accent-dim);
  border: 1px solid var(--accent-glow);
  color: var(--text-primary);
  align-self: flex-end;
  border-bottom-right-radius: 4px;
  text-align: right;
}

/* Bottom area (chips + input) */
.ai-chat-bottom {
  flex-shrink: 0;
  border-top: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.1);
}

/* Slash command chips */
.ai-chat-prompts {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px 14px 8px;
}

.ai-prompt-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--bg-hover);
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 11.5px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  white-space: nowrap;
}

.ai-prompt-chip:hover {
  background: var(--bg-active);
  border-color: rgba(255, 255, 255, 0.15);
  color: var(--text-primary);
}

.ai-prompt-chip .chip-slash {
  font-weight: 700;
  color: var(--text-dimmed);
  font-size: 13px;
  line-height: 1;
}

/* Input row */
.ai-chat-input-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px 12px;
  position: relative;
}

.ai-chat-input-box {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
}

.ai-chat-input-prefix {
  position: absolute;
  left: 12px;
  color: var(--text-dimmed);
  font-size: 14px;
  pointer-events: none;
  font-weight: 600;
}

.ai-chat-input {
  flex: 1;
  width: 100%;
  background: var(--bg-hover);
  border: 1px solid var(--border);
  border-radius: 10px;
  height: 42px;
  color: var(--text-primary);
  padding: 0 44px 0 14px;
  outline: none;
  font-family: inherit;
  font-size: 13px;
  transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
}

.ai-chat-input:focus {
  border-color: var(--accent);
  background: var(--bg-active);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.ai-chat-input.slash-mode {
  padding-left: 26px;
}

.ai-chat-input::placeholder {
  color: var(--text-dimmed);
}

.ai-chat-send {
  position: absolute;
  right: 20px;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--accent-dim);
  border: 1px solid var(--accent-glow);
  color: var(--accent);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}

.ai-chat-send:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  transform: scale(1.05);
}

.ai-chat-send:active {
  transform: scale(0.95);
}

/* Slash command dropdown */
.ai-slash-dropdown {
  position: absolute;
  bottom: 100%;
  left: 12px;
  right: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.4);
  overflow: hidden;
  display: none;
  z-index: 100;
  margin-bottom: 6px;
  animation: dropUp 0.18s cubic-bezier(0.16,1,0.3,1);
}

@keyframes dropUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.ai-slash-dropdown.open { display: block; }

.ai-slash-header {
  padding: 8px 14px 6px;
  font-size: 10px;
  font-weight: 700;
  color: var(--text-dimmed);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  border-bottom: 1px solid var(--border);
}

.ai-slash-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 14px;
  cursor: pointer;
  transition: background 0.12s;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.ai-slash-item:last-child { border-bottom: none; }

.ai-slash-item:hover,
.ai-slash-item.focused {
  background: var(--bg-hover);
}

.ai-slash-item-icon {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--bg-active);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  color: var(--text-muted);
  flex-shrink: 0;
  margin-top: 1px;
}

.ai-slash-item-info {
  flex: 1;
  min-width: 0;
}

.ai-slash-item-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 4px;
}

.ai-slash-item-name span.cmd-slash {
  color: var(--text-dimmed);
  font-weight: 700;
}

.ai-slash-item-desc {
  font-size: 11.5px;
  color: var(--text-dimmed);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Thinking animation */
.ai-thinking-dots span {
  display: inline-block;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--text-muted);
  margin: 0 2px;
  animation: dotBounce 1.2s ease-in-out infinite;
}

.ai-thinking-dots span:nth-child(2) { animation-delay: 0.2s; }
.ai-thinking-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes dotBounce {
  0%, 100% { transform: translateY(0); opacity: 0.4; }
  50% { transform: translateY(-4px); opacity: 1; }
}

.apply-status-button-alt {
  background: var(--bg-hover);
  border: 1px solid var(--border);
}

@media (max-width: 680px) {
  .ai-assistant-chat {
    right: 12px;
    left: 12px;
    bottom: 88px;
    width: auto;
    height: 70dvh;
  }

  .ai-assistant-fab {
    right: 16px;
    bottom: 16px;
  }
}

@media (max-width: 360px) {
  .sidebar-guild-name {
    font-size: 14px;
  }

  .nav-link {
    font-size: 13px;
    padding: 9px 10px;
  }
}


/* ══════════════════════════════════════
   Premium Black — unified theme & sizing
   ══════════════════════════════════════ */

.night-sky {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse at 18% -10%, rgba(201, 184, 150, 0.08), transparent 38%),
    radial-gradient(ellipse at 88% 110%, rgba(0, 0, 0, 0.55), transparent 42%),
    #121214;
}

.star-layer,
.night-sky::before,
.night-sky::after,
.skyline,
body::after {
  display: none !important;
}

.screen,
.modal-overlay,
.toast,
.ai-assistant-fab,
.ai-assistant-chat {
  position: relative;
  z-index: 1;
}

.modal-overlay,
.toast,
.ai-assistant-fab,
.ai-assistant-chat,
.global-unsaved-bar {
  position: fixed;
}

#login-screen,
#dashboard-screen,
.main-content {
  background: transparent;
}

#dashboard-screen.active {
  display: flex;
}

.login-card {
  width: min(400px, calc(100vw - 32px));
  padding: 36px 32px;
  border-radius: var(--radius);
  background: var(--bg-card);
  box-shadow: var(--card-shadow);
}

.login-logo {
  font-size: 40px;
  filter: none;
}

.login-card h1 {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.login-card > p {
  font-size: var(--text-sm);
  margin-bottom: 24px;
}

.btn-login-discord {
  height: var(--control-h);
  border-radius: var(--radius-sm);
  font-size: var(--text-md);
  background: #5865F2;
  box-shadow: 0 8px 20px rgba(88, 101, 242, 0.22);
}

.server-list-container {
  width: 72px;
  min-width: 72px;
  padding: 14px 0;
  background: var(--server-bar);
  backdrop-filter: none;
}

.nav-sidebar {
  width: var(--sidebar-w);
  background: var(--bg-sidebar);
  font-family: var(--font);
}

.sidebar-guild-header {
  position: relative;
  padding: 16px 14px;
  gap: 10px;
  min-height: 72px;
  background: transparent;
  cursor: pointer;
}

.sidebar-guild-img {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}

.sidebar-guild-name {
  flex: 1;
  min-width: 0;
  font-size: var(--text-md);
  font-weight: 600;
  letter-spacing: -0.01em;
}

.sidebar-header-actions,
.mobile-header-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.theme-toggle-btn {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--accent-dim);
  color: var(--accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform .18s ease, background .18s ease;
}

.theme-toggle-btn:hover {
  transform: translateY(-1px);
  background: var(--accent-dim);
}

.theme-toggle-login {
  position: absolute;
  top: 18px;
  right: 18px;
  z-index: 5;
}

.star-color-btn {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--accent-dim);
  color: var(--accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform .18s ease, background .18s ease;
}

.star-color-btn:hover {
  transform: translateY(-1px);
  background: rgba(201, 184, 150, 0.2);
}

.mobile-star-color { margin-left: 0; }

.sidebar-scroll {
  padding: 10px 8px 18px;
  gap: 6px;
}

.nav-section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.12em;
  padding: 12px 10px 8px;
  margin: 0;
  cursor: pointer;
  user-select: none;
}

.nav-section-title::after {
  content: '\f107';
  font-family: 'Font Awesome 6 Free';
  font-weight: 900;
  font-size: 10px;
  color: var(--text-dimmed);
}

.nav-section.collapsed .nav-link { display: none; }
.nav-section.collapsed .nav-section-title::after { content: '\f105'; }

.nav-link {
  min-height: var(--nav-h);
  height: var(--nav-h);
  margin: 2px 0;
  padding: 0 12px;
  gap: 10px;
  font-size: var(--text-sm);
  font-weight: 500;
  border-radius: var(--radius-sm);
  border-left: 0;
}

.nav-link:hover {
  transform: none;
  background: var(--bg-hover);
}

.nav-link.active {
  color: var(--text-primary);
  background: var(--accent-dim);
  border-left: 0;
  box-shadow: inset 3px 0 0 var(--accent);
}

.nav-icon {
  width: 18px;
  min-width: 18px;
  font-size: 14px;
  color: var(--text-dimmed);
  filter: none;
}

.nav-link:hover .nav-icon,
.nav-link.active .nav-icon {
  color: var(--accent);
  filter: none;
}

.module-status.enabled {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--success);
}

.main-content {
  padding: 28px 32px 40px;
}

.main-content::before { display: none; }

.view-header {
  align-items: center;
  gap: 14px;
  margin-bottom: 24px;
  padding: 16px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  box-shadow: none;
}

.view-header h2 {
  font-size: var(--text-xl);
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.02em;
}

.view-subtitle {
  font-size: var(--text-sm);
  margin-top: 2px;
}

.view-icon {
  font-size: 20px;
  filter: none;
  color: var(--accent);
}

.form-field { gap: 6px; margin-bottom: 16px; }
.form-field label { font-size: var(--text-xs); }

.form-field input[type="text"],
.form-field textarea,
.form-select,
.field-input,
input[type="text"],
input[type="number"],
textarea,
select {
  min-height: var(--control-h);
  padding: 10px 14px;
  font-size: var(--text-md);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text-primary);
}

.form-field input:focus,
.form-field textarea:focus,
.form-select:focus {
  background: #17171a;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.btn-primary,
.btn-ghost,
.btn-send-panel,
.btn-add-element {
  min-height: var(--control-h);
  padding: 0 18px;
  font-size: var(--text-md);
  border-radius: var(--radius-sm);
}

.btn-primary,
.btn-send-panel,
.btn-add-element {
  background: var(--accent);
  color: #161618;
  border: 1px solid transparent;
  box-shadow: none;
  font-weight: 650;
}

.btn-primary:hover,
.btn-send-panel:hover,
.btn-add-element:hover {
  background: var(--accent-hover);
  color: #121214;
  transform: translateY(-1px);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.28);
}

.btn-ghost {
  background: transparent;
  color: var(--text-primary);
  border: 1px solid var(--border);
}

.modal-box {
  border-radius: var(--radius);
  background: var(--bg-modal);
}

.modal-head { padding: 16px 20px; }
.modal-head h3 { font-size: var(--text-lg); }
#autoreply-form { padding: 20px; }

[class*="card"],
[class*="panel"]:not(.nav-):not(.ms-):not(.ss-),
.command-item,
.command-card,
.reply-card,
.invite-card,
.log-item,
.editor-section,
.system-panel-card,
.ticket-panel-card,
.security-card,
.apply-card,
.premium-card,
.toggle-row {
  background: var(--bg-card);
  border-color: var(--border);
  box-shadow: none;
  border-radius: var(--radius);
}

.nav-section,
.nav-section-title,
.sidebar-scroll,
.modal-head,
.modal-foot {
  background: transparent;
  box-shadow: none;
}

.toggle { width: 42px; height: 24px; }
.toggle-slider:before { width: 18px; height: 18px; }

.ai-assistant-fab {
  width: 48px;
  height: 48px;
  border-radius: var(--radius);
  background: var(--bg-card);
}

.ai-assistant-fab i { font-size: 18px; filter: none; }

.ai-assistant-chat {
  width: 360px;
  height: 500px;
  border-radius: var(--radius);
  background: var(--bg-sidebar);
}

/* Mini sidebar */
body.mini-sidebar { --sidebar-w: 76px; }

body.mini-sidebar .sidebar-guild-header {
  justify-content: center;
  padding: 16px 8px;
}

body.mini-sidebar .sidebar-guild-name,
body.mini-sidebar .star-color-btn,
body.mini-sidebar .nav-link span:not(.nav-icon),
body.mini-sidebar .module-status,
body.mini-sidebar .nav-section-title {
  display: none;
}

body.mini-sidebar .sidebar-header-actions {
  margin-left: 0;
}

body.mini-sidebar .theme-toggle-btn {
  display: inline-flex;
}

body.mini-sidebar .nav-link {
  justify-content: center;
  padding: 0;
  margin: 4px 8px;
}

body.mini-sidebar .sidebar-guild-img {
  width: 40px;
  height: 40px;
}

/* ── Unsaved changes bar ── */
.global-unsaved-bar {
  left: 50%;
  bottom: 18px;
  z-index: 2500;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  width: min(680px, calc(100vw - 28px));
  min-height: 56px;
  padding: 10px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--card-shadow);
  transform: translate(-50%, 130%);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.22s ease, opacity 0.22s ease;
}

.global-unsaved-bar.show {
  transform: translate(-50%, 0);
  opacity: 1;
  pointer-events: auto;
}

.global-unsaved-message {
  color: var(--text-primary);
  font-size: var(--text-md);
  font-weight: 600;
}

.global-unsaved-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.global-unsaved-btn {
  min-width: 120px;
  height: 40px;
  border: 0;
  border-radius: var(--radius-sm);
  color: #161618;
  cursor: pointer;
  font-family: inherit;
  font-size: var(--text-sm);
  font-weight: 600;
}

.global-unsaved-btn.secondary {
  background: #2A2A2E;
  color: var(--text-primary);
}

.global-unsaved-btn.primary { background: var(--accent); }

@media (max-width: 680px) {
  .global-unsaved-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    padding: 12px;
  }
  .global-unsaved-btn { width: 100%; min-width: 0; }
}

/* Scrollbars */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 8px;
}
::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.18); }

/* Searchable selects */
.ms-search-wrap {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
}

.ms-search-icon {
  color: var(--text-muted);
  font-size: 12px;
  flex-shrink: 0;
}

.ms-search-input {
  flex: 1;
  min-height: 28px !important;
  background: transparent !important;
  border: none !important;
  outline: none !important;
  color: var(--text-primary);
  font-size: var(--text-sm);
  padding: 2px 0 !important;
  box-shadow: none !important;
}

.ms-options-list { overflow-y: auto; max-height: 176px; }

.ss-wrapper { position: relative; width: 100%; z-index: 3; }

.ss-wrapper > select {
  display: none !important;
  position: absolute !important;
  width: 0 !important;
  height: 0 !important;
  min-height: 0 !important;
  padding: 0 !important;
  margin: 0 !important;
  border: 0 !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

.ss-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: var(--control-h);
  padding: 8px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: var(--text-md);
  cursor: pointer;
}

.ss-trigger .ss-display {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ss-chevron {
  font-size: 11px;
  color: var(--text-muted);
  transition: transform 0.18s ease;
  flex-shrink: 0;
}

.ss-trigger.open .ss-chevron { transform: rotate(180deg); }

.ss-trigger:hover {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.ss-trigger.open {
  border-color: var(--accent);
  border-bottom-color: transparent;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  box-shadow: none;
}

.ss-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 40;
  background: var(--bg-input);
  border: 1px solid var(--accent);
  border-top: none;
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  box-shadow: 0 16px 28px rgba(0, 0, 0, 0.45);
  overflow: hidden;
  max-height: 260px;
}

.ss-dropdown.open { display: block; }

.ss-dropdown .ms-search-wrap {
  background: var(--bg-input);
}

.ss-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  font-size: var(--text-sm);
  color: var(--text-primary);
  cursor: pointer;
}

.ss-option .ss-hash {
  flex-shrink: 0;
  color: var(--text-dimmed);
  font-weight: 700;
}

.ss-option .ss-opt-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ss-option:hover,
.ss-option.sel {
  background: var(--accent-dim);
  color: var(--accent);
}

.ss-option:hover .ss-hash,
.ss-option.sel .ss-hash { color: var(--accent); }

.send-modal-overlay { z-index: 4000; }
.send-modal-box { overflow: visible; }
.send-modal-body { overflow: visible; position: relative; z-index: 2; }

/* Mobile */
@media (max-width: 768px) {
  .main-content {
    padding: calc(var(--mobile-header-h, 52px) + 12px) 16px 24px;
  }


  .view-header {
    padding: 14px;
    margin-bottom: 16px;
  }

  .view-header h2 { font-size: 18px; }
}

@media (max-width: 480px) {
  :root {
    --server-size: 40px;
    --mobile-content-left: 60px;
    --control-h: 40px;
  }

  .login-card { padding: 28px 20px; }
  .login-logo { font-size: 36px; }
  .login-card h1 { font-size: 20px; }
  .view-header h2 { font-size: 17px; }
}

@media (prefers-reduced-motion: reduce) {
  .star-layer,
  .main-content > *,
  .screen.active,
  .ai-status-dot,
  .view-loader-spinner {
    animation: none !important;
  }
}

.settings-panel,
.welcome-card,
.security-module-card,
.invite-card,
.premium-card,
.ticket-panel-card,
.system-panel-card,
.autoreply-card,
.log-card {
  border-radius: var(--radius);
}

.security-module-card > .card-header,
.security-head {
  padding-left: 20px;
  padding-right: 20px;
}

.mobile-dash-header {
  background: rgba(18, 18, 20, 0.94);
}

.search-box {
  min-height: var(--control-h);
  padding: 0 14px;
}

/* Light surfaces only — existing palettes / accents are unchanged */
html[data-theme="light"] {
  --bg-base:        #F4F1EA;
  --bg-sidebar:     #EDE9E1;
  --bg-card:        #FFFCF7;
  --bg-card-hover:  #F7F3EB;
  --bg-hover:       rgba(28, 26, 22, 0.05);
  --bg-input:       #FFFFFF;
  --bg-modal:       #FFFCF7;
  --server-bar:     #E6E1D8;
  --text-primary:   #1C1A16;
  --text-muted:     #6A655F;
  --text-dimmed:    #8E877E;
  --border:         rgba(28, 26, 22, 0.10);
  --card-shadow:    0 10px 28px rgba(40, 32, 18, 0.08);
  color-scheme: light;
}

html[data-theme="light"] body {
  background-color: var(--bg-base);
  background-image:
    radial-gradient(ellipse at 12% 0%, rgba(201, 184, 150, 0.12), transparent 42%),
    radial-gradient(ellipse at 100% 100%, rgba(255, 255, 255, 0.7), transparent 46%);
}

html[data-theme="light"] .night-sky {
  background:
    radial-gradient(ellipse at 18% -10%, rgba(201, 184, 150, 0.10), transparent 38%),
    #F4F1EA;
}

html[data-theme="light"] .mobile-dash-header {
  background: rgba(244, 241, 234, 0.94);
}

html[data-theme="light"] .global-unsaved-btn.secondary {
  background: #E6E1D8;
  color: var(--text-primary);
}
