body { overflow-x: hidden; }
main { display: flex; flex-direction: column; flex: 1 0 auto; }

/* ================= SITE HEADER ================= */
.site-header {
  position: sticky;
  top: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: 0.85rem var(--space-6);
  background: rgba(8, 8, 10, 0.82);
  border-bottom: 1px solid var(--border);
  -webkit-backdrop-filter: blur(14px) saturate(150%);
  backdrop-filter: blur(14px) saturate(150%);
}
:root[data-theme="light"] .site-header { background: rgba(247, 247, 246, 0.86); }

.nav-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  font-family: var(--font-mono);
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-bright);
  text-decoration: none;
  white-space: nowrap;
}
.logo-badge {
  width: 26px; height: 26px;
  border-radius: 50%;
  background: #0b0b0c;
  border: 1px solid var(--border-hi);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.logo-badge img { width: 14px; }

#navUser { font-size: var(--text-md); font-weight: 500; margin-left: auto; }

/* ---- User menu (avatar + name -> dropdown with Log out) ---- */
.user-menu { position: relative; }
.user-menu-trigger {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px 4px 4px;
  border: 1px solid transparent;
  border-radius: var(--radius-full);
  background: none;
  color: var(--text);
  font: inherit;
  font-size: var(--text-md);
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.15s var(--ease-out), border-color 0.15s var(--ease-out);
}
.user-menu-trigger:hover { background: var(--surface-alt); border-color: var(--border); }
.user-menu-trigger img { width: 28px; height: 28px; border-radius: 50%; border: 1px solid var(--border); }
.user-menu-trigger svg { width: 14px; height: 14px; color: var(--text-dim); transition: transform 0.18s var(--ease-out); }
.user-menu-trigger[aria-expanded="true"] svg { transform: rotate(180deg); }
.user-menu-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 70;
  min-width: 150px;
  padding: 6px;
  border: 1px solid var(--border-hi);
  border-radius: var(--radius-sm);
  /* Solid, not the translucent --surface - a floating panel needs an opaque
     backing so it doesn't show whatever scrolls underneath it. */
  background: var(--bg-subtle);
  box-shadow: var(--shadow-lg);
}
.user-menu-dropdown a {
  display: block;
  padding: 9px 11px;
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: var(--text-md);
  text-decoration: none;
  transition: background-color 0.15s var(--ease-out);
}
.user-menu-dropdown a:hover { background: var(--surface-alt); }

@media (max-width: 400px) {
  /* Keeps the header from overflowing on the narrowest phones - brand +
     theme toggle + a long Discord username otherwise doesn't fit. */
  .user-menu-trigger span { display: none; }
  .user-menu-trigger { padding: 4px; gap: 0; }
}

/* ---- Theme toggle ---- */
.theme-toggle {
  width: 34px; height: 34px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  color: var(--text-muted);
  flex-shrink: 0;
  padding: 0;
  transition: color 0.2s var(--ease-out), border-color 0.2s var(--ease-out);
}
.theme-toggle:hover { border-color: var(--accent); color: var(--text-bright); }
.theme-toggle svg { width: 16px; height: 16px; }
.theme-toggle .icon-moon { display: none; }
:root[data-theme="light"] .theme-toggle .icon-sun { display: none; }
:root[data-theme="light"] .theme-toggle .icon-moon { display: block; }

.btn-dark { background: var(--text); color: var(--bg); border-color: var(--text); }
.btn-dark:hover { background: var(--text-bright); color: var(--bg); }
:root[data-theme="light"] .btn-dark { background: #000; color: #fff; border-color: #000; }
.btn-light { background: var(--surface-alt); color: var(--text); border-color: var(--border); }
.btn-light:hover { border-color: var(--accent); color: var(--text-bright); }
.btn-danger { background: rgba(229, 72, 77, 0.1); color: #e5a3a3; border-color: rgba(229, 72, 77, 0.4); }
.btn-danger:hover { background: rgba(229, 72, 77, 0.18); color: #ffb4b4; border-color: rgba(229, 72, 77, 0.65); }
.btn-danger:disabled { opacity: .55; cursor: not-allowed; }

/* ================= LOGIN GATE ================= */
.login-gate {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(24px, 5vw, 56px);
  flex-wrap: wrap;
  padding: var(--space-16) var(--space-6);
  max-width: min(80rem, calc(100% - 3rem));
  margin: 0 auto;
}
.dash-server-preview { flex: 1 1 380px; max-width: 520px; min-width: min(100%, 320px); }
.dash-preview-frame {
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  overflow: hidden;
  background: #1e1f22;
  box-shadow: 0 32px 64px rgba(0, 0, 0, 0.45);
}
.dash-preview-top {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: #111214;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 13px;
  color: #dbdee1;
}
.dash-preview-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #23a559;
  box-shadow: 0 0 0 4px rgba(35, 165, 89, 0.2);
}
.dash-preview-title { font-weight: 600; flex: 1; }
.dash-preview-pill {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: #b5bac1;
}
.dash-preview-body { display: flex; min-height: 280px; }
.dash-preview-rail {
  width: 56px;
  padding: 10px 8px;
  background: #111214;
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-right: 1px solid rgba(255, 255, 255, 0.06);
}
.dash-preview-guild {
  width: 40px;
  height: 40px;
  border-radius: 14px;
  background: #313338;
}
.dash-preview-guild.is-active {
  border-radius: 12px;
  background: linear-gradient(145deg, #5865f2, #3c45a5);
}
.dash-preview-channels {
  width: 168px;
  padding: 10px 8px;
  background: #2b2d31;
  border-right: 1px solid rgba(0, 0, 0, 0.25);
  font-size: 13px;
}
.dash-preview-cat {
  margin: 8px 6px 4px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #949ba4;
}
.dash-preview-ch {
  padding: 5px 8px;
  margin: 2px 4px;
  border-radius: 6px;
  color: #949ba4;
}
.dash-preview-ch.is-active { background: #404249; color: #f2f3f5; }
.dash-preview-ch.is-voice::before { content: "VC "; font-size: 10px; font-weight: 700; color: #b5bac1; }
.dash-preview-main { flex: 1; padding: 12px 14px; background: #313338; display: flex; flex-direction: column; gap: 12px; }
.dash-preview-msg { display: flex; gap: 10px; align-items: flex-start; }
.dash-preview-msg img { border-radius: 50%; background: #1e1f22; padding: 3px; }
.dash-preview-meta { margin: 0 0 4px; font-size: 13px; color: #f2f3f5; }
.dash-preview-meta span {
  font-size: 10px;
  font-weight: 700;
  padding: 1px 4px;
  border-radius: 4px;
  background: #5865f2;
  color: #fff;
  vertical-align: middle;
  margin-left: 4px;
}
.dash-preview-text { margin: 0; font-size: 14px; line-height: 1.45; color: #dbdee1; }
.dash-preview-modules { display: flex; flex-wrap: wrap; gap: 6px; margin-top: auto; }
.dash-preview-modules span {
  font-size: 11px;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #949ba4;
}
.dash-preview-modules span.on {
  background: rgba(255, 255, 255, 0.08);
  color: #f2f3f5;
  border-color: rgba(255, 255, 255, 0.18);
}
.dash-live-preview { margin-bottom: var(--space-8); }
.dash-live-preview .dash-preview-frame { max-width: 640px; }
.login-gate .login-card { flex: 1 1 320px; max-width: 420px; }
@media (max-width: 820px) {
  .login-gate { flex-direction: column; padding-top: var(--space-10); }
  .dash-server-preview { order: -1; max-width: 100%; }
}
.login-card {
  max-width: 440px;
  width: 100%;
  padding: var(--space-10) var(--space-8);
  text-align: center;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
}
.login-card .logo-badge {
  width: 56px; height: 56px;
  margin: 0 auto var(--space-5);
  background: var(--surface-hi);
  border: 1px solid var(--border-hi);
}
.login-card .logo-badge img { width: 28px; }
.login-card h1 { font-size: var(--text-2xl); margin: 0 0 var(--space-2); }
.login-card > p { color: var(--text-muted); margin: 0; }
.login-card .btn { margin-top: var(--space-6); }
.login-perks {
  display: flex; flex-direction: column; gap: var(--space-2);
  margin-top: var(--space-8);
  padding-top: var(--space-6);
  border-top: 1px solid var(--border);
  text-align: left;
}
.login-perks span { display: flex; align-items: center; gap: 9px; color: var(--text-muted); font-size: var(--text-md); }
.login-perks svg { width: 15px; height: 15px; color: var(--success); flex-shrink: 0; }

/* ================= SERVER GRID ================= */
.grid-header { padding: var(--space-12) 0 var(--space-8); gap: var(--space-4); flex-wrap: wrap; }
.grid-header h1 { font-size: var(--text-2xl); margin: 0 0 var(--space-1); }
.grid-header p { color: var(--text-muted); margin: 0; font-size: var(--text-md); }
#serverGridSection { padding-bottom: var(--space-24); }
#refreshServersBtn svg { width: 15px; height: 15px; }
#refreshServersBtn:disabled { opacity: 0.7; cursor: default; }
#refreshServersBtn.is-spinning svg { animation: refresh-spin 0.7s linear infinite; }
@keyframes refresh-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { #refreshServersBtn.is-spinning svg { animation: none; } }

.server-card { display: flex; flex-direction: column; align-items: center; text-align: center; gap: var(--space-3); padding: var(--space-6); }
.server-card-disabled { opacity: 0.5; }
.server-icon { width: 62px; height: 62px; border-radius: var(--radius); object-fit: cover; border: 1px solid var(--border); background: var(--surface-alt); }
.server-card h3 { margin: 0; font-size: var(--text-base); }
.server-card .btn { margin-top: var(--space-2); }
.server-icon-lg { width: 54px; height: 54px; border-radius: var(--radius); object-fit: cover; border: 1px solid var(--border); flex-shrink: 0; }

/* Skeleton placeholders while guilds load - a shimmer of the right shape
   reads as "loading" far better than a spinner or an empty void. */
.skeleton-card { padding: var(--space-6); display: flex; flex-direction: column; align-items: center; gap: var(--space-3); }
.sk {
  background: linear-gradient(90deg, var(--surface-alt) 25%, var(--surface-hi) 50%, var(--surface-alt) 75%);
  background-size: 200% 100%;
  animation: sk-shimmer 1.4s linear infinite;
  border-radius: var(--radius-sm);
}
.sk-avatar { width: 62px; height: 62px; border-radius: var(--radius); }
.sk-line { height: 12px; width: 70%; }
.sk-line.short { width: 45%; }
.sk-btn { height: 32px; width: 90px; border-radius: var(--radius-sm); margin-top: var(--space-2); }
@keyframes sk-shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .sk { animation: none; } }

/* Unsaved-changes bar, fixed to the bottom of the viewport. Mirrors Discord's
   own "Careful - you have unsaved changes!" bar: appears the moment a savable
   field changes, and a "shake" (triggered by JS adding .unsaved-bar-attention
   briefly) draws the eye back to it if they try to navigate away instead. */
.unsaved-bar {
  position: fixed;
  left: 50%;
  bottom: var(--space-6);
  transform: translateX(-50%);
  z-index: 80;
  display: none;
  align-items: center;
  gap: var(--space-5);
  padding: var(--space-4) var(--space-4) var(--space-4) var(--space-5);
  background: var(--bg-subtle);
  border: 1px solid var(--border-hi);
  color: var(--text);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  font-size: var(--text-md);
  font-weight: 600;
}
.unsaved-bar.is-visible { display: flex; }
/* Trying to leave with unsaved changes flashes the bar red and shakes it.
   The shake animates transform, which is also what centres the bar
   (translateX(-50%)) - so every keyframe has to re-state that offset or the
   bar jumps to the left edge mid-animation. The colour flash is separate so
   it still works on narrow screens, where the bar is edge-to-edge and has no
   centring transform to shake against. */
/* The alert state is a plain class toggled by JS for ~900ms, not a keyframe
   animation. An animated border-color simply refused to take effect on this
   element (keyframes loaded, animation reported as running, computed colour
   never moved), and chasing that further wasn't worth it when a state class
   is both simpler and immune to the global reduced-motion animation reset. */
.unsaved-bar.is-alerting {
  border-color: #e5484d;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.45), 0 0 0 4px rgba(229, 72, 77, 0.28);
}
.unsaved-bar.unsaved-bar-attention {
  animation: unsaved-shake 0.45s var(--ease-out);
}
@keyframes unsaved-shake {
  0%, 100% { transform: translateX(-50%); }
  15%, 55% { transform: translateX(calc(-50% - 8px)); }
  35%, 75% { transform: translateX(calc(-50% + 8px)); }
}
/* Literal colours, not var(): a custom property referenced inside a keyframe
   resolves against the element once, and the animated border-color simply
   never took effect here - the animation ran with the base colour throughout.
   Red reads as red in both themes, so hardcoding it costs nothing. */
@keyframes unsaved-flash {
  0%, 100% {
    border-color: rgba(255, 255, 255, 0.15);
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.45);
  }
  25%, 60% {
    border-color: #e5484d;
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.45), 0 0 0 4px rgba(229, 72, 77, 0.28);
  }
}
@media (prefers-reduced-motion: reduce) {
  /* Reduced-motion means no *movement* - it doesn't mean no feedback. Killing
     the animation outright left anyone with the OS setting on (which is easy
     to have without realising) getting no signal at all when they tried to
     leave with unsaved changes. Drop the shake, keep the colour pulse: it's
     a single slow fade, nowhere near a flash-seizure risk. */
  .unsaved-bar.unsaved-bar-attention { animation: unsaved-flash 0.9s var(--ease-out); }
}
@media (max-width: 640px) {
  .unsaved-bar { left: var(--space-4); right: var(--space-4); bottom: var(--space-4); transform: none; flex-wrap: wrap; }
  /* No centring transform at this width, so the shake would fling the bar
     sideways - keep the colour flash, drop the movement. */
  .unsaved-bar.unsaved-bar-attention { animation: unsaved-flash 0.9s var(--ease-out); }
}

/* A boolean setting as a labeled row with a real toggle switch on the right
 - replaces the plain "[ ] Enabled" native checkboxes that were the biggest
   concrete piece of "the settings menu looks plain/bad" feedback. Same
   .toggle switch the module-grid cards and Commands pane already use. */
.toggle-field {
  justify-content: space-between;
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--border);
  /* Matches .field's own margin-bottom (var(--space-4)) - these used to
     disagree (var(--space-2), 8px vs .field's 16px), which is exactly why
     a pane's rhythm looked broken: every "Enabled" toggle sat noticeably
     closer to the field below it than every other field pair did. */
  margin-bottom: var(--space-4);
}
.toggle-field span { font-size: var(--text-md); }

/* Native <details>/<summary> ("More options" on a ticket panel) styled to
   match everything else instead of the browser-default plain triangle. */
details {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: var(--space-3) var(--space-4);
  margin: var(--space-2) 0 var(--space-4);
  background: var(--surface-alt);
}
details[open] { padding-bottom: var(--space-4); }
details summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 6px;
  user-select: none;
}
details summary::-webkit-details-marker { display: none; }
details summary::before {
  content: "";
  width: 0;
  height: 0;
  border-left: 5px solid var(--text-dim);
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  transition: transform 0.15s var(--ease-out);
  flex-shrink: 0;
}
details[open] summary::before { transform: rotate(90deg); }
details .field:first-of-type { margin-top: var(--space-4); }

/* Icon badge injected next to each pane's <h2> (server.js's injectPaneIcon)
 - the same icon its module-grid card uses, so opening a pane feels like
   navigating into a real menu instead of landing on a bare form. */
.pane-title-row { display: flex; align-items: center; gap: 12px; }
.pane-icon {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  background: var(--surface-alt);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.pane-icon svg { width: 18px; height: 18px; }

/* First-time-per-feature explainer, shown once per browser (localStorage,
   see server.js's TOUR_SEEN_KEY) at the top of a pane the first time it's
   opened. The site's own neutral accent (not the warning-colored
   unsaved-bar) since this is informational, not an alert. */
.tour-banner {
  display: flex;
  align-items: flex-start;
  gap: var(--space-4);
  justify-content: space-between;
  background: var(--surface-alt);
  border: 1px solid var(--border-hi);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: var(--space-4);
  margin-bottom: var(--space-6);
}
.tour-banner strong { display: block; margin-bottom: 2px; }
.tour-banner p { margin: 0; color: var(--text-muted); font-size: var(--text-sm); }
.tour-banner .btn { flex-shrink: 0; }

/* Whole-page loader shown while we don't yet know what to render (login gate
   vs. server grid, or the server-manage pane before its data arrives) - same
   shimmer language as the skeleton cards above, just centered on the page. */
.page-loader { display: flex; flex-direction: column; align-items: center; gap: var(--space-3); padding: var(--space-24) var(--space-6); }
.page-loader .sk-line { height: 14px; }

/* Empty state */
.empty-state { text-align: center; padding: var(--space-20) var(--space-6); }
.empty-icon {
  width: 58px; height: 58px;
  margin: 0 auto var(--space-5);
  border-radius: var(--radius);
  background: var(--surface-alt);
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-dim);
}
.empty-icon svg { width: 24px; height: 24px; }
.empty-state h3 { margin: 0 0 var(--space-2); font-size: var(--text-lg); }
.empty-state p { color: var(--text-muted); max-width: 44ch; margin: 0 auto var(--space-6); }

/* ================= SERVER SETTINGS ================= */
.back-link {
  display: inline-flex; align-items: center; gap: 6px;
  text-decoration: none; font-family: var(--font-mono); font-size: var(--text-sm); font-weight: 500;
  margin: var(--space-8) 0 var(--space-3);
  color: var(--text-muted);
  transition: color 0.15s var(--ease-out), transform 0.15s var(--ease-out);
}
.back-link:hover { color: var(--text-bright); transform: translateX(-3px); }
.server-header { padding-bottom: var(--space-8); gap: var(--space-4); flex-wrap: wrap; }
.server-header h1 { margin: 0; font-size: var(--text-2xl); }

#moduleGrid { padding-bottom: var(--space-24); }
.module-card { display: flex; flex-direction: column; gap: var(--space-3); padding: var(--space-5); }
.module-card h3 { margin: 0; font-size: var(--text-base); }
.module-card p { margin: 0; font-size: var(--text-md); color: var(--text-muted); }
.module-card-soon { opacity: 0.55; }
.module-icon {
  width: 42px; height: 42px;
  border-radius: var(--radius-sm);
  background: var(--surface-hi);
  border: 1px solid var(--border-hi);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.module-icon svg { width: 19px; height: 19px; }
.module-icon-soon { background: transparent; border-style: dashed; color: var(--text-dim); }
.module-card .btn { margin-top: auto; align-self: flex-start; }

/* The breathing room before the footer belongs OUTSIDE the card, not inside
   it - this was padding-bottom: var(--space-24) (96px) on top of .card's own
   24px, which rendered as a big empty dead zone below the Save button inside
   every pane. Same visual gap before the footer, without the hole. */
/* 820px was a single-column cap - too narrow to put anything beside anything
   else, which is why every pane read as one long vertical stack. */
.pane { max-width: 1320px; margin-bottom: var(--space-16); }
/* h2/h3 had no margin-bottom of their own anywhere in this file - they were
   falling back to the browser's default heading margins (~1em, different
   for each), which never matched the space-4 rhythm every field/toggle-row
   below them actually uses. That mismatch (not any one field's own spacing)
   is what kept reading as "the spacing is messed up" pane over pane - h3
   sections in particular got a browser-default top margin stacked on top of
   .divider's own 32px, doubling up the gap after every <hr>. */
.pane h2, .pane h3 { margin: 0 0 var(--space-4); }
.pane h2 { font-size: var(--text-xl); }
.pane h3 { font-size: var(--text-lg); }
.pane > p { color: var(--text-muted); }
/* align-items:start so the preview column doesn't stretch to match a much
   taller form column (was leaving a large dead gap under a short preview
   card); the preview itself sticks near the top of the viewport instead so
   it's still visible while scrolling a long form, instead of just sitting in
   empty space. */
.wl-columns { display: grid; grid-template-columns: 1.2fr 1fr; gap: var(--space-8); align-items: start; }
.wl-columns > div:last-child { position: sticky; top: calc(var(--space-8) + 68px); }
@media (max-width: 860px) { .wl-columns > div:last-child { position: static; } }
/* Styled like an actual Discord message from Iridex - a fake message-author
   row (bot avatar, name, APP tag, timestamp) above the embed-like card, so
   this reads as "here's what Iridex will post" rather than a generic form
   preview. Colors are Discord's own dark-theme ones (#2b2d31 etc.), not the
   site's tokens - this is deliberately meant to look like Discord itself,
   not like the dashboard around it. */
.preview-card { background: #313338; border-radius: var(--radius-sm); padding: var(--space-4); font-size: var(--text-md); }
.preview-message-header { display: flex; align-items: baseline; gap: 8px; margin-bottom: 6px; }
.preview-bot-avatar { width: 22px; height: 22px; border-radius: 50%; background: #1e1f22; padding: 3px; flex-shrink: 0; align-self: center; }
.preview-bot-name { color: #f2f3f5; font-weight: 600; font-size: 0.95em; }
.preview-bot-tag {
  background: #5865f2;
  color: #fff;
  font-size: 0.6em;
  font-weight: 700;
  letter-spacing: 0.02em;
  padding: 1px 4px;
  border-radius: 3px;
  text-transform: uppercase;
}
.preview-timestamp { color: #949ba4; font-size: 0.75em; }
.preview-embed { background: #2b2d31; border-left: 4px solid var(--text-dim); border-radius: 4px; padding: 10px 12px; color: #dbdee1; }
.preview-embed strong { color: #f2f3f5; }
/* This card is deliberately always Discord-dark regardless of the site's own
   light/dark toggle - .text-muted's site token would go unreadable-light
   against it in light mode, so it's pinned here instead. */
.preview-embed .text-muted { color: #b5bac1; }
.preview-avatar { width: 40px; height: 40px; border-radius: 50%; }

/* Components V2 container, as Discord draws one: a rounded card with an
   accent stripe down the left edge, text blocks, an optional thumbnail
   beside the first block, full-width media, hairline separators, "-#"
   subtext, and the button row inside it. Pinned to Discord-dark for the same
   reason as .preview-embed above. */
.v2-container {
  position: relative;
  max-width: 540px;
  padding: 14px 16px 14px 20px;
  background: #2b2d31;
  border: 1px solid #3f4147;
  border-radius: 8px;
  color: #dbdee1;
  overflow: hidden;
  line-height: 1.375;
}
.v2-container::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 4px;
  background: var(--v2-accent, #8b5cf6);
}
.v2-section { display: flex; align-items: flex-start; gap: 16px; }
.v2-text { flex: 1; min-width: 0; }
.v2-h3 { font-size: 1.5em; font-weight: 700; color: #f2f3f5; margin: 0 0 4px; line-height: 1.2; }
.v2-body { color: #dbdee1; white-space: pre-wrap; word-break: break-word; }
.v2-thumb { width: 80px; height: 80px; border-radius: 8px; object-fit: cover; flex-shrink: 0; }
.v2-media { display: block; width: 100%; max-height: 260px; object-fit: cover; border-radius: 8px; }
.v2-sep { height: 1px; background: #3f4147; margin: 12px 0; }
.v2-subtext { font-size: 0.75em; color: #949ba4; }
.v2-container .preview-buttons { margin-top: 12px; }

/* Real Discord button colours, so a preview's buttons look like what will
   actually post rather than this site's own button chrome. Same reasoning
   as .preview-embed being pinned to Discord-dark regardless of site theme. */
.preview-buttons { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
/* A custom-emoji tag or :shortcode: rendered inline in preview text - sized
 * to sit on the text baseline the way Discord's own emoji rendering does. */
.preview-emoji { width: 1.375em; height: 1.375em; vertical-align: -0.4em; object-fit: contain; }
.discord-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px; border-radius: 3px; border: none;
  font-size: 14px; font-weight: 500; color: #fff;
  pointer-events: none; white-space: nowrap;
}
.discord-btn-primary { background: #5865f2; }
.discord-btn-secondary { background: #4e5058; }
.discord-btn-success { background: #248046; }
.discord-btn-danger { background: #da373c; }
.discord-btn-link { background: #4e5058; }
.discord-btn-link::after { content: "↗"; opacity: 0.8; font-size: 12px; }

.divider { border: none; border-top: 1px solid var(--border); margin: var(--space-8) 0; }

.list-row {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: var(--space-3) var(--space-4);
  background: var(--surface-alt);
  font-size: var(--text-md);
}
.list-row code { color: var(--text-bright); }

/* Checkbox-style toggle */
.toggle { position: relative; display: inline-block; width: 42px; height: 24px; flex-shrink: 0; }
.toggle input { opacity: 0; width: 0; height: 0; position: absolute; }
.toggle .slider {
  position: absolute; inset: 0;
  background: var(--surface-hi);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: background 0.2s var(--ease-out), border-color 0.2s var(--ease-out);
}
.toggle .slider::before {
  content: "";
  position: absolute;
  width: 16px; height: 16px;
  left: 3px; top: 3px;
  background: var(--text-dim);
  border-radius: 50%;
  transition: transform 0.22s var(--ease-out), background 0.2s var(--ease-out);
}
.toggle input:checked + .slider { background: var(--surface-hi); border-color: var(--accent); }
.toggle input:checked + .slider::before { transform: translateX(18px); background: var(--accent); }
.toggle input:disabled + .slider { cursor: not-allowed; opacity: 0.6; }
.toggle input:focus-visible + .slider { outline: 2px solid var(--accent); outline-offset: 3px; }

@media (max-width: 860px) { .wl-columns { grid-template-columns: 1fr; } }

/* ================= SITE FOOTER ================= */
/* Shared with homepage/wiki - same markup, same classes, so the three sites
   read as one product instead of the dashboard looking like an afterthought. */
.site-footer {
  margin-top: auto; /* sticky footer */
  border-top: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.012);
}
:root[data-theme="light"] .site-footer { background: rgba(0, 0, 0, 0.012); }
.footer-grid {
  max-width: 1160px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1.6fr repeat(5, minmax(0, 1fr));
  gap: var(--space-8);
  padding: var(--space-10) var(--space-6) var(--space-6);
}
.footer-brand-row { display: flex; align-items: center; gap: 9px; }
.footer-brand strong { font-family: var(--font-mono); font-size: var(--text-lg); color: var(--text-bright); }
.footer-brand p { color: var(--text-muted); margin-top: var(--space-3); max-width: 34ch; font-size: var(--text-md); }
.footer-col { display: flex; flex-direction: column; align-items: flex-start; gap: var(--space-2); }
.footer-col h4 {
  font-family: var(--font-mono);
  margin: 0 0 var(--space-2);
  font-size: 0.72rem;
  color: var(--text-dim);
  letter-spacing: 0.13em;
  text-transform: uppercase;
  font-weight: 500;
}
.footer-col a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: var(--text-md);
  padding: 3px 0;
  transition: color 0.16s var(--ease-out);
}
.footer-col a:hover { color: var(--text-bright); }
.footer-col-wide { grid-column: span 2; }
.footer-sublists { display: flex; flex-wrap: wrap; gap: var(--space-8) var(--space-10); }
.footer-sublist { display: flex; flex-direction: column; align-items: flex-start; gap: var(--space-2); }

.footer-disclaimer {
  max-width: 1160px;
  margin: 0 auto;
  padding: var(--space-5) var(--space-6) var(--space-8);
  color: var(--text-faint);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  border-top: 1px solid var(--border);
}

/* See homepage/dashboard/assets/css/site.css - same slot, filled in by
   /dashboard/assets/js/locale.js so a new language is a one-line change there. */
.lang-switch {
  max-width: 1160px;
  margin: 0 auto;
  padding: 0 var(--space-6) var(--space-8);
}
.lang-switch-widget { position: relative; display: inline-block; }
.lang-switch-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 180px;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-dim);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 5px 10px;
  cursor: pointer;
}
.lang-switch-btn:hover,
.lang-switch-widget.is-open .lang-switch-btn { color: var(--text-bright); border-color: var(--border-hi); }
.lang-switch-current { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lang-switch-btn svg {
  width: 11px;
  height: 11px;
  flex: none;
  transition: transform 0.15s var(--ease-out);
}
.lang-switch-widget.is-open .lang-switch-btn svg { transform: rotate(180deg); }
/* position: fixed and appended to <body> (not inside .lang-switch-widget)
   on purpose - left/top/bottom set from JS via the button's own
   getBoundingClientRect(). This is the one thing that survives opening the
   widget inside a scrolling container like the account modal's
   .acct-modal-body: an absolutely-positioned list there gets clipped the
   moment it crosses that container's edge, no matter the z-index. */
.lang-switch-list {
  position: fixed;
  /* Above .acct-modal (z-index: 300) - this list is meant to render on top
     of the account modal when opened from its Preferences row. */
  z-index: 320;
  width: max-content;
  max-width: 220px;
  max-height: 260px;
  overflow-y: auto;
  margin: 0;
  padding: 4px;
  list-style: none;
  background: var(--surface-solid);
  border: 1px solid var(--border-hi);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
}
.lang-switch-list[hidden] { display: none; }
.lang-switch-option {
  padding: 6px 10px;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  cursor: pointer;
  white-space: nowrap;
}
.lang-switch-option:hover { background: var(--surface-alt); color: var(--text-bright); }
.lang-switch-option.is-active { background: var(--surface-hi); color: var(--text-bright); }

/* Offer-once banner from /dashboard/assets/js/locale.js - see homepage/dashboard/assets/css/site.css. */
.lang-banner {
  position: fixed;
  left: 50%;
  bottom: var(--space-5);
  transform: translate(-50%, 16px);
  z-index: 60;
  display: flex;
  align-items: center;
  gap: var(--space-4);
  max-width: calc(100% - var(--space-6) * 2);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--border-hi);
  border-radius: var(--radius);
  /* --surface is a ~2.5% tint meant to sit over the page's own solid
     background - fine for a card in normal flow, but this banner floats
     fixed on top of whatever's scrolled behind it, so that tint alone read
     as see-through. --bg-subtle (same token the account modal uses) is
     genuinely opaque. */
  background: var(--bg-subtle);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
  opacity: 0;
  transition: opacity 0.2s var(--ease-out), transform 0.2s var(--ease-out);
}
.lang-banner.is-open { opacity: 1; transform: translate(-50%, 0); }
.lang-banner-text { color: var(--text-muted); font-size: var(--text-sm); white-space: nowrap; }
.lang-banner-text strong { color: var(--text-bright); }
.lang-banner-close {
  border: none;
  background: transparent;
  color: var(--text-dim);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  padding: 4px;
}
.lang-banner-close:hover { color: var(--text-bright); }
@media (max-width: 640px) {
  .lang-banner { flex-wrap: wrap; justify-content: center; text-align: center; }
  .lang-banner-text { white-space: normal; }
}

@media (max-width: 820px) {
  .footer-grid { grid-template-columns: 1fr 1fr; }
}

/* ================= IMAGE PICKER ================= */
/* Upgrades a plain "paste a URL" text field into a click-to-set preview box
 - see /dashboard/assets/js/imagePicker.js. The underlying <input> is hidden but
   still the real value; this is purely the front-end for it. */
.img-picker { position: relative; display: inline-block; margin-top: var(--space-2); }
.img-picker-thumbnail { width: 96px; }
.img-picker-banner { display: block; width: 100%; }

.img-picker-box {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  border: 1.5px dashed var(--border-hi);
  border-radius: var(--radius);
  background: var(--surface-alt);
  color: var(--text-dim);
  cursor: pointer;
  font-family: inherit;
  font-size: var(--text-sm);
  font-weight: 500;
  transition: border-color 0.15s var(--ease-out), color 0.15s var(--ease-out), background 0.15s var(--ease-out);
}
.img-picker-thumbnail .img-picker-box { aspect-ratio: 1; flex-direction: column; }
.img-picker-thumbnail .img-picker-box svg { width: 22px; height: 22px; }
.img-picker-thumbnail .img-picker-box span { font-size: var(--text-xs); text-align: center; line-height: 1.2; }
.img-picker-banner .img-picker-box { height: 150px; }
.img-picker-box:hover { border-color: var(--accent); color: var(--text); background: var(--surface-hi); }
/* An inline <svg> with no width/height attributes falls back to the browser's
   default replaced-element size (300x150) when nothing constrains it - that's
   the size this had until now, which is why the empty "Add banner" icon was
   ballooning way outside its own box and smearing across the row. */
.img-picker-box svg { width: 28px; height: 28px; flex-shrink: 0; }

.img-picker-filled {
  border-style: solid;
  border-color: var(--border);
  background-size: cover;
  background-position: center;
  position: relative;
  color: transparent;
}
.img-picker-edit {
  position: absolute;
  inset: auto 0 0 0;
  padding: 4px 8px;
  font-size: var(--text-xs);
  color: var(--text-bright);
  background: linear-gradient(to top, rgba(0, 0, 0, 0.72), transparent);
  opacity: 0;
  transition: opacity 0.15s var(--ease-out);
}
.img-picker-filled:hover .img-picker-edit { opacity: 1; }

.img-picker-remove {
  position: absolute;
  top: -8px;
  right: -8px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 1px solid var(--border-hi);
  background: var(--surface-solid);
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.img-picker-remove:hover { color: var(--danger); border-color: var(--danger); }

.img-picker-popover {
  position: absolute;
  z-index: 30;
  top: calc(100% + 8px);
  left: 0;
  width: max(280px, 100%);
  padding: var(--space-4);
  background: var(--surface-solid);
  border: 1px solid var(--border-hi);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
}
/* Drop zone leads, link field is the secondary path underneath it. */
.img-picker-drop {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: var(--space-5) var(--space-4);
  border: 1.5px dashed var(--border-hi);
  border-radius: var(--radius-sm);
  background: var(--surface-alt);
  color: var(--text-muted);
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s var(--ease-out), background 0.15s var(--ease-out);
}
.img-picker-drop:hover, .img-picker-drop.is-dragging { border-color: var(--accent); background: var(--surface-hi); }
.img-picker-drop.is-dragging { border-style: solid; }
.img-picker-drop svg { width: 22px; height: 22px; margin-bottom: 2px; }
.img-picker-drop-main { font-size: var(--text-sm); color: var(--text); }
.img-picker-drop-sub { font-size: var(--text-xs); color: var(--text-dim); }

.img-picker-linkrow { display: flex; align-items: center; gap: 6px; margin-top: var(--space-3); }
.img-picker-linkrow .img-picker-url { flex: 1; min-width: 0; }
.img-picker-error { margin: var(--space-2) 0 0; font-size: var(--text-xs); color: var(--danger); }

/* ================= SAVE STATUS ================= */
/* Replaces the old raw "Saved ✅" text node next to every Save button - a
   real, theme-consistent inline pill instead of a plain unicode emoji. */
.save-status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  border-radius: var(--radius-full);
  font-size: var(--text-sm);
  font-weight: 600;
  animation: save-status-in 0.2s var(--ease-out);
}
.save-status svg { width: 13px; height: 13px; flex-shrink: 0; }
.save-status-ok { color: #9fe3bb; background: rgba(125, 211, 160, 0.13); }
:root[data-theme="light"] .save-status-ok { color: #17794a; background: rgba(23, 121, 74, 0.1); }
.save-status-error { color: #ff9a9a; background: rgba(229, 72, 77, 0.13); }
:root[data-theme="light"] .save-status-error { color: #b3261e; background: rgba(229, 72, 77, 0.1); }
@keyframes save-status-in { from { opacity: 0; transform: translateY(2px); } to { opacity: 1; transform: translateY(0); } }
@media (prefers-reduced-motion: reduce) { .save-status { animation: none; } }

/* ================= ROLE CHIPS ================= */
.chip-list { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: var(--space-3); min-height: 32px; align-items: center; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px 6px 12px;
  border-radius: var(--radius-full);
  background: var(--surface-hi);
  border: 1px solid var(--border-hi);
  font-size: var(--text-sm);
  color: var(--text);
}
.chip-remove {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: none;
  background: none;
  color: var(--text-dim);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
}
.chip-remove:hover { color: var(--danger); background: rgba(229, 72, 77, 0.12); }

/* ================= LOG TABLE ================= */
.table-scroll { width: 100%; overflow-x: auto; }
.log-table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
.log-table th {
  text-align: left;
  padding: 8px 12px;
  color: var(--text-dim);
  font-weight: 700;
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-bottom: 1px solid var(--border-hi);
  white-space: nowrap;
}
.log-table td { padding: 10px 12px; border-bottom: 1px solid var(--border); color: var(--text-muted); white-space: nowrap; }
.log-table td:nth-child(3) { color: var(--text); white-space: normal; }
.log-table tr:last-child td { border-bottom: none; }
.log-table tr:hover td { background: var(--surface-alt); }

/* ================= PANE ACTION BAR ================= */
/* The Save button + its status pill used to be two loose siblings dangling
   under whatever the last field happened to be, with per-pane inline
   margin-top hacks to compensate. A single bordered action row instead:
   consistent separation on every pane, and the status sits with the button
   it belongs to rather than floating beside it. */
.pane-actions {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-top: var(--space-6);
  padding-top: var(--space-5);
  border-top: 1px solid var(--border);
}
.pane-actions .hint { margin: 0; }

/* Row flagged by a refused save (an empty question / untitled panel /
   unpicked role) - points at the actual row instead of making someone
   count list positions from an error message. */
.is-invalid {
  border-color: var(--danger) !important;
  box-shadow: 0 0 0 3px rgba(229, 72, 77, 0.12);
}

/* ================= PANE LANDSCAPE LAYOUT ================= */
/* Every settings pane used to be one long vertical stack of bare fields
   separated by <hr>s. These give each pane a real two-column layout with
   its settings grouped into labelled blocks, so a pane reads as "here are
   the 2-3 things this module does" instead of "here are 11 inputs". */
.pane-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: var(--space-5);
  align-items: start;
  margin-bottom: var(--space-5);
}
/* Form-heavy pane with a preview beside it - give the form the extra room. */
.pane-grid-wide { grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); }
.pane-grid > .col-span { grid-column: 1 / -1; }
@media (max-width: 940px) {
  .pane-grid, .pane-grid-wide { grid-template-columns: 1fr; }
}

/* A labelled block of related settings. */
.settings-group {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-alt);
  padding: var(--space-5);
}
.pane .settings-group > h3 {
  margin: 0;
  font-size: var(--text-md);
  font-family: var(--font-sans);
  letter-spacing: 0;
}
.settings-group-desc { margin: 4px 0 var(--space-4); font-size: var(--text-sm); color: var(--text-dim); }
.settings-group > h3:last-child, .settings-group > .settings-group-desc:last-child { margin-bottom: 0; }
/* Last control in a group shouldn't add trailing space inside the box. */
.settings-group > .field:last-child,
.settings-group > .toggle-field:last-child { margin-bottom: 0; }
.settings-group > .toggle-field:last-child { border-bottom: none; padding-bottom: 0; }

/* Column of stacked groups (the left side of a two-column pane). */
.pane-col { display: flex; flex-direction: column; gap: var(--space-5); }

/* Preview column sticks while scrolling a long form beside it. */
.preview-col { position: sticky; top: calc(var(--space-6) + 68px); }
.pane .preview-col h3 { margin: 0 0 var(--space-3); font-size: var(--text-sm); color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.06em; }
@media (max-width: 940px) { .preview-col { position: static; } }

/* A read-only "what this does" panel, for panes with no live preview. */
.info-list { display: flex; flex-direction: column; gap: var(--space-3); margin: 0; padding: 0; list-style: none; }
.info-list li { display: flex; gap: 10px; align-items: flex-start; font-size: var(--text-sm); color: var(--text-muted); }
.info-list svg { width: 15px; height: 15px; flex-shrink: 0; margin-top: 2px; color: var(--text-dim); }

/* Commands pane: categories side by side instead of one tall column. */
#commandsList { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0 var(--space-6); }
@media (max-width: 940px) { #commandsList { grid-template-columns: 1fr; } }

/* Live clock in the Timezone pane. */
.tz-clock { font-family: var(--font-mono); font-size: var(--text-3xl); font-weight: 600; color: var(--text-bright); line-height: 1.1; font-variant-numeric: tabular-nums; }
.tz-clock-date { margin-top: 6px; font-size: var(--text-sm); color: var(--text-dim); }

/* ================= MOTION ================= */
/* Panes and their groups fade/rise in when opened, and module cards stagger
   in on the grid - the dashboard used to swap content instantly, which read
   as flat. Everything here is disabled under prefers-reduced-motion below. */
@keyframes pane-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes card-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.pane[style*="display: block"], .pane:not([style*="display:none"]) { animation: pane-in 0.28s var(--ease-out) both; }
.settings-group { animation: pane-in 0.34s var(--ease-out) both; }
.pane-grid > *:nth-child(2) .settings-group, .pane-grid > .preview-col { animation-delay: 0.05s; }
.pane-col .settings-group:nth-child(2) { animation-delay: 0.05s; }
.pane-col .settings-group:nth-child(3) { animation-delay: 0.1s; }

.module-card { animation: card-in 0.32s var(--ease-out) both; }
.module-card:nth-child(2) { animation-delay: 0.03s; }
.module-card:nth-child(3) { animation-delay: 0.06s; }
.module-card:nth-child(4) { animation-delay: 0.09s; }
.module-card:nth-child(5) { animation-delay: 0.12s; }
.module-card:nth-child(6) { animation-delay: 0.15s; }
.module-card:nth-child(n + 7) { animation-delay: 0.18s; }

/* Cards lift slightly on hover instead of only changing border colour. */
.module-card, .server-card {
  transition: border-color 0.22s var(--ease-out), background-color 0.22s var(--ease-out),
    transform 0.22s var(--ease-out), box-shadow 0.22s var(--ease-out);
}
.module-card:hover, .server-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.settings-group { transition: border-color 0.2s var(--ease-out); }
.settings-group:focus-within { border-color: var(--border-hi); }

.btn { transition: background-color 0.16s var(--ease-out), border-color 0.16s var(--ease-out), color 0.16s var(--ease-out), transform 0.12s var(--ease-out); }
.btn:active { transform: translateY(1px); }

@media (prefers-reduced-motion: reduce) {
  .pane, .settings-group, .module-card { animation: none !important; }
  .module-card:hover, .server-card:hover { transform: none; }
  .btn:active { transform: none; }
}

/* ================= CUSTOM SELECT ================= */
/* A native select's open option list is drawn by the OS and can't be styled - 
   it rendered as a white system menu on this dark UI. /dashboard/assets/js/customSelect.js
   keeps the real <select> as the source of truth and draws this listbox over
   it. */
.cs { position: relative; }
.cs-native {
  /* Not display:none - a hidden-but-present select keeps working with
     .value/.dispatchEvent and stays in the accessibility tree. */
  position: absolute;
  opacity: 0;
  pointer-events: none;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
}
.cs-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  width: 100%;
  padding: 10px 14px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: inherit;
  font-size: var(--text-md);
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s var(--ease-out), background 0.15s var(--ease-out);
}
.cs-trigger:hover { border-color: var(--border-hi); }
.cs-trigger[aria-expanded="true"] { border-color: var(--accent); }
.cs-trigger:disabled { opacity: 0.6; cursor: not-allowed; }
.cs-trigger svg { width: 16px; height: 16px; color: var(--text-dim); flex-shrink: 0; transition: transform 0.18s var(--ease-out); }
.cs-trigger[aria-expanded="true"] svg { transform: rotate(180deg); }
.cs-value { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cs-placeholder { color: var(--text-faint); }

.cs-list {
  position: absolute;
  z-index: 80;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  max-height: 300px;
  display: flex;
  flex-direction: column;
  background: var(--surface-solid);
  border: 1px solid var(--border-hi);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: cs-in 0.14s var(--ease-out);
}
@keyframes cs-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.cs-search { padding: 8px; border-bottom: 1px solid var(--border); }
.cs-search input { padding: 7px 10px; font-size: var(--text-sm); }
.cs-options { overflow-y: auto; padding: 5px; }
.cs-option {
  padding: 8px 11px;
  border-radius: var(--radius-sm);
  font-size: var(--text-md);
  color: var(--text);
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cs-option:hover { background: var(--surface-alt); }
.cs-option.is-selected { background: var(--surface-hi); color: var(--text-bright); font-weight: 600; }
.cs-empty { padding: 12px; text-align: center; color: var(--text-dim); font-size: var(--text-sm); }
@media (prefers-reduced-motion: reduce) { .cs-list { animation: none; } .cs-trigger[aria-expanded="true"] svg { transition: none; } }

/* ================= PANEL EDITORS ================= */
/* A panel's own name, shown only in the dashboard so several panels in a
   list are tellable apart - styled as an editable title rather than yet
   another labelled field. */
.panel-head { margin-bottom: var(--space-4); }
.panel-name-input {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 700;
  padding: 6px 10px;
  background: transparent;
  border-color: transparent;
}
.panel-name-input:hover { border-color: var(--border); }
.panel-name-input:focus { background: var(--surface-alt); border-color: var(--accent); }

/* Link-button rows (label + url + remove). */
.link-btn-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: var(--space-3); }
.link-btn-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr) auto; gap: 8px; align-items: center; }
@media (max-width: 620px) { .link-btn-row { grid-template-columns: 1fr; } }

/* Reaction-role rows: role, emoji, label, description, remove. */
.rr-role-row {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) 110px minmax(0, 1fr) minmax(0, 1.2fr) auto;
  gap: 8px;
  align-items: center;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
}
@media (max-width: 900px) { .rr-role-row { grid-template-columns: 1fr 1fr; } }
@media (max-width: 560px) { .rr-role-row { grid-template-columns: 1fr; } }

/* Dropdown stand-in inside a preview card. */
.preview-select {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border-hi);
  border-radius: var(--radius-sm);
  background: var(--surface-alt);
  color: var(--text-dim);
  font-size: var(--text-sm);
}
.preview-select svg { width: 14px; height: 14px; flex-shrink: 0; }

/* ================= EMOJI PICKER ================= */
.emoji-field { position: relative; display: flex; align-items: center; gap: 6px; }
.emoji-field input { flex: 1; min-width: 0; }
.emoji-field-trigger, .emoji-inline-trigger {
  flex-shrink: 0;
  width: 38px; height: 38px;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-alt);
  color: var(--text-dim);
  font-size: 16px;
  cursor: pointer;
  transition: border-color 0.16s var(--ease-out), color 0.16s var(--ease-out), background 0.16s var(--ease-out);
}
.emoji-field-trigger:hover, .emoji-inline-trigger:hover { border-color: var(--accent); color: var(--text); background: var(--surface-hi); }
.emoji-inline-trigger svg { width: 17px; height: 17px; }
.emoji-inline { position: relative; display: flex; align-items: center; gap: 6px; }
.emoji-inline > input, .emoji-inline > textarea { flex: 1; min-width: 0; }
.emoji-inline > textarea + .emoji-inline-trigger { align-self: flex-start; }

/* Small "?" button next to a field that accepts placeholders - click opens a
 * short popup explaining them, so the syntax doesn't have to be memorized or
 * guessed from the field's own placeholder text. */
.placeholder-info-btn {
  width: 18px;
  height: 18px;
  border-radius: 999px;
  border: 1px solid var(--border-hi);
  background: var(--surface-2);
  color: var(--text-dim);
  font-size: 0.68rem;
  font-weight: 700;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
}
.placeholder-info-btn:hover { color: var(--text); border-color: var(--accent); }
/* The list version: one row per token the section supports. Rows are
   buttons, so a token can be inserted without leaving the keyboard. */
.placeholder-info-btn { margin-left: 6px; vertical-align: 1px; }
.placeholder-info-pop.has-list { width: 340px; padding: 6px; }
.placeholder-info-pop .ph-head {
  margin: 4px 8px 6px;
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-dim);
}
.placeholder-info-pop .ph-row {
  display: grid;
  /* One token column for the whole list, sized to the longest token any
     section uses (%membercount%), so the descriptions line up. */
  grid-template-columns: 118px 1fr;
  align-items: baseline;
  gap: 10px;
  width: 100%;
  padding: 7px 8px;
  border: 0;
  border-radius: calc(var(--radius) - 4px);
  background: none;
  color: var(--text-muted);
  font: inherit;
  font-size: var(--text-sm);
  text-align: left;
  cursor: pointer;
}
.placeholder-info-pop .ph-row:hover,
.placeholder-info-pop .ph-row:focus-visible { background: var(--surface-alt); color: var(--text); outline: none; }
.placeholder-info-pop .ph-row code {
  font-size: 0.8rem;
  color: var(--text-bright);
  background: var(--surface-alt);
  border: 1px solid var(--border);
  padding: 1px 6px;
  border-radius: 5px;
  white-space: nowrap;
  justify-self: start;
}
.placeholder-info-pop .ph-note {
  margin: 6px 8px 4px;
  padding-top: 6px;
  border-top: 1px solid var(--border);
  font-size: var(--text-xs);
  color: var(--text-dim);
}
/* The description line a section's "?" sits in. */
.settings-group-desc .placeholder-info-btn, .hint .placeholder-info-btn { margin-left: 4px; }
.placeholder-info-pop {
  position: absolute;
  z-index: 350;
  width: 260px;
  max-width: calc(100vw - 32px);
  padding: 10px 12px;
  background: var(--surface-solid);
  border: 1px solid var(--border-hi);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  font-size: var(--text-sm);
  color: var(--text-dim);
  line-height: 1.4;
  animation: emoji-pop-in 0.16s var(--ease-out);
}

.emoji-pop {
  position: absolute;
  z-index: 350;
  top: calc(100% + 8px);
  right: 0;
  width: 320px;
  max-height: 340px;
  display: flex;
  flex-direction: column;
  background: var(--surface-solid);
  border: 1px solid var(--border-hi);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: emoji-pop-in 0.16s var(--ease-out);
}
@keyframes emoji-pop-in { from { opacity: 0; transform: translateY(-6px) scale(0.98); } to { opacity: 1; transform: none; } }
.emoji-pop-search { padding: 8px; border-bottom: 1px solid var(--border); }
.emoji-pop-search input { padding: 7px 10px; font-size: var(--text-sm); }
.emoji-pop-body { overflow-y: auto; padding: 8px; }
.emoji-pop-group + .emoji-pop-group { margin-top: 10px; }
.emoji-pop-group h5 {
  margin: 0 0 6px;
  font-family: var(--font-mono);
  font-size: 0.66rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-faint);
}
.emoji-pop-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px; }
.emoji-cell {
  display: flex; align-items: center; justify-content: center;
  aspect-ratio: 1;
  border: none;
  border-radius: 6px;
  background: none;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  transition: background 0.12s var(--ease-out), transform 0.12s var(--ease-out);
}
.emoji-cell:hover { background: var(--surface-hi); transform: scale(1.15); }
.emoji-cell img { width: 22px; height: 22px; object-fit: contain; }
.emoji-pop-empty { padding: 16px; text-align: center; color: var(--text-dim); font-size: var(--text-sm); margin: 0; }
@media (prefers-reduced-motion: reduce) { .emoji-pop { animation: none; } .emoji-cell:hover { transform: none; } }

/* ================= BRAND MENU ================= */
.brand-menu { position: relative; }
.brand-menu .nav-brand { cursor: pointer; user-select: none; }
.brand-caret { width: 13px; height: 13px; color: var(--text-dim); transition: transform 0.18s var(--ease-out); }
.nav-brand[aria-expanded="true"] .brand-caret { transform: rotate(180deg); }

.brand-menu-panel {
  position: absolute;
  top: calc(100% + 10px);
  left: 0;
  z-index: 85;
  width: 320px;
  padding: var(--space-4);
  background: var(--bg-subtle);
  border: 1px solid var(--border-hi);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  animation: brand-menu-in 0.18s var(--ease-out);
}
@keyframes brand-menu-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

.brand-menu-section + .brand-menu-section { margin-top: var(--space-4); padding-top: var(--space-4); border-top: 1px solid var(--border); }
.brand-menu-kicker {
  margin: 0 0 var(--space-3);
  font-family: var(--font-mono);
  font-size: 0.66rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-faint);
}
.brand-menu-kicker::before { content: "// "; }

.brand-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-3); }
.brand-stat { display: flex; flex-direction: column; gap: 1px; }
.brand-stat b { font-family: var(--font-display); font-size: var(--text-lg); color: var(--text-bright); line-height: 1.1; }
.brand-stat span { font-size: var(--text-xs); color: var(--text-dim); }

.brand-mods { display: flex; flex-wrap: wrap; gap: 6px; }
.brand-mod {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 9px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: var(--text-xs);
  color: var(--text-dim);
  text-transform: capitalize;
}
.brand-mod-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--text-faint); }
.brand-mod.is-on { color: var(--text); border-color: var(--border-hi); }
.brand-mod.is-on .brand-mod-dot { background: var(--success); }
.brand-menu-note { margin: var(--space-3) 0 0; font-size: var(--text-xs); color: var(--text-dim); }

.brand-menu-links { display: flex; flex-direction: column; gap: 2px; margin-top: var(--space-4); padding-top: var(--space-3); border-top: 1px solid var(--border); }
.brand-menu-links a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 9px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: var(--text-md);
  text-decoration: none;
  transition: background-color 0.15s var(--ease-out), color 0.15s var(--ease-out);
}
.brand-menu-links a:hover { background: var(--surface-alt); color: var(--text-bright); }
.brand-menu-links svg { width: 15px; height: 15px; flex-shrink: 0; color: var(--text-dim); }
.brand-menu-loading { display: flex; flex-direction: column; gap: 8px; }
.brand-menu-loading .sk-line { height: 34px; width: 100%; }
.brand-menu-loading .sk-line.short { width: 70%; }
@media (prefers-reduced-motion: reduce) { .brand-menu-panel { animation: none; } }

/* ================= SERVER OVERVIEW ================= */
/* The landing view when you open a server: headline numbers first, module
   configuration below. */
#serverOverview { margin-bottom: var(--space-10); }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: var(--space-4); }
.stat-card {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-5);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  transition: border-color 0.22s var(--ease-out), transform 0.22s var(--ease-out), box-shadow 0.22s var(--ease-out);
  animation: card-in 0.32s var(--ease-out) both;
}
.stat-card:hover { border-color: var(--border-hi); transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.stat-card:nth-child(2) { animation-delay: 0.04s; }
.stat-card:nth-child(3) { animation-delay: 0.08s; }
.stat-card:nth-child(4) { animation-delay: 0.12s; }
.stat-card:nth-child(5) { animation-delay: 0.16s; }
.stat-card:nth-child(6) { animation-delay: 0.2s; }
.stat-icon {
  width: 40px; height: 40px;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
  background: var(--surface-hi);
  border: 1px solid var(--border);
  color: var(--text-muted);
}
.stat-icon svg { width: 18px; height: 18px; }
.stat-body { min-width: 0; }
.stat-value { font-family: var(--font-display); font-size: var(--text-2xl); font-weight: 700; color: var(--text-bright); line-height: 1.05; }
.stat-label { font-size: var(--text-sm); color: var(--text-dim); }

.modules-heading { font-size: var(--text-xl); margin: 0 0 var(--space-5); scroll-margin-top: 84px; }
.overview-jump { display: flex; justify-content: center; margin-top: var(--space-8); }
.overview-jump .btn { gap: 8px; }
.overview-jump svg { width: 15px; height: 15px; }

.activity-row { display: flex; flex-direction: column; gap: 2px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.activity-row:last-child { border-bottom: none; }
.activity-action { font-size: var(--text-sm); color: var(--text); }
.activity-meta { font-size: var(--text-xs); color: var(--text-dim); }
@media (prefers-reduced-motion: reduce) { .stat-card { animation: none; } .stat-card:hover { transform: none; } }

/* Server hero -----------------------------------------------------------
   The overview is the first thing you see after picking a server, so it
   gets the full viewport rather than sitting as a short band above a lot
   of dead space. Height is min-height, not height: on a laptop with a lot
   of modules enabled the panels still need room to grow. */
.server-hero {
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
  padding: var(--space-7);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background:
    radial-gradient(110% 70% at 50% 0%, rgba(255, 255, 255, 0.055), transparent 62%),
    linear-gradient(180deg, var(--surface-alt), transparent 70%);
}
/* The grid wash from the marketing site, faded out at the edges so it
   never fights the cards sitting on top of it. */
.server-hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(var(--border) 1px, transparent 1px),
    linear-gradient(90deg, var(--border) 1px, transparent 1px);
  background-size: 58px 58px;
  opacity: 0.5;
  -webkit-mask-image: radial-gradient(85% 65% at 50% 22%, #000 20%, transparent 76%);
  mask-image: radial-gradient(85% 65% at 50% 22%, #000 20%, transparent 76%);
  pointer-events: none;
}
.server-hero > * { position: relative; z-index: 1; }

.server-hero-id { display: flex; align-items: center; gap: var(--space-4); }
.server-icon-hero {
  width: 72px; height: 72px; border-radius: 20px;
  border: 1px solid var(--border-hi); object-fit: cover; flex-shrink: 0;
}
.hero-eyebrow {
  display: block; font-size: var(--text-xs); letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--text-dim); margin-bottom: 6px;
}
.server-hero-id h1 { margin: 0; font-size: var(--text-3xl); line-height: 1.05; }

/* The two panels match heights, but a bounded one: the activity list scrolls
   inside itself instead of stretching the row to fit every entry, which is
   what left the Modules card as a mostly-empty column. */
.hero-panels { align-items: stretch; }
.hero-panels > .settings-group {
  display: flex;
  flex-direction: column;
  min-height: 0;
}
#overviewActivity {
  flex: 1;
  min-height: 0;
  max-height: 320px;
  overflow-y: auto;
  padding-right: 4px;
}
#overviewModules { align-content: flex-start; }

/* The small header is redundant while the hero is showing its own, bigger
   copy - but it still carries the server name on module panes. */
.settings-shell.overview-mode > .server-header { display: none; }

@media (max-width: 860px) {
  .server-hero { min-height: 0; padding: var(--space-6) var(--space-5); }
  .server-icon-hero { width: 56px; height: 56px; border-radius: 16px; }
}

/* Rule cards ------------------------------------------------------------
   One row of a module list (an auto-delete rule, a watcher, a scheduled
   message). The fields flow into as many columns as fit, so a row with two
   short fields does not stretch them across the whole pane. */
.rule-card { padding: 16px; }
.rule-fields {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-start;
}
/* A textarea is always its own line - sharing a row with a text input makes
   both too narrow to use. */
.rule-fields > .field:has(textarea) { flex: 1 0 100%; }
.rule-fields > .field { margin-bottom: 0; }
/* Toggles sit on their own line under the inputs rather than being squeezed
   in beside them. */
.rule-fields > .toggle-field { flex: 1 0 100%; margin-bottom: 0; }
.rule-card .rule-remove { margin-top: 12px; }

/* Page transition ---------------------------------------------------------
   Covers the viewport while a page loads and while navigating away, so a
   click reads as a transition instead of a blank flash. Kept short: a loader
   that outlasts its page is worse than none. */
.page-loader-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  opacity: 1;
  transition: opacity 0.3s ease;
}
.page-loader-overlay.is-done {
  opacity: 0;
  pointer-events: none;
}

.page-loader-mark {
  position: relative;
  display: grid;
  place-items: center;
  width: 72px;
  height: 72px;
}
.page-loader-mark svg {
  width: 26px;
  height: 26px;
  fill: var(--text);
  animation: loaderPulse 1.4s ease-in-out infinite;
}
/* The ring is a bordered circle with one edge coloured, spun. Cheaper than an
   SVG stroke animation and it matches the wordmark's diamond. */
.page-loader-ring {
  position: absolute;
  inset: 0;
  border: 2px solid var(--border);
  border-top-color: var(--text);
  border-radius: 50%;
  animation: loaderSpin 0.9s linear infinite;
}
/* Empty and takes no space until a caller passes a message (e.g. locale.js
   switching languages) - most page loads never show any text here. */
.page-loader-text {
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  margin-top: 16px;
  white-space: nowrap;
  font-size: var(--text-sm);
  color: var(--text-muted);
}
.page-loader-text:empty { display: none; }

@keyframes loaderSpin { to { transform: rotate(360deg); } }
@keyframes loaderPulse {
  0%, 100% { opacity: 0.45; transform: scale(0.92); }
  50%      { opacity: 1;    transform: scale(1); }
}

/* In-page busy state, for work with no page load behind it (opening a module
   pane). The target dims and shows the same ring. */
.is-busy {
  position: relative;
  pointer-events: none;
}
.is-busy > * { opacity: 0.35; transition: opacity 0.15s ease; }
.is-busy::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 30px;
  height: 30px;
  margin: -15px 0 0 -15px;
  border: 2px solid var(--border);
  border-top-color: var(--text);
  border-radius: 50%;
  animation: loaderSpin 0.75s linear infinite;
}

/* An overlay that cannot animate away is a trap, so reduced-motion drops the
   whole thing rather than showing a static block. */
@media (prefers-reduced-motion: reduce) {
  .page-loader-overlay { display: none; }
  .is-busy::after { animation: none; }
  .is-busy > * { opacity: 1; }
  .is-busy { pointer-events: auto; }
}

/* Overview module grid --------------------------------------------------
   Every switchable module, on or off, so the card reports the server's
   actual state instead of listing only what happens to be enabled. Each is
   a shortcut into that module's settings. */
.mod-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
  gap: 8px;
}
.mod-tile {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm, 10px);
  background: var(--surface);
  color: var(--text-muted);
  font: inherit;
  font-size: var(--text-sm);
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease, transform 0.15s ease;
}
.mod-tile:hover {
  border-color: var(--border-hi);
  background: var(--surface-alt);
  transform: translateY(-1px);
}
.mod-tile-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-dim);
  flex-shrink: 0;
  transition: background 0.15s ease, box-shadow 0.15s ease;
}
/* On is stated with colour and a glow rather than only a brighter grey,
   which was indistinguishable at a glance in a list this long. */
.mod-tile.is-on { color: var(--text); border-color: var(--border-hi); }
.mod-tile.is-on .mod-tile-dot {
  background: #7dd3a0;
  box-shadow: 0 0 0 3px rgba(125, 211, 160, 0.16);
}
.mod-tile-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Activity rows: a readable list rather than undifferentiated lines. */
.act-row { padding: 10px 0; border-bottom: 1px solid var(--border); }
.act-row:last-child { border-bottom: none; }
.act-row strong { display: block; font-weight: 600; font-size: var(--text-sm); }
.act-meta { color: var(--text-dim); font-size: var(--text-xs); margin-top: 2px; }

/* Breathing room ---------------------------------------------------------
   Several blocks sat flush against the container edge or against each other,
   which read as cramped even though nothing was actually overflowing. These
   are spacing corrections only. */

/* The shell started immediately under the sticky header. */
.settings-shell { padding-top: var(--space-6); padding-bottom: var(--space-8); }
.settings-shell > .back-link { display: inline-block; margin-bottom: var(--space-4); }

/* The hero and the module grid below it were touching. */
#serverOverview { margin-bottom: var(--space-8); }
.modules-heading { margin-top: var(--space-8); }

/* Cards inside the hero had tight inner padding relative to their size. */
.hero-panels > .settings-group { padding: var(--space-6); }

/* Module tiles ran to the very edge of their card. */
#overviewModules { padding-top: 4px; }

/* Panes: the action bar was flush against the last field. */
.pane-actions { margin-top: var(--space-7); padding-top: var(--space-5); border-top: 1px solid var(--border); }

/* Rule cards stacked with no gap between them. */
#amList, #adList, #apList, #smList, #ccList, #soList, #fmList, #emList,
#gwHostRoles, #abKeywords, #arList { display: flex; flex-direction: column; gap: var(--space-4); }

/* On narrow screens the container gutter was the only thing between content
   and the viewport edge, which is too little at that size. */
@media (max-width: 640px) {
  .container { padding-left: var(--space-4); padding-right: var(--space-4); }
  .pane { padding: var(--space-5); }
}

/* Account menu ------------------------------------------------------------
   The dropdown was a single unlabelled "Log out" link in a bare box. It now
   carries the account it belongs to, the plan, and the account actions, so it
   reads as a menu rather than a stray link. */
.user-menu-dropdown { min-width: 236px; padding: 8px; }

.user-menu-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px 10px;
}
.user-menu-head img {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--border);
  flex-shrink: 0;
}
.user-menu-name {
  font-weight: 600;
  font-size: var(--text-md);
  /* A long username should truncate rather than widen the whole panel. */
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.user-menu-plan { margin-top: 3px; }

.plan-chip {
  display: inline-block;
  font-size: var(--text-xs);
  letter-spacing: 0.04em;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-hi);
  color: var(--text-muted);
}
.plan-chip.is-loading { opacity: 0.6; }
/* Supporter gets the brand accent, so the difference is visible at a glance
   without needing to read the label. */
.plan-chip.is-supporter {
  color: #c4b5fd;
  border-color: rgba(139, 92, 246, 0.45);
  background: rgba(139, 92, 246, 0.14);
}
.plan-chip.is-archived {
  color: var(--text-dim);
  border-color: var(--border);
  background: var(--surface);
}

.user-menu-sep {
  height: 1px;
  background: var(--border);
  margin: 6px 4px;
}

/* Overrides the plain anchor rule above: these are icon + label rows. */
.user-menu-dropdown .user-menu-item {
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  font-size: var(--text-sm);
  color: var(--text-muted);
}
.user-menu-dropdown .user-menu-item:hover { background: var(--surface-alt); color: var(--text); }
.user-menu-item svg { width: 15px; height: 15px; flex-shrink: 0; }
.user-menu-item.is-danger { color: #e5a3a3; }
.user-menu-item.is-danger:hover { background: rgba(229, 72, 77, 0.12); color: #ff8b8b; }

/* The caret needs its own selector now that the menu contains other svgs. */
.user-menu-trigger .user-menu-caret { width: 14px; height: 14px; }

/* Account modal, logout veil, spacing corrections ------------------------- */

.acct-modal {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: grid;
  place-items: center;
  padding: var(--space-5);
  background: rgba(0, 0, 0, 0.62);
  opacity: 0;
  transition: opacity 0.18s ease;
}
.acct-modal.is-open { opacity: 1; }

.acct-modal-card {
  width: min(900px, 100%);
  height: auto;
  max-height: min(86vh, 760px);
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border-hi);
  border-radius: var(--radius-lg);
  background: var(--bg-subtle);
  box-shadow: var(--shadow-lg);
  transform: translateY(8px) scale(0.985);
  transition: transform 0.18s ease;
}
.acct-modal.is-open .acct-modal-card { transform: none; }

.acct-modal-head {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-5) var(--space-6);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.acct-modal-head img {
  width: 44px; height: 44px; border-radius: 50%;
  border: 1px solid var(--border-hi); flex-shrink: 0;
}
.acct-modal-name { font-weight: 600; }
.acct-modal-id { color: var(--text-dim); font-size: var(--text-xs); }
.acct-modal-x {
  margin-left: auto;
  background: none; border: none; cursor: pointer;
  color: var(--text-dim); font-size: 26px; line-height: 1;
  padding: 0 4px; transition: color 0.15s ease;
}
.acct-modal-x:hover { color: var(--text); }

.badge-grid { display: grid; gap: var(--space-4); }
.badge-card {
  display: flex;
  gap: var(--space-4);
  align-items: flex-start;
  border: 1px solid var(--border);
  border-radius: var(--radius-md, 14px);
  background: var(--surface-alt);
  padding: var(--space-4);
}
.badge-medal {
  width: 42px;
  height: 42px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  border-radius: 12px;
  border: 1px solid var(--border);
}
.badge-medal svg { width: 20px; height: 20px; }
.badge-card.is-supporter .badge-medal { color: #c4b5fd; border-color: rgba(139,92,246,0.45); background: rgba(139,92,246,0.14); }
.badge-card.is-early .badge-medal { color: #7dd3a0; border-color: rgba(125,211,160,0.4); background: rgba(125,211,160,0.12); }
.badge-title { font-weight: 600; margin-bottom: 2px; }
.badge-reason { color: var(--text-muted); font-size: var(--text-sm); margin: 0 0 4px; }
.badge-date { color: var(--text-dim); font-size: var(--text-xs); margin: 0; }

/* Below the header: a left sidebar of section tabs (Discord's own settings
   layout) and the active section's content beside it, instead of a row of
   tabs squeezed across the top. Every tab's data still starts loading the
   instant the modal opens (see user-menu.js), so switching tabs is never
   itself a wait. */
.acct-modal-main {
  display: flex;
  flex: 1;
  min-height: 0;
}
.acct-tabs {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex-shrink: 0;
  width: 200px;
  padding: var(--space-4);
  border-right: 1px solid var(--border);
  overflow-y: auto;
}
.acct-tab {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px var(--space-3);
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: var(--text-sm);
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  white-space: nowrap;
  transition: color 0.15s ease, background-color 0.15s ease;
}
.acct-tab svg { width: 16px; height: 16px; flex-shrink: 0; }
.acct-tab:hover { color: var(--text); background: var(--surface); }
.acct-tab.is-active { color: var(--text-bright); background: var(--surface-hi); }

/* The body scrolls, the header and footer do not, so Save is always reachable
   however many badges someone has. */
.acct-modal-body { flex: 1; min-width: 0; overflow-y: auto; padding: var(--space-6) var(--space-7); }
.acct-section { margin-bottom: var(--space-6); }
.acct-section:last-child { margin-bottom: 0; }
.acct-section h3 {
  margin: 0 0 var(--space-3);
  font-size: var(--text-xs);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-dim);
}
.acct-subhead {
  margin: var(--space-5) 0 var(--space-3);
  font-size: var(--text-xs);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-dim);
}
.acct-section .acct-subhead:first-child { margin-top: 0; }
.acct-muted { margin: 0; font-size: var(--text-sm); }
.acct-billing-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: var(--space-3);
}

.acct-invoice-list { display: flex; flex-direction: column; gap: 2px; }
.acct-invoice-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--border);
  font-size: var(--text-sm);
}
.acct-invoice-row:last-child { border-bottom: none; }
.acct-invoice-date { flex: 1; color: var(--text-muted); }
.acct-invoice-amount { font-family: var(--font-mono); font-weight: 600; }
.acct-invoice-status {
  font-size: var(--text-xs);
  text-transform: capitalize;
  color: var(--text-dim);
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
}
.acct-invoice-status.is-paid { color: #7dd3a0; border-color: rgba(125, 211, 160, 0.4); }
.acct-invoice-status.is-open { color: #f0b429; border-color: rgba(240, 180, 41, 0.4); }
.acct-invoice-link { color: #c4b5fd; text-decoration: none; font-weight: 500; }
.acct-invoice-link:hover { text-decoration: underline; }

@media (max-width: 480px) {
  .acct-invoice-row { flex-wrap: wrap; }
  .acct-invoice-date { flex-basis: 100%; }
}

.acct-server-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--border);
  animation: acctRowIn 0.22s var(--ease-out);
}
.acct-server-row:last-child { border-bottom: none; }
@keyframes acctRowIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: none; }
}
.acct-server-icon { width: 32px; height: 32px; border-radius: 50%; border: 1px solid var(--border); flex-shrink: 0; }
.acct-server-main { flex: 1; min-width: 0; display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; }
.acct-server-name { font-weight: 600; font-size: var(--text-sm); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 220px; }
.acct-server-side { flex-shrink: 0; text-align: right; }
.acct-server-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

@media (max-width: 480px) {
  .acct-server-row { flex-wrap: wrap; }
  .acct-server-side { width: 100%; text-align: left; }
  .acct-server-actions { justify-content: flex-start; }
}

.acct-email-row { display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; margin-bottom: var(--space-3); }
.acct-email-badge { font-size: var(--text-xs); padding: 2px 8px; border-radius: 999px; border: 1px solid var(--border); }
.acct-email-badge.is-verified { color: #7dd3a0; border-color: rgba(125, 211, 160, 0.4); }
.acct-email-badge.is-pending { color: #f0b429; border-color: rgba(240, 180, 41, 0.4); }
.acct-email-form { display: flex; gap: var(--space-2); flex-wrap: wrap; }
.acct-email-form input[type="email"] {
  flex: 1; min-width: 200px; padding: 9px 12px; border-radius: var(--radius-sm, 8px);
  border: 1px solid var(--border); background: var(--surface-2, transparent); color: inherit; font: inherit;
}
.acct-email-msg { margin: var(--space-2) 0 0; font-size: var(--text-sm); min-height: 1.4em; }
.acct-email-msg.is-ok { color: #7dd3a0; }
.acct-email-msg.is-bad { color: #f28b82; }
.acct-email-prompt-card { max-width: 420px; }

.acct-pref {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-4) 0;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}
.acct-pref:last-child { border-bottom: none; padding-bottom: 0; }
.acct-pref span { display: grid; gap: 2px; }
.acct-pref em { font-style: normal; color: var(--text-dim); font-size: var(--text-xs); }
.acct-pref input { width: 17px; height: 17px; flex-shrink: 0; accent-color: #8b5cf6; }

.acct-modal-foot {
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}
.acct-foot-right { margin-left: auto; display: flex; gap: 8px; }
.acct-saved { color: #7dd3a0; font-size: var(--text-xs); width: 100%; text-align: right; }
.acct-app-version {
  margin: 0;
  padding: var(--space-2) var(--space-6) var(--space-4);
  font-size: var(--text-xs);
  color: var(--text-dim);
  text-align: center;
}

/* Logout ------------------------------------------------------------------
   Signing out ends the session, so it gets a moment of acknowledgement
   rather than an abrupt reload. */
.logout-veil {
  position: fixed; inset: 0; z-index: 400;
  display: grid; place-items: center;
  background: var(--bg);
  opacity: 0;
  transition: opacity 0.28s ease;
}
.logout-veil.is-open { opacity: 1; }
.logout-mark { display: grid; justify-items: center; gap: var(--space-4); color: var(--text); }
.logout-mark svg { width: 32px; height: 32px; animation: logoutSlide 0.9s ease-in-out infinite; }
.logout-mark p { margin: 0; color: var(--text-muted); font-size: var(--text-sm); }
@keyframes logoutSlide {
  0%, 100% { transform: translateX(-3px); opacity: 0.55; }
  50%      { transform: translateX(3px);  opacity: 1; }
}

/* A saved "reduce motion" preference must win over the site's own defaults,
   which is what the class on <html> is for. */
.force-reduce-motion *,
.force-reduce-motion *::before,
.force-reduce-motion *::after {
  animation-duration: 0.001ms !important;
  transition-duration: 0.001ms !important;
}

@media (prefers-reduced-motion: reduce) {
  .acct-modal, .acct-modal-card, .logout-veil { transition: none; }
  .logout-mark svg { animation: none; }
}

/* Spacing ----------------------------------------------------------------
   Panels were butting into each other and into their own borders. These set
   consistent internal padding and outer rhythm rather than relying on each
   component to remember. */
.section { padding-block: var(--space-7); }
.page-head { padding-block: var(--space-7) var(--space-6); }

.card, .settings-group, .pane {
  /* A border with content pressed against it reads as broken, which is what
     several panels were doing. */
  padding: var(--space-6);
}
.settings-group + .settings-group { margin-top: var(--space-5); }
.pane > h2 { margin: 0 0 var(--space-5); }
.pane-grid { gap: var(--space-6); }

.field { margin-bottom: var(--space-5); }
.field:last-child { margin-bottom: 0; }
.field label { display: block; margin-bottom: 8px; }
.hint { margin: 8px 0 0; }

.toggle-field { padding-block: var(--space-3); }

@media (max-width: 640px) {
  .card, .settings-group, .pane { padding: var(--space-5); }
  .acct-modal { padding: var(--space-3); }
  .acct-modal-head, .acct-modal-body, .acct-modal-foot { padding-inline: var(--space-5); }
  /* The left sidebar doesn't fit next to content on a phone - back to a
     horizontal tab strip across the top, same as before this redesign. */
  .acct-modal-card { width: 100%; height: min(92vh, 760px); }
  .acct-modal-main { flex-direction: column; }
  .acct-tabs { flex-direction: row; width: 100%; padding: var(--space-3) var(--space-5); border-right: none; border-bottom: 1px solid var(--border); overflow-x: auto; overflow-y: visible; }
  .acct-modal-body { padding: var(--space-5); }
}

/* The Settings entry is a button (it opens a modal) sitting among links, so
   it inherits the browser's button chrome unless it is reset to match. */
/* Only what a <button> needs on top of the shared item styling above: the
   browser gives it its own background, border, font and centred text. */
.user-menu-dropdown button.user-menu-item {
  width: 100%;
  background: none;
  border: none;
  font-family: inherit;
  font-weight: inherit;
  text-align: left;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}
.user-menu-dropdown button.user-menu-item:focus-visible { outline: 2px solid var(--border-hi); outline-offset: -2px; }

/* Default checkboxes are a bright white square against a dark panel. These
   are drawn to match the rest of the UI. */
.acct-pref input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 40px;
  height: 22px;
  border-radius: 999px;
  border: 1px solid var(--border-hi);
  background: var(--surface-hi);
  position: relative;
  cursor: pointer;
  transition: background 0.16s ease, border-color 0.16s ease;
}
.acct-pref input[type="checkbox"]::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--text-dim);
  transition: transform 0.16s ease, background 0.16s ease;
}
.acct-pref input[type="checkbox"]:checked {
  background: rgba(139, 92, 246, 0.3);
  border-color: rgba(139, 92, 246, 0.6);
}
.acct-pref input[type="checkbox"]:checked::after {
  transform: translateX(18px);
  background: #c4b5fd;
}
.acct-pref input[type="checkbox"]:focus-visible { outline: 2px solid var(--border-hi); outline-offset: 2px; }

/* Section headings inside the modal were flush against the panel edge on the
   left because the body padding was the only inset. */
.acct-section h3 { margin-top: 0; }
.acct-modal-body > .acct-section + .acct-section { padding-top: var(--space-5); border-top: 1px solid var(--border); }

/* Without JS nothing removes the overlay, so it only covers the page once a
   script has confirmed JS is running. */
html:not(.js) .page-loader-overlay { display: none; }

/* Supporter-gated modules ------------------------------------------------
   The gate is enforced by the API either way; this exists so nobody finds
   out by having a save rejected. */
.mod-supporter-tag {
  display: inline-block;
  margin-left: 8px;
  vertical-align: middle;
  font-size: var(--text-xs);
  font-weight: 500;
  letter-spacing: 0.04em;
  padding: 2px 8px;
  border-radius: 999px;
  color: #c4b5fd;
  border: 1px solid rgba(139, 92, 246, 0.45);
  background: rgba(139, 92, 246, 0.14);
}

.pane-locked {
  display: flex;
  align-items: flex-start;
  gap: var(--space-4);
  padding: var(--space-5);
  margin-bottom: var(--space-5);
  border: 1px solid rgba(139, 92, 246, 0.4);
  border-radius: var(--radius-md);
  background: rgba(139, 92, 246, 0.09);
}
.pane-locked svg { width: 20px; height: 20px; color: #c4b5fd; flex-shrink: 0; margin-top: 2px; }
.pane-locked h4 { margin: 0 0 4px; font-size: var(--text-md); }
.pane-locked p { margin: 0 0 var(--space-3); color: var(--text-muted); font-size: var(--text-sm); }

/* Module cards ----------------------------------------------------------
   The cards were sized by their content, so descriptions of different
   lengths left the Settings buttons at different heights across a row.
   A column layout with the action pinned to the bottom lines them up
   whatever the text does. */
.module-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}
.module-card > .spread { margin-bottom: var(--space-2); }
.module-card h3 {
  margin: 0;
  font-size: var(--text-md);
  /* The Supporter chip is inline with the title, so the line has to be
     able to wrap without the chip landing on the text. */
  line-height: 1.5;
}
.module-card p { margin: 0; font-size: var(--text-sm); }
/* Pins the action row to the bottom of whatever height the row settles on. */
.module-card > div:last-child { margin-top: auto; padding-top: var(--space-3); }

/* Locked modules ---------------------------------------------------------
   Dimmed rather than hidden: knowing the feature exists is the point of
   showing it at all. The action is a link to the plan, not a dead button,
   because a disabled control with no explanation is worse than none. */
.module-card-locked { opacity: 0.72; }
.module-card-locked:hover { opacity: 1; }
.module-card-locked .toggle { opacity: 0.45; cursor: not-allowed; }
.module-card-locked .toggle input { cursor: not-allowed; }
.module-locked-btn {
  border-color: rgba(139, 92, 246, 0.45);
  background: rgba(139, 92, 246, 0.14);
  color: #c4b5fd;
}
.module-locked-btn:hover {
  background: rgba(139, 92, 246, 0.24);
  border-color: rgba(139, 92, 246, 0.7);
  color: #ddd6fe;
}
.is-invite-paused { opacity: 0.55; cursor: not-allowed; pointer-events: none; }

/* Operator network panel -------------------------------------------------
   Whole-network totals, above the server list because it is the wider view
   of the same thing. Visible only to the operator accounts; the API returns
   404 to everyone else. */
.net-panel {
  border: 1px solid rgba(139, 92, 246, 0.35);
  border-radius: var(--radius-lg);
  background:
    radial-gradient(120% 80% at 50% 0%, rgba(139, 92, 246, 0.1), transparent 62%),
    var(--surface);
  padding: var(--space-6);
  margin-bottom: var(--space-7);
}
.net-head { margin-bottom: var(--space-5); }
.net-eyebrow {
  display: inline-block;
  font-size: var(--text-xs);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #c4b5fd;
  border: 1px solid rgba(139, 92, 246, 0.4);
  border-radius: 999px;
  padding: 2px 10px;
  margin-bottom: var(--space-3);
}
.net-head h2 { margin: 0 0 4px; font-size: var(--text-xl); }
.net-head p { margin: 0; font-size: var(--text-sm); }
.net-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: var(--space-4);
}
.net-tile {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-alt);
  padding: var(--space-4);
}
.net-value { font-size: var(--text-xl); font-weight: 600; line-height: 1.1; }
.net-label { color: var(--text-dim); font-size: var(--text-xs); margin-top: 4px; }

/* Labels a second stat grid (Amplify's own numbers) as its own section
   rather than letting it read as a continuation of the row above it. */
.op-subhead {
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.op-status-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: var(--space-3);
}
.op-status-row {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-alt);
  padding: 10px 14px;
}
.op-status-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; background: var(--text-dim); }
.op-status-dot.is-on { background: var(--success); }
.op-status-dot.is-off { background: var(--danger); }
.op-status-name { flex: 1; font-size: var(--text-sm); }
.op-status-state { font-size: var(--text-xs); font-weight: 600; color: var(--text-dim); }
.op-status-state.is-on { color: var(--success); }
.op-status-state.is-off { color: var(--danger); }

/* Blacklisted server card ------------------------------------------------ */
.guild-card.is-blacklisted { opacity: 0.6; border-color: rgba(229, 72, 77, 0.4); }
.guild-blacklist-warn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--text-xs);
  color: #e5a3a3;
  border: 1px solid rgba(229, 72, 77, 0.4);
  background: rgba(229, 72, 77, 0.12);
  border-radius: 999px;
  padding: 3px 10px;
}
.guild-blacklist-warn svg { width: 12px; height: 12px; }

/* Operator panel ---------------------------------------------------------
   Sits below the server list: even for an operator, the reason to open the
   dashboard is still to manage a server. Sections are collapsed by default
   because almost always exactly one of them is wanted. */
.op-panel {
  border: 1px solid rgba(139, 92, 246, 0.35);
  border-radius: var(--radius-lg);
  background:
    radial-gradient(120% 70% at 50% 0%, rgba(139, 92, 246, 0.09), transparent 62%),
    var(--surface);
  padding: var(--space-6);
  margin-top: var(--space-8);
  margin-bottom: var(--space-8);
}
.op-head { margin-bottom: var(--space-5); }
.op-eyebrow {
  display: inline-block;
  font-size: var(--text-xs);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #c4b5fd;
  border: 1px solid rgba(139, 92, 246, 0.4);
  border-radius: 999px;
  padding: 2px 10px;
  margin-bottom: var(--space-3);
}
.op-head h2 { margin: 0 0 4px; font-size: var(--text-xl); }
.op-head p { margin: 0; font-size: var(--text-sm); }
.op-muted { margin: 0; font-size: var(--text-sm); }

.op-section {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-alt);
  margin-top: var(--space-4);
  overflow: hidden;
}
/* Was flex + space-between: title flush left, description flush right - 
 * which only ever *looked* roughly centered for a description short enough
 * to leave the title sitting near the middle by coincidence. Two things
 * tried and rejected before this: plain text-align:center needs
 * display:block, which un-suppresses <summary>'s native disclosure marker
 * (showed up as a stray "|"); and absolutely-centering the title over a
 * flex row centers it against the row's full width regardless of the
 * description, which overlaps a long description on a narrow screen. A
 * 3-column grid (empty spacer / title / description) is what actually
 * gets real centering without either problem - the two `1fr` tracks stay
 * equal width whatever the description's own length is, which is what
 * keeps the title genuinely centered, and the description gets a real
 * reserved column instead of floating over anything. */
.op-section summary {
  display: grid;
  /* minmax(0, 1fr), not plain 1fr - a plain fr track still grows past its
   * "fair share" to fit its content when that content is wider (exactly
   * what a long description does here), which pushed the title off-center
   * again. minmax(0, ...) caps it, so both flanking tracks stay genuinely
   * equal width and the description wraps inside its own instead. */
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: baseline;
  column-gap: var(--space-4);
  padding: var(--space-4) var(--space-5);
  padding-right: calc(var(--space-5) + 22px);
  position: relative;
  cursor: pointer;
  font-weight: 600;
  list-style: none;
  transition: background-color .14s ease;
}
.op-section summary > span:first-child {
  grid-column: 2;
  justify-self: center;
  text-align: center;
}
.op-section summary .op-summary-hint {
  grid-column: 3;
  justify-self: end;
  text-align: right;
  min-width: 0;
}
/* The default disclosure triangle sits badly against a flex summary - swap
   it for a chevron on the trailing edge (the conventional side for an
   expand/collapse indicator) that rotates with the open state. */
.op-section summary::-webkit-details-marker { display: none; }
.op-section summary::marker { content: ""; display: none; }
.op-section summary::after {
  content: "";
  position: absolute;
  right: var(--space-5);
  top: 50%;
  width: 8px;
  height: 8px;
  margin-top: -6px;
  border-right: 2px solid var(--text-dim);
  border-bottom: 2px solid var(--text-dim);
  transform: rotate(45deg);
  transition: transform .16s ease, border-color .16s ease;
}
.op-section[open] > summary::after { transform: rotate(-135deg); margin-top: -3px; border-color: var(--accent); }
.op-section summary:hover { background: var(--surface-hi); }
.op-section summary:hover::after { border-color: var(--text-bright); }
.op-section[open] { border-color: var(--border-hi); }
.op-section[open] > summary { background: var(--surface-hi); border-bottom: 1px solid var(--border); }
.op-summary-hint { color: var(--text-dim); font-size: var(--text-xs); font-weight: 400; text-align: right; }
/* The 3-column centered-title grid above only really works with room to
 * spare either side of the title - on a phone-width screen there isn't
 * any, and a longer hint (Network News' description especially) has
 * nowhere to go but overlap or spill past the edge. Stacked and
 * left-aligned instead: title on its own row, hint wrapping normally
 * underneath, both full width. */
@media (max-width: 640px) {
  .op-section summary {
    grid-template-columns: 1fr auto;
    row-gap: 4px;
    padding-right: calc(var(--space-4) + 22px);
  }
  .op-section summary > span:first-child {
    grid-column: 1 / -1;
    grid-row: 1;
    justify-self: start;
    text-align: left;
  }
  .op-section summary .op-summary-hint {
    grid-column: 1 / -1;
    grid-row: 2;
    justify-self: start;
    text-align: left;
    white-space: normal;
  }
}
/* Opening/closing is animated by JS (native <details> snaps its content to
   display:none/block instantly - no CSS transition can smooth that), which
   sets an explicit height and toggles .is-animating around the transition. */
.op-body { padding: var(--space-5); box-sizing: border-box; }
.op-section.is-animating > .op-body { overflow: hidden; transition: height .22s var(--ease-out, ease); }
@media (prefers-reduced-motion: reduce) {
  .op-section.is-animating > .op-body { transition: none; }
}

.op-form {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: var(--space-5);
  padding-bottom: var(--space-5);
  border-bottom: 1px solid var(--border);
}
.op-form input { flex: 1; min-width: 160px; margin: 0; }
.op-form textarea, .op-form select { flex: 1; min-width: 160px; margin: 0; resize: none; }
.op-form select { appearance: none; -webkit-appearance: none; padding-right: 2.5rem; color-scheme: dark; background-image: linear-gradient(45deg, transparent 50%, var(--text-dim) 50%), linear-gradient(135deg, var(--text-dim) 50%, transparent 50%); background-position: calc(100% - 16px) 50%, calc(100% - 11px) 50%; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; }
.op-form button[type="submit"] { flex: 0 0 auto; white-space: nowrap; }
.op-emoji-picker { position: absolute; z-index: 20; top: 100%; left: 0; margin-top: 4px; width: 260px; max-height: 220px; overflow-y: auto; padding: 8px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface-solid); box-shadow: 0 8px 24px rgba(0,0,0,.35); display: flex; flex-wrap: wrap; gap: 4px; }
.op-emoji-item { width: 36px; height: 36px; display: flex; align-items: center; justify-content: center; border-radius: 6px; border: 1px solid transparent; background: transparent; cursor: pointer; padding: 0; }
.op-emoji-item:hover { background: var(--surface-hi); border-color: var(--border); }
.op-emoji-item img { width: 24px; height: 24px; display: block; }
.op-row-actions .btn { white-space: nowrap; }
/* Each capability is the exact same row component as a Switches toggle
   (.acct-pref.op-flag) - one label, one pill switch, full width - instead of
   a grid of small inline checkboxes. Same control, same look, everywhere. */
.op-capabilities {
  width: 100%;
  padding: var(--space-2) var(--space-4) 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
}
.op-capabilities-title { padding: var(--space-3) 0; font-weight: 600; color: var(--text); font-size: var(--text-sm); }
.op-capabilities .op-flag { padding: var(--space-3) 0; }
/* .op-form input { flex: 1; min-width: 160px } (meant for text fields)
   reaches this checkbox too, since it's nested inside the same <form>.
   flex:0 0 auto alone fixed the flex-grow stretch, but left the 160px
   min-width in effect - min-width always wins over a smaller explicit
   width, so the pill was still forced out to 160px regardless. Both have
   to be pinned back down to the toggle's own natural size. */
.op-capabilities .op-flag input[type="checkbox"] { flex: 0 0 auto; min-width: 0; }
.op-capabilities .op-flag input[type="checkbox"]:disabled { cursor: not-allowed; opacity: .55; }
.op-status { color: var(--text-dim); font-size: var(--text-xs); flex-basis: 100%; }
.op-status:empty { display: none; }
/* A plain field label inside .op-form, for a control (the News form's
 * extra-buttons list) that isn't itself an <input> with a placeholder. */
.op-form-label { display: block; font-size: var(--text-sm); color: var(--text-dim); margin-bottom: var(--space-2); }

@media (max-width: 560px) {
  .op-capabilities { grid-template-columns: 1fr; }
}

.op-row {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--border);
}
.op-row:last-child { border-bottom: none; }

.op-incident-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-alt);
  padding: var(--space-4);
  margin-bottom: var(--space-3);
}
.op-incident-card .op-row { border-bottom: none; padding-top: 0; }
.op-incident-timeline { display: grid; gap: 8px; margin: var(--space-3) 0; }
.op-incident-update {
  border-left: 2px solid var(--border-hi);
  padding-left: 10px;
}
.op-incident-update p { margin: 4px 0 0; font-size: var(--text-sm); }
.op-incident-update-form { flex-wrap: nowrap; gap: 6px; margin-top: var(--space-2); }
.op-incident-update-form select { flex: 0 0 auto; width: auto; }
.op-incident-update-form input { flex: 1; }

/* A result list (the server search, most visibly) swapping in instantly
 * reads as a bug even when it's working correctly - nothing on screen
 * moved, so a slow response and an empty result look identical for a
 * beat. Each row fading and settling in, staggered a little per row,
 * gives the eye something to track and makes the list feel like it
 * arrived rather than teleported. Skipped entirely under reduced motion,
 * same as the rest of the site. */
@media (prefers-reduced-motion: no-preference) {
  #opServerSearchResults .op-row {
    animation: op-row-in 0.28s var(--ease-out) backwards;
  }
  #opServerSearchResults .op-row:nth-child(n+2) { animation-delay: 0.03s; }
  #opServerSearchResults .op-row:nth-child(n+3) { animation-delay: 0.06s; }
  #opServerSearchResults .op-row:nth-child(n+4) { animation-delay: 0.09s; }
  #opServerSearchResults .op-row:nth-child(n+5) { animation-delay: 0.12s; }
  #opServerSearchResults .op-row:nth-child(n+6) { animation-delay: 0.15s; }
}
@keyframes op-row-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

/* A pulsing placeholder instead of static "Searching…" text - matches the
 * shape of what's about to appear, so the swap from loading to results
 * feels continuous rather than one flat state replacing another. */
.op-search-skeleton { display: flex; flex-direction: column; gap: var(--space-3); padding: var(--space-2) 0; }

/* The "Use a template" bar a few panes show under their <h2> - empty (no
 * templates published yet for that module) collapses to nothing rather
 * than showing an empty bar. */
.template-picker:empty { display: none; }
.template-picker {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
  margin: var(--space-3) 0 var(--space-5);
  padding: var(--space-3) var(--space-4);
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.template-picker select { flex: 1; min-width: 180px; }
.template-picker .hint { flex-basis: 100%; margin: 0; }

/* The Overview / Modules / Templates tab strip at the top of a server's
 * settings page - three views on the same page, switched in server.js. */
.settings-tabs {
  display: flex;
  gap: var(--space-2);
  margin-bottom: var(--space-6);
  border-bottom: 1px solid var(--border);
}
.settings-tab {
  appearance: none;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  padding: var(--space-3) var(--space-1);
  margin-bottom: -1px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
}
.settings-tab + .settings-tab { margin-left: var(--space-4); }
.settings-tab:hover { color: var(--text); }
.settings-tab.is-active { color: var(--text); border-bottom-color: var(--accent); }

/* The Templates tab's browser view. */
.template-filter-bar { align-items: center; }
.template-search {
  flex: 1;
  min-width: 220px;
  max-width: 360px;
}
#templateModuleFilter { min-width: 200px; }
.template-grid { gap: var(--space-4); }
.template-card { display: flex; flex-direction: column; }
.template-card h3 { margin: var(--space-2) 0 var(--space-1); }
.template-import-status { min-height: 1.2em; }
.op-search-skeleton-row { height: 42px; border-radius: var(--radius-sm); background: var(--surface-hi); animation: op-skeleton-pulse 1.1s ease-in-out infinite; }
.op-search-skeleton-row:nth-child(2) { animation-delay: 0.12s; }
.op-search-skeleton-row:nth-child(3) { animation-delay: 0.24s; }
@keyframes op-skeleton-pulse { 0%, 100% { opacity: 0.5; } 50% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  #opServerSearchResults .op-row { animation: none; }
  .op-search-skeleton-row { animation: none; opacity: 0.7; }
}
.op-avatar { width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--border); flex-shrink: 0; }
.op-row-main { flex: 1; min-width: 0; }
.op-row-name { font-weight: 600; font-size: var(--text-sm); }
.op-row-id { font-size: var(--text-xs); color: var(--text-dim); }
.op-sub { display: block; color: var(--text-dim); font-size: var(--text-xs); margin-top: 2px; }
.op-row-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; text-align: right; flex-shrink: 0; }
.op-row-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; flex-wrap: wrap; justify-content: flex-end; }
.op-place { font-weight: 600; font-size: var(--text-sm); color: #7dd3a0; }
/* Report bodies vary wildly in length; clamp so one essay does not push
   every other report off the screen. */
.op-report { align-items: flex-start; }
.op-report-body {
  margin: 6px 0 0;
  font-size: var(--text-xs);
  color: var(--text-muted);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.op-flag { border-bottom: 1px solid var(--border); }
.op-flag:last-child { border-bottom: none; }

@media (max-width: 640px) {
  .op-row { flex-wrap: wrap; }
  .op-row-meta { align-items: flex-start; text-align: left; }
  .op-row-actions { justify-content: flex-start; width: 100%; }
}

/* Dashboard lock ---------------------------------------------------------
   A maintenance switch, not a security boundary: the API still authorises
   every request. This stops people writing settings into a system being
   repaired, and says so plainly rather than failing silently. */
.dash-lock-banner {
  display: flex;
  align-items: flex-start;
  gap: var(--space-4);
  border: 1px solid rgba(240, 180, 41, 0.4);
  background: rgba(240, 180, 41, 0.1);
  border-radius: var(--radius-md);
  padding: var(--space-4) var(--space-5);
  margin-bottom: var(--space-6);
}
.dash-lock-banner svg { width: 20px; height: 20px; color: #f0b429; flex-shrink: 0; margin-top: 2px; }
.dash-lock-banner strong { display: block; font-size: var(--text-sm); }
.dash-lock-banner span { display: block; color: var(--text-muted); font-size: var(--text-xs); margin-top: 2px; }

.guild-card.is-dash-locked { opacity: 0.6; }
.dash-lock-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--text-xs);
  color: #f0b429;
  border: 1px solid rgba(240, 180, 41, 0.4);
  background: rgba(240, 180, 41, 0.12);
  border-radius: 999px;
  padding: 4px 10px;
}
.dash-lock-badge svg { width: 12px; height: 12px; }

/* Link to the operator panel from the dashboard home. Discovery only: the
   page and every route behind it return 404 to anyone else. */
.op-link-card {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  border: 1px solid rgba(139, 92, 246, 0.35);
  border-radius: var(--radius-md);
  background: rgba(139, 92, 246, 0.07);
  padding: var(--space-4) var(--space-5);
  margin-top: var(--space-7);
  text-decoration: none;
  color: inherit;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.op-link-card:hover { background: rgba(139, 92, 246, 0.13); border-color: rgba(139, 92, 246, 0.6); }
.op-link-mark {
  width: 38px; height: 38px; flex-shrink: 0;
  display: grid; place-items: center;
  border-radius: 10px;
  color: #c4b5fd;
  border: 1px solid rgba(139, 92, 246, 0.4);
  background: rgba(139, 92, 246, 0.14);
}
.op-link-mark svg { width: 19px; height: 19px; }
.op-link-card strong { display: block; font-size: var(--text-sm); }
.op-link-card span { display: block; color: var(--text-dim); font-size: var(--text-xs); margin-top: 2px; }
.op-link-arrow { width: 16px; height: 16px; margin-left: auto; color: var(--text-dim); flex-shrink: 0; }

/* Supporter panel --------------------------------------------------------
   Shown to everyone. Hiding it from non-supporters means nobody discovers
   the plan; hiding it from supporters means the thing they paid for is
   invisible. The state is carried by colour, not by presence. */
.sup-panel {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  padding: var(--space-6);
  margin-top: var(--space-7);
}
.sup-panel.is-active {
  border-color: rgba(139, 92, 246, 0.4);
  background:
    radial-gradient(120% 70% at 50% 0%, rgba(139, 92, 246, 0.1), transparent 62%),
    var(--surface);
}
.sup-head { margin-bottom: var(--space-5); }
.sup-head h2 { margin: 0 0 4px; font-size: var(--text-lg); }
.sup-head p { margin: 0; font-size: var(--text-sm); }
.sup-chip {
  display: inline-block;
  font-size: var(--text-xs);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 2px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-hi);
  color: var(--text-muted);
  margin-bottom: var(--space-3);
}
.sup-chip.is-active {
  color: #c4b5fd;
  border-color: rgba(139, 92, 246, 0.45);
  background: rgba(139, 92, 246, 0.14);
}
.sup-perks {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-5);
}
.sup-perk { display: flex; gap: 10px; align-items: flex-start; }
.sup-perk svg { width: 15px; height: 15px; flex-shrink: 0; margin-top: 3px; color: var(--text-dim); }
/* Ticks turn green only when the perks are actually yours, so the list
   reads as an offer rather than a false claim when you are on Free. */
.sup-perk.is-active svg { color: #7dd3a0; }
.sup-perk strong { display: block; font-size: var(--text-sm); }
.sup-perk span { display: block; color: var(--text-dim); font-size: var(--text-xs); margin-top: 2px; }
.sup-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* Operator and partner badges. Each kind gets its own colour so they stay
   distinguishable at leaderboard size, where the label is not shown. */
.badge-card.is-operator .badge-medal,
.lb-badge.is-operator {
  color: #f0b429;
  border-color: rgba(240, 180, 41, 0.45);
  background: rgba(240, 180, 41, 0.14);
}
.badge-card.is-partner .badge-medal,
.lb-badge.is-partner {
  color: #6ec8f5;
  border-color: rgba(110, 200, 245, 0.45);
  background: rgba(110, 200, 245, 0.14);
}
.badge-card.is-messages .badge-medal,
.lb-badge.is-messages {
  color: #60a5fa;
  border-color: rgba(96, 165, 250, 0.45);
  background: rgba(96, 165, 250, 0.14);
}
.badge-card.is-voice .badge-medal,
.lb-badge.is-voice {
  color: #f472b6;
  border-color: rgba(244, 114, 182, 0.45);
  background: rgba(244, 114, 182, 0.14);
}


/* ================= PLANS PAGE (app-only, see plans.html) ================= */
.plan-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr));
  gap: var(--space-5);
  max-width: 880px;
  margin: 0 auto var(--space-8);
}
.plan-card {
  position: relative;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  padding: var(--space-7);
  display: flex;
  flex-direction: column;
}
.plan-card.is-supporter {
  border-color: rgba(139, 92, 246, 0.4);
  background:
    radial-gradient(130% 80% at 50% 0%, rgba(139, 92, 246, 0.14), transparent 60%),
    var(--surface);
  box-shadow: 0 0 0 1px rgba(139, 92, 246, 0.12), 0 18px 50px -24px rgba(139, 92, 246, 0.55);
}
.plan-card.is-current { outline: 1px solid var(--border-hi); }
/* The flag sits in the border, so the card it labels needs room for it or
   it lands on top of the heading. */

/* Inline, not floated over the border. Absolute positioning put it on
   top of the plan name at every width. */
.plan-flag {
  display: inline-block;
  margin-bottom: var(--space-3);
  align-self: flex-start;
  font-size: var(--text-xs);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  padding: 3px 10px;
  border-radius: 999px;
  color: #0b0b0e;
  background: linear-gradient(90deg, #a78bfa, #8b5cf6);
}
.plan-name { margin: 0 0 var(--space-2); font-size: var(--text-xl); }
.plan-price { display: flex; align-items: baseline; gap: 6px; margin-bottom: var(--space-2); }
.plan-price strong { font-size: var(--text-3xl); line-height: 1; }
.plan-price span { color: var(--text-dim); font-size: var(--text-sm); }
.plan-tagline { color: var(--text-muted); margin: 0 0 var(--space-5); }

.plan-features { list-style: none; margin: 0 0 var(--space-6); padding: 0; display: grid; gap: 10px; }
.plan-features li { display: flex; align-items: flex-start; gap: 10px; font-size: var(--text-sm); }
.plan-features svg { width: 15px; height: 15px; flex-shrink: 0; margin-top: 2px; }
.plan-features .is-in { color: var(--text); }
.plan-features .is-in svg { color: #7dd3a0; }
/* Excluded items stay listed rather than hidden, so the difference between
   the plans is legible instead of implied. */
.plan-features .is-out { color: var(--text-dim); }
.plan-features .is-out svg { color: var(--text-dim); }

.plan-action { margin-top: auto; }
.plan-cta { width: 100%; justify-content: center; }
.plan-current {
  display: block;
  text-align: center;
  padding: 10px;
  border: 1px dashed var(--border-hi);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: var(--text-sm);
}
.plan-fineprint { color: var(--text-dim); font-size: var(--text-xs); margin: 8px 0 0; text-align: center; }

.plans-loading { display: flex; justify-content: center; }

/* Same shape and material as .btn throughout the rest of the site (8px
   radius, --surface background, --border-hi border) rather than an
   unrelated fully-rounded pill - two buttons side by side, not a separate
   widget style. */
.plan-interval-toggle {
  display: flex;
  gap: 6px;
  max-width: 320px;
  margin: 0 auto var(--space-7);
}
.plan-interval-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  border: 1px solid var(--border-hi);
  background: var(--surface);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  font-weight: 500;
  line-height: 1.25;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background .18s ease, color .18s ease, border-color .18s ease, transform .1s ease;
}
.plan-interval-btn:hover:not(.is-active) { border-color: var(--accent); background: var(--surface-alt); color: var(--text-bright); }
.plan-interval-btn:active { transform: scale(0.98); }
.plan-interval-btn.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--primary-contrast);
  font-weight: 700;
}
.plan-interval-save { font-size: 11px; font-weight: 500; opacity: .7; }
.plan-interval-btn.is-active .plan-interval-save { opacity: .85; font-weight: 600; }

.plan-price { transition: opacity .15s ease, transform .15s ease; }
.plan-price.is-swapping { opacity: 0; transform: translateY(3px); }

.plan-note {
  max-width: 880px;
  margin: 0 auto var(--space-5);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  padding: var(--space-6);
}
.plan-note h2 { margin: 0 0 var(--space-2); font-size: var(--text-lg); }
.plan-note p { color: var(--text-muted); margin: 0 0 var(--space-3); }
.plan-note p:last-child { margin-bottom: 0; }

/* ------------------------------------------------------------- /chat --- */
/* A Discord-like 3-column layout: chat list, thread, profile. Full-bleed
 * (no .container) since a chat app wants the vertical space, not a
 * centered reading column. */
.chat-shell {
  display: flex;
  height: calc(100vh - 64px);
  border-top: 1px solid var(--border);
}
.chat-sidebar {
  width: 280px;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.chat-sidebar-head { padding: var(--space-4); border-bottom: 1px solid var(--border); }
.chat-list { flex: 1; overflow-y: auto; }
.chat-list-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: var(--space-3) var(--space-4);
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  position: relative;
}
.chat-list-item:hover { background: var(--surface-hi); }
.chat-list-item.is-active { background: var(--surface-hi); box-shadow: inset 3px 0 0 var(--accent); }
.chat-list-item img { width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0; }
.chat-list-item-main { flex: 1; min-width: 0; }
.chat-list-item-name { font-weight: 600; font-size: var(--text-sm); display: flex; align-items: center; gap: 6px; }
.chat-list-item-preview { color: var(--text-dim); font-size: var(--text-xs); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-list-item-remove {
  opacity: 0;
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 4px;
  flex-shrink: 0;
}
.chat-list-item:hover .chat-list-item-remove { opacity: 1; }
.chat-list-item-remove:hover { color: var(--danger, #e5484d); }
.chat-unread-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); flex-shrink: 0; }

.chat-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.chat-main-head { padding: var(--space-4); border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 10px; }
.chat-main-head img { width: 32px; height: 32px; border-radius: 50%; }
.chat-back-btn {
  display: none; /* shown only under the phone/tablet breakpoint below */
  background: none;
  border: none;
  color: var(--text);
  font-size: var(--text-lg);
  line-height: 1;
  cursor: pointer;
  padding: 4px 8px 4px 0;
  flex-shrink: 0;
}
.chat-messages { flex: 1; overflow-y: auto; padding: var(--space-4); display: flex; flex-direction: column; gap: 10px; }
.chat-bubble-row { display: flex; }
.chat-bubble-row.is-mine { justify-content: flex-end; }
.chat-bubble-row.is-system { justify-content: center; }
.chat-bubble {
  max-width: 65%;
  padding: 8px 12px;
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  white-space: pre-wrap;
  word-break: break-word;
  position: relative;
}
.chat-bubble.is-user { background: var(--surface-hi); border: 1px solid var(--border); }
.chat-bubble.is-operator { background: var(--accent); color: var(--primary-contrast); }
.chat-bubble.is-system { background: transparent; color: var(--text-dim); font-size: var(--text-xs); text-align: center; max-width: 80%; }
.chat-bubble.is-deleted { font-style: italic; opacity: 0.6; }
.chat-bubble-time { display: block; font-size: 10px; opacity: 0.7; margin-top: 3px; }
.chat-bubble-delete {
  position: absolute;
  top: -8px;
  right: -8px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-dim);
  cursor: pointer;
  font-size: 11px;
  line-height: 1;
  display: none;
  align-items: center;
  justify-content: center;
}
.chat-bubble.is-operator:hover .chat-bubble-delete { display: flex; }
.chat-bubble code { background: rgba(0, 0, 0, 0.2); border-radius: 4px; padding: 1px 5px; font-family: var(--font-mono); font-size: 0.9em; }
.chat-bubble pre { background: rgba(0, 0, 0, 0.2); border-radius: var(--radius); padding: 8px 10px; overflow-x: auto; margin: 4px 0; }
.chat-bubble pre code { background: none; padding: 0; }
.chat-mention { background: rgba(88, 101, 242, 0.3); color: inherit; border-radius: 3px; padding: 0 3px; font-weight: 600; }
.chat-spoiler { background: rgba(0, 0, 0, 0.7); color: transparent; border-radius: 3px; cursor: pointer; }
.chat-spoiler.is-revealed { background: none; color: inherit; cursor: text; }
.chat-input-row {
  padding: var(--space-4);
  padding-bottom: calc(var(--space-4) + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--border);
  display: flex;
  gap: 10px;
}
.chat-input-row textarea { flex: 1; resize: none; min-height: 2.6em; max-height: 12em; overflow-y: auto; }
.chat-mention-menu {
  position: absolute;
  left: var(--space-4);
  right: var(--space-4);
  bottom: 100%;
  margin-bottom: 6px;
  background: var(--surface-solid);
  border: 1px solid var(--border-hi);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  max-height: 220px;
  overflow-y: auto;
  z-index: 5;
}
.chat-mention-option { display: flex; align-items: center; gap: 8px; padding: 7px 10px; cursor: pointer; font-size: var(--text-sm); }
.chat-mention-option img { width: 22px; height: 22px; border-radius: 50%; }
.chat-mention-option:hover, .chat-mention-option.is-active { background: var(--surface-hi); }

.chat-profile { width: 280px; flex-shrink: 0; border-left: 1px solid var(--border); overflow-y: auto; padding: var(--space-4); }
.chat-profile-empty { display: flex; align-items: center; justify-content: center; color: var(--text-dim); text-align: center; padding: var(--space-6); }

@media (max-width: 900px) {
  .chat-profile { display: none; }
}
@media (max-width: 700px) {
  /* Below this there's no room for a list + thread side by side - one pane
     at a time, switched by the "is-thread-open" class chat-page.js toggles
     on select/back, same pattern as any mobile messaging app. */
  .chat-sidebar { width: 100%; border-right: none; }
  .chat-main { display: none; }
  .chat-shell.is-thread-open .chat-sidebar { display: none; }
  .chat-shell.is-thread-open .chat-main { display: flex; }
  .chat-back-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
    margin-left: calc(var(--space-2) * -1);
  }
  .chat-bubble { max-width: 85%; }
  /* No hover on touch - the "remove chat" button being hover-only made it
     unreachable on a phone/tablet, so it's just always visible below here. */
  .chat-list-item-remove { opacity: 1; }
}

/* window.confirm() replacement (/dashboard/assets/js/confirm-dialog.js) - .is-danger
 * themes the card red for a destructive action. */
.iridex-confirm.is-danger .acct-modal-card { border-color: var(--danger, #e5484d); }
.iridex-confirm.is-danger .acct-modal-body { color: var(--text); }

/* An open dropdown must paint above everything that comes after it on the
   page (the Save button, the unsaved-changes bar). The list is already
   opaque - what was showing through it was another element winning the
   stacking order: each settings group is its own stacking context (they
   animate in), so the list's own z-index only competes inside it. Raising
   the group that holds an open picker fixes it at the right level. */
.settings-group:has(.cs-trigger[aria-expanded="true"]),
.settings-group:has(.emoji-pop),
.card:has(.cs-trigger[aria-expanded="true"]),
.field:has(.cs-trigger[aria-expanded="true"]) {
  position: relative;
  z-index: 120;
}
.cs-list { z-index: 130; background-color: var(--surface-solid); }

/* Dropdown lists are attached to <body> and placed by customSelect.js, so they
   can't be clipped by a scrolling parent. This wins over the earlier
   absolute-position rule and the per-group stacking workaround. */
.cs-list.cs-floating {
  position: fixed;
  right: auto;
  z-index: 10000;
  background-color: var(--surface-solid);
}

/* Ticket type editor: plain sections with generous, even spacing. */
.tt-section { margin-top: 34px; }
.tt-section:first-child { margin-top: 0; }
.tt-heading {
  margin: 0 0 18px;
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
}
.tt-section .field { margin-bottom: 20px; }
.tt-section .field:last-child { margin-bottom: 0; }
.tt-section .field > label { display: block; margin-bottom: 9px; }
.tt-section .row { gap: 16px; align-items: flex-start; }
.tt-section .row .field { margin-bottom: 0; }
.tt-section .row + .field, .tt-section .row + .row { margin-top: 20px; }

/* Previews stay put while the fields beside them scroll, and can't be picked
   up or dragged. Sticky needs every ancestor to leave overflow alone, so the
   pane cards are pinned to overflow: visible. */
.pane, .pane .card, .pane .settings-group { overflow: visible; }
.preview-card, .preview-card * { -webkit-user-drag: none; user-drag: none; }
.preview-card { user-select: none; cursor: default; }
.preview-col, .wl-columns > div:last-child, .tt-preview-col { position: sticky; align-self: start; }
.tt-preview-col { top: calc(var(--space-6) + 68px); }
.tt-layout { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 28px; align-items: start; margin-top: 14px; }
@media (max-width: 940px) { .tt-preview-col { position: static; } }

/* Accent colour picker: swatch, hex readout and a "No color" toggle */
.opt-color { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.opt-color input[type="color"] { flex-shrink: 0; transition: opacity 0.16s var(--ease-out); }
.opt-color-hex { min-width: 64px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: var(--text-sm); color: var(--text-muted); letter-spacing: 0.02em; }
.opt-color.is-none .opt-color-hex { color: var(--text-muted); font-style: italic; }
.opt-color-none { display: inline-flex; align-items: center; gap: 7px; }
.opt-color-none svg { width: 14px; height: 14px; }
.opt-color-none.is-active { background: color-mix(in srgb, var(--accent) 16%, transparent); border-color: var(--accent); color: var(--text-bright); }
.opt-color-none.is-active:hover { background: color-mix(in srgb, var(--accent) 24%, transparent); }
input[type="color"].is-none {
  background-image: linear-gradient(135deg, transparent calc(50% - 1px), #e5484d calc(50% - 1px), #e5484d calc(50% + 1px), transparent calc(50% + 1px));
}
input[type="color"].is-none::-webkit-color-swatch { opacity: 0; }
input[type="color"].is-none::-moz-color-swatch { opacity: 0; }

/* Cards laid out side by side get their spacing from the grid gap. The
   stacked-card margin above pushed every right-hand card lower than its
   neighbour. */
:is(.pane-grid, .hero-panels, .wl-columns, .tt-layout, .op-section, .mod-grid) > .settings-group + .settings-group { margin-top: 0; }
/* Cards size to their own content. Stretching them to match the tallest card
   in the row only moved the empty space inside the shorter card. */

/* ================= MODULE PANE POLISH =================
   A pane used to be a bordered card holding more bordered cards, so every
   setting sat inside two frames and a lot of padding. The pane itself is now
   just a layout, and the setting groups are the only cards on screen. */
.pane.card {
  background: transparent;
  border: 0;
  padding: 0;
  overflow: visible;
}

/* A form field is read left to right, so an input stretched across a 1300px
   pane is harder to use, not easier. Everything stops at a comfortable
   measure; the ones that genuinely want the full width opt out with
   .is-wide. */
.settings-group .field > input:not([type="color"]),
.settings-group .field > select,
.settings-group .field > textarea,
.settings-group .field > .cs { max-width: 620px; }
.settings-group .field.is-wide > * { max-width: none; }

/* "Nothing here yet" reads as a state of the list, not as a stray sentence
   floating where the list should be. */
.empty-note {
  margin: 0 0 var(--space-4);
  padding: var(--space-5);
  border: 1px dashed var(--border-hi);
  border-radius: var(--radius);
  background: var(--surface-alt);
  color: var(--text-muted);
  font-size: var(--text-sm);
  text-align: center;
}

/* On/off was two nearly identical greys with only the knob colour differing.
   On is now filled. */
.toggle .slider { background: rgba(255, 255, 255, 0.04); }
.toggle input:checked + .slider { background: var(--accent); border-color: var(--accent); }
.toggle input:checked + .slider::before { background: var(--primary-contrast); }

/* ================= PREVIEW =================
   The preview is the thing people actually judge their message by, so it is
   framed like a Discord client: a channel bar above the message, and the
   message itself on Discord's own chat background. */
.preview-col > h3,
.tt-preview-col > h3,
.wl-columns > div:last-child > h3 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 !important;
  padding: 9px 14px;
  border: 1px solid #232428;
  border-bottom: 0;
  border-radius: 10px 10px 0 0;
  background: #1e1f22;
  color: #b5bac1 !important;
  font-size: var(--text-xs) !important;
}
.preview-col > h3::before,
.tt-preview-col > h3::before,
.wl-columns > div:last-child > h3::before {
  content: "";
  width: 7px; height: 7px; border-radius: 50%;
  background: #3ba55d;
  box-shadow: 0 0 0 3px rgba(59, 165, 93, 0.16);
}
.preview-card {
  border: 1px solid #232428;
  border-radius: 0 0 10px 10px;
  padding: var(--space-5) var(--space-4);
  box-shadow: 0 18px 40px -28px rgba(0, 0, 0, 0.9);
}
/* Discord's own message spacing: a 40px avatar column beside the text. */
.preview-message-header { align-items: center; gap: 8px; margin-bottom: 8px; }
.preview-bot-avatar { width: 28px; height: 28px; padding: 4px; }
.preview-bot-name { font-size: 1em; }

/* Thumbnail and banner pickers read as a pair: same height, the banner
   capped so it does not become a huge empty slab beside a small square. */
.img-picker-thumbnail { width: 112px; }
.img-picker-banner { max-width: 420px; }
.img-picker-banner .img-picker-box { height: 112px; }
.img-picker-thumbnail .img-picker-box span { font-size: 11px; }

/* ================= PANE LAYOUT + SECTION RAIL =================
   A module pane is a long form, so it gets its own contents list down the
   right-hand side: every section of this pane, click to jump, current one
   marked while scrolling, and a button to put it away (remembered). Built by
   /dashboard/assets/js/paneNav.js from the pane's own headings, so no pane needs markup
   for it. */
.pane.card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 208px;
  column-gap: var(--space-8);
  align-items: start;
}
.pane.card > *:not(.pane-nav) { grid-column: 1; min-width: 0; }
.pane-nav {
  grid-column: 2;
  /* span, not "1 / -1": the pane's rows are implicit, where -1 resolves back
     to the first line and leaves the rail stuck in row one, stretching it. */
  grid-row: 1 / span 50;
  position: sticky;
  top: calc(68px + var(--space-6));
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  padding: var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-alt);
}
.pane-nav-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 6px 8px;
  margin-bottom: 2px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  transition: color 0.16s var(--ease-out), background 0.16s var(--ease-out);
}
.pane-nav-toggle:hover { color: var(--text); background: var(--surface-hi); }
.pane-nav-toggle svg { width: 14px; height: 14px; flex-shrink: 0; }
.pane-nav-links { display: flex; flex-direction: column; gap: 1px; }
.pane-nav-links button {
  position: relative;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  text-decoration: none;
  font-size: var(--text-sm);
  line-height: 1.3;
  transition: color 0.16s var(--ease-out), background 0.16s var(--ease-out);
}
.pane-nav-links button:hover { color: var(--text-bright); background: var(--surface-hi); }
.pane-nav-links button.is-active { color: var(--text-bright); background: var(--surface-hi); }
.pane-nav-links button.is-active::before {
  content: "";
  position: absolute; left: 0; top: 6px; bottom: 6px;
  width: 2px; border-radius: 2px; background: var(--accent);
}
/* Hidden: the rail collapses to just its button, and the form takes the room. */
.pane.card:has(.pane-nav.is-hidden) { grid-template-columns: minmax(0, 1fr) 42px; column-gap: var(--space-5); }
.pane-nav.is-hidden { padding: var(--space-2); background: transparent; border-color: transparent; }
.pane-nav.is-hidden .pane-nav-links { display: none; }
.pane-nav.is-hidden .pane-nav-toggle { justify-content: center; padding: 8px; border: 1px solid var(--border); background: var(--surface-alt); }
.pane-nav.is-hidden .pane-nav-toggle span { display: none; }
@media (max-width: 1180px) {
  .pane.card, .pane.card:has(.pane-nav.is-hidden) { grid-template-columns: minmax(0, 1fr); }
  .pane-nav { display: none; }
}

/* ================= PANE SPACING =================
   One rhythm for every pane: the group header sits above a hairline, and
   every control below it is spaced the same whether it is a field, a toggle
   row or a picker. */
.settings-group { padding: var(--space-5) var(--space-6) var(--space-6); }
.pane .settings-group > h3 { font-size: var(--text-md); }
.settings-group-desc { margin: 6px 0 0; }
.settings-group > h3 + .settings-group-desc { margin-bottom: 0; }
.settings-group > h3,
.settings-group > .settings-group-desc {
  padding-bottom: 0;
}
.settings-group > h3 ~ *:not(h3):not(.settings-group-desc):first-of-type { margin-top: var(--space-5); }
.settings-group > .field { margin-bottom: var(--space-5); }
.settings-group > .row { margin-bottom: var(--space-5); }
.settings-group > .row:last-child { margin-bottom: 0; }
.field label { margin-bottom: 7px; font-size: var(--text-sm); color: var(--text-muted); }
.toggle-field { margin-bottom: var(--space-5); padding: var(--space-3) 0; }
/* Consecutive toggles read as one list rather than as separate rows with
   surprise gaps between them. */
.toggle-field + .toggle-field { margin-top: calc(var(--space-5) * -1 + 0px); }

/* Thumbnail and banner, side by side and level with each other. */
.media-row { align-items: flex-start; gap: var(--space-5); }
.media-row > .field { margin-bottom: 0; }
.media-thumb { width: 112px; flex-shrink: 0; }
.media-banner { flex: 1; min-width: 0; max-width: 420px; }
.media-row .img-picker { margin-top: 0; }
.field-grow { flex: 1; min-width: 0; margin-bottom: 0; }

/* Contact address in the footer brand block. */
.footer-email { display: inline-block; margin-top: var(--space-3); font-size: var(--text-sm); color: var(--text-muted); text-decoration: none; transition: color 0.16s var(--ease-out); }
.footer-email:hover { color: var(--text-bright, var(--text)); text-decoration: underline; }
.footer-email + .footer-status { margin-top: var(--space-2); }

/* Jumping to a section leaves it clear of the sticky page header. */
.settings-group { scroll-margin-top: 96px; }
.pane-nav-links button {
  text-align: left;
  border: 0;
  background: transparent;
  font: inherit;
  cursor: pointer;
  width: 100%;
}


/* =====================================================================
   IRIDEX POLISH LAYER
   Iridex's own palette - near-black ground, white accent, colour reserved
   for the few places that already earn it (Supporter, previews, status).
   What this layer adds is depth and rhythm, not hue: surfaces that catch
   light at their top edge, a glass header, heavier headings, and clear
   focus and hover states. A finishing pass over the existing rules, so
   every component keeps its structure.
   ===================================================================== */
:root {
  --edge: rgba(255, 255, 255, 0.09);
  --edge-hi: rgba(255, 255, 255, 0.2);
  --card-bg: #0c0c0f;

  --shadow-near: 0 1px 0 rgba(255, 255, 255, 0.045) inset;
  --shadow-drop: 0 30px 80px -40px rgba(0, 0, 0, 0.95);
  --shadow-bloom: 0 0 60px -24px rgba(255, 255, 255, 0.1);
}

/* ---- Ground: one soft light overhead, no colour cast ---------------- */
body {
  background:
    radial-gradient(95% 55% at 50% -12%, rgba(255, 255, 255, 0.045), transparent 62%),
    var(--bg);
  background-attachment: fixed;
}

/* ---- Type ---------------------------------------------------------- */
h1, .hero h1 { font-weight: 800; letter-spacing: -0.035em; }
h2, .section-title, .page-head h1 { font-weight: 800; letter-spacing: -0.03em; }
h3 { letter-spacing: -0.015em; }

/* ---- Surfaces ------------------------------------------------------ */
.card,
.feature-detail,
.step-card,
.plan-card,
.pt-card,
.link-card,
.discord-card,
.cta-card,
.settings-panel,
.plan-note,
.report-cta,
.hub-section,
.portal-card,
.stat-strip,
.app-download-card,
.lb-columns > div,
.op-section {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.025), rgba(255, 255, 255, 0)), var(--card-bg);
  border-color: var(--edge);
  box-shadow: var(--shadow-near), var(--shadow-drop);
  transition: border-color 0.25s var(--ease-out), box-shadow 0.25s var(--ease-out), transform 0.25s var(--ease-out);
}
.card:hover,
.feature-detail:hover,
.step-card:hover,
.link-card:hover,
.pt-card:hover,
.portal-card:hover,
.app-download-card:hover {
  border-color: var(--edge-hi);
  box-shadow: var(--shadow-near), var(--shadow-drop), var(--shadow-bloom);
}
/* The closing call to action and the community card carry the page, so they
   sit a step brighter than the cards around them. */
.cta-card, .discord-card { border-color: var(--edge-hi); }

/* ---- Buttons: Iridex's own light primary --------------------------- */
.btn-primary, .btn-dark {
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.55) inset, 0 12px 28px -16px rgba(0, 0, 0, 0.95);
}
.btn-primary:hover, .btn-dark:hover {
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.7) inset, 0 16px 34px -16px rgba(0, 0, 0, 1);
}
.btn-light, .btn-outline { background: rgba(255, 255, 255, 0.03); border-color: rgba(255, 255, 255, 0.12); }
.btn-light:hover, .btn-outline:hover {
  border-color: var(--edge-hi);
  background: rgba(255, 255, 255, 0.07);
  color: var(--text-bright);
}
.btn { letter-spacing: 0.01em; }

/* ---- Header -------------------------------------------------------- */
.site-header {
  background: color-mix(in srgb, var(--bg) 72%, transparent);
  backdrop-filter: saturate(150%) blur(16px);
  -webkit-backdrop-filter: saturate(150%) blur(16px);
}
.nav-links a:hover { color: var(--text-bright); }
.logo-badge { box-shadow: none; background: transparent; border: 0; border-radius: 0; width: auto; height: auto; }
.logo-badge img { width: 22px; height: 22px; }

/* ---- Small type ---------------------------------------------------- */
code {
  padding: 0.12em 0.4em;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.07);
  font-size: 0.92em;
}
pre code { padding: 0; border: 0; background: none; }

/* Contact address in the footer's Legal column: dim grey at rest with a
   faint halo, lighting up on hover - the one spot of glow in the footer, so
   the address reads as an invitation rather than another link in the list. */
.footer-email,
.footer-col a.footer-email {
  display: inline-block;
  margin-top: var(--space-3);
  color: #7c7c86;
  font-size: var(--text-sm);
  text-decoration: none;
  text-shadow: 0 0 14px rgba(255, 255, 255, 0.12);
  transition: color 0.22s var(--ease-out), text-shadow 0.22s var(--ease-out);
}
.footer-email:hover,
.footer-col a.footer-email:hover {
  color: var(--text-bright);
  text-shadow: 0 0 10px rgba(255, 255, 255, 0.45), 0 0 26px rgba(255, 255, 255, 0.22);
}
:root[data-theme="light"] .footer-email,
:root[data-theme="light"] .footer-col a.footer-email {
  color: #6b6b77;
  text-shadow: 0 0 14px rgba(15, 15, 25, 0.1);
}
:root[data-theme="light"] .footer-email:hover,
:root[data-theme="light"] .footer-col a.footer-email:hover {
  color: #15151c;
  text-shadow: 0 0 10px rgba(15, 15, 25, 0.28);
}

/* ---- Interaction --------------------------------------------------- */
/* Text fields get their own quieter ring from base.css's input:focus (a
   border colour + soft box-shadow) - this outline is only for things that
   don't already have one: links, buttons, checkboxes. Including inputs here
   stacked a second, harsher ring on top of the first on every click (not
   just keyboard focus - Chrome/Firefox both treat a text field's own click
   as :focus-visible), which is the stark white box a typed-in field showed. */
a:focus-visible, button:focus-visible, .btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 6px;
}
::selection { background: rgba(255, 255, 255, 0.22); color: var(--text-bright); }

/* ---- Scrollbar ----------------------------------------------------- */
* { scrollbar-color: rgba(255, 255, 255, 0.18) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.28); background-clip: content-box; }
::-webkit-scrollbar-track { background: transparent; }

/* ---- Light theme --------------------------------------------------- */
:root[data-theme="light"] {
  --card-bg: #ffffff;
  --edge: rgba(15, 15, 20, 0.1);
  --edge-hi: rgba(15, 15, 20, 0.2);
  --shadow-drop: 0 18px 44px -28px rgba(15, 15, 25, 0.35);
  --shadow-near: 0 1px 0 rgba(255, 255, 255, 0.9) inset;
  --shadow-bloom: 0 0 50px -26px rgba(15, 15, 25, 0.35);
}
:root[data-theme="light"] body {
  background: radial-gradient(95% 55% at 50% -12%, rgba(15, 15, 25, 0.05), transparent 62%), var(--bg);
}
:root[data-theme="light"] .site-header { background: color-mix(in srgb, #fff 78%, transparent); }
:root[data-theme="light"] ::selection { background: rgba(15, 15, 25, 0.16); }

@media (prefers-reduced-motion: reduce) {
  .card, .feature-detail, .step-card, .link-card, .pt-card, .portal-card { transition: none; }
}

/* ---- Footer -------------------------------------------------------- */
/* A quiet slab rather than a continuation of the page: its own dark ground,
   a lit top edge, and one rhythm for every column. */
.site-footer {
  position: relative;
  border-top: 1px solid var(--edge);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.02), rgba(255, 255, 255, 0)), #0a0a0d;
}
.site-footer::before {
  content: "";
  position: absolute;
  inset: -1px 0 auto 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.16), transparent);
}
.footer-grid { padding: var(--space-12) var(--space-6) var(--space-8); gap: var(--space-10); }
.footer-brand p { line-height: 1.6; }
.footer-brand-row strong { letter-spacing: 0.02em; }

.footer-col h4 { font-size: 0.68rem; letter-spacing: 0.16em; color: var(--text-faint); margin-bottom: var(--space-3); }
.footer-col a {
  position: relative;
  font-size: var(--text-sm);
  padding: 4px 0;
}
/* A hairline grows in under a link on hover - enough feedback without
   shifting the layout. */
.footer-col a::after {
  content: "";
  position: absolute;
  left: 0;
  right: 100%;
  bottom: 2px;
  height: 1px;
  background: currentColor;
  opacity: 0.45;
  transition: right 0.22s var(--ease-out);
}
.footer-col a:hover::after { right: 0; }
.footer-email::after { display: none; }

/* Status pill: reads as a live indicator, not a stray line of text. */
.footer-status {
  gap: 8px;
  margin-top: var(--space-4);
  padding: 5px 11px 5px 9px;
  border: 1px solid var(--edge);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.025);
  width: fit-content;
}
.footer-status:hover { border-color: var(--edge-hi); color: var(--text); }
.status-dot.online { box-shadow: 0 0 0 3px rgba(125, 211, 160, 0.16); }
.status-dot.offline { box-shadow: 0 0 0 3px rgba(229, 72, 77, 0.16); }

.footer-disclaimer { border-top-color: var(--edge); opacity: 0.85; }

@media (max-width: 860px) {
  .footer-grid { grid-template-columns: 1fr 1fr; gap: var(--space-8); }
  .footer-brand { grid-column: 1 / -1; }
}
@media (max-width: 520px) {
  .footer-grid { grid-template-columns: 1fr; }
}

:root[data-theme="light"] .site-footer {
  background: linear-gradient(180deg, rgba(15, 15, 25, 0.03), rgba(15, 15, 25, 0)), #f4f4f7;
}
:root[data-theme="light"] .site-footer::before { background: linear-gradient(90deg, transparent, rgba(15, 15, 25, 0.14), transparent); }

/* The giant brand wordmark bleeding off the bottom edge, same move as
   Discord's own footer - but sat directly on the footer's own background
   (no block/color of its own) so it reads as a continuation of the links
   section above rather than a new slab. Grayscale gradient-fill text, same
   technique as .hero h1 .muted, to match the site's black/white/gray theme
   instead of the brand's full iris spectrum. */
.footer-wordmark {
  display: flex;
  align-items: center;
  justify-content: center;
  height: clamp(160px, 22vw, 320px);
  overflow: hidden;
}
.footer-wordmark span {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(5rem, 16vw, 13rem);
  line-height: 1;
  letter-spacing: -0.03em;
  white-space: nowrap;
  color: #8a8a92;
}
:root[data-theme="light"] .footer-wordmark span {
  color: #8a8a92;
}

/* =====================================================================
   MODULE PANES
   A settings page is a form, and a form is read in one column at a time.
   These rules give every pane the same anatomy: a header that says what
   the module is, cards whose headings are separated from their controls,
   inputs that look like inputs, and a save bar that stays reachable.
   ===================================================================== */

/* ---- Pane header --------------------------------------------------- */
.pane-title-row {
  gap: 14px;
  padding-bottom: var(--space-5);
  margin-bottom: var(--space-6);
  border-bottom: 1px solid var(--edge);
}
.pane-title-row h2 { margin: 0; font-size: var(--text-2xl); letter-spacing: -0.02em; }
.pane-icon {
  width: 40px;
  height: 40px;
  border-radius: 11px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0.02));
  border-color: var(--edge);
}
.pane-icon svg { width: 20px; height: 20px; color: var(--text); }

/* ---- Section cards -------------------------------------------------- */
.settings-group { border-radius: 14px; }
/* The heading block sits above a hairline, so a card reads as "this is the
   subject" then "these are its controls" rather than one run of text. */
.settings-group > h3 {
  font-size: var(--text-md);
  color: var(--text-bright);
  letter-spacing: -0.01em;
}
.settings-group > h3 + .settings-group-desc,
.settings-group > .settings-group-desc {
  padding-bottom: var(--space-4);
  border-bottom: 1px solid var(--edge);
  margin-bottom: var(--space-4) !important;
  line-height: 1.55;
}
.settings-group > h3:only-child { margin-bottom: 0; }

/* ---- Controls ------------------------------------------------------- */
.pane input:not([type="checkbox"]):not([type="color"]),
.pane select,
.pane textarea,
.pane .cs-trigger {
  background: rgba(255, 255, 255, 0.025);
  border-color: var(--edge);
  border-radius: 10px;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.03) inset;
  transition: border-color 0.18s var(--ease-out), background 0.18s var(--ease-out);
}
.pane input:not([type="checkbox"]):not([type="color"]):hover,
.pane select:hover,
.pane textarea:hover,
.pane .cs-trigger:hover { border-color: var(--edge-hi); }
.pane textarea { line-height: 1.6; }
.pane .field label { color: var(--text-muted); font-weight: 500; }
.pane .hint { line-height: 1.5; }

/* A toggle is a row, so the whole row should respond to the pointer. */
.toggle-field {
  margin-inline: calc(var(--space-3) * -1);
  padding-inline: var(--space-3);
  border-radius: 10px;
  transition: background 0.16s var(--ease-out);
}

/* "Add another one" buttons read as an action on the list above them. */
.settings-group > .btn[id^="add"],
.settings-group .btn[id^="add"],
.settings-group .btn[id*="Add"] {
  border-style: dashed;
}

/* ---- Save bar ------------------------------------------------------- */
/* Plainly at the end of the pane. It was sticky for a while, which meant a
   floating slab followed you down the page and sat on top of the form. */
.pane-actions {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  margin-top: var(--space-8);
  padding-top: var(--space-5);
  border-top: 1px solid var(--edge);
}

/* ---- Section rail --------------------------------------------------- */
.pane-nav { padding: var(--space-4) var(--space-3); border-radius: 14px; }
.pane-nav-links button { font-size: var(--text-sm); line-height: 1.35; padding: 8px 10px; }

/* ---- Preview -------------------------------------------------------- */
.preview-col > h3, .tt-preview-col > h3, .wl-columns > div:last-child > h3 { letter-spacing: 0.08em; }

:root[data-theme="light"] .pane input:not([type="checkbox"]):not([type="color"]),
:root[data-theme="light"] .pane select,
:root[data-theme="light"] .pane textarea,
:root[data-theme="light"] .pane .cs-trigger { background: rgba(15, 15, 25, 0.02); }

/* =====================================================================
   SETTING ROWS
   A settings card is a list of decisions, so each one is a row: what it is
   on the left, the control on the right, a hairline between. It replaces
   the stacked label-over-input form, which read as one long column of
   boxes with no hierarchy and no way to scan.
   ===================================================================== */
@media (min-width: 720px) {
  .pane .settings-group > .field {
    display: grid;
    grid-template-columns: minmax(150px, 230px) minmax(0, 1fr);
    align-items: center;
    column-gap: var(--space-6);
    row-gap: 6px;
    margin-bottom: 0;
    padding: var(--space-4) 0;
    border-bottom: 1px solid var(--edge);
    min-height: 56px;
  }
  .pane .settings-group > .field > label { margin-bottom: 0; align-self: center; }
  .pane .settings-group > .field > .hint {
    grid-column: 1;
    grid-row: 2;
    margin: 0;
    align-self: start;
  }
  /* The control keeps the right-hand column whatever it is. */
  .pane .settings-group > .field > :not(label):not(.hint) { grid-column: 2; grid-row: 1 / span 2; }
  .pane .settings-group > .field[style] { max-width: none !important; width: auto !important; }
  .pane .settings-group > .field > input,
  .pane .settings-group > .field > select,
  .pane .settings-group > .field > .cs { max-width: 420px; width: 100%; }
  /* Numbers and times are short values; a 400px box for "5" reads as a
     mistake. */
  .pane .settings-group > .field > input[type="number"],
  .pane .settings-group > .field > input[type="time"] { max-width: 140px; }
  .pane .settings-group > .field > input[type="color"] { width: 56px; }

  /* Anything that needs the full width says so by carrying a textarea, an
     image picker or a list - those get the label above instead. */
  .pane .settings-group > .field:has(textarea),
  .pane .settings-group > .field:has(.img-picker),
  .pane .settings-group > .field:has(.stack),
  .pane .settings-group > .field.is-wide {
    grid-template-columns: minmax(0, 1fr);
    align-items: stretch;
  }
  .pane .settings-group > .field:has(textarea) > :not(label):not(.hint),
  .pane .settings-group > .field:has(.img-picker) > :not(label):not(.hint),
  .pane .settings-group > .field:has(.stack) > :not(label):not(.hint),
  .pane .settings-group > .field.is-wide > :not(label):not(.hint) { grid-column: 1; grid-row: auto; }
  .pane .settings-group > .field:has(textarea) > .hint,
  .pane .settings-group > .field:has(.img-picker) > .hint,
  .pane .settings-group > .field:has(.stack) > .hint { grid-column: 1; grid-row: auto; }
  .pane .settings-group > .field:has(textarea) > textarea { max-width: none; }

  /* Rows sit flush with the card's edges so the hairlines read as dividers
     of the card, not as boxes floating inside it. */
  .pane .settings-group > .field,
  .pane .settings-group > .toggle-field {
    margin-inline: calc(var(--space-6) * -1);
    padding-inline: var(--space-6);
    border-radius: 0;
  }
  .pane .settings-group > .field:last-child,
  .pane .settings-group > .toggle-field:last-child { border-bottom: 0; padding-bottom: 0; }
  .pane .settings-group > .toggle-field { padding-block: var(--space-4); border-bottom: 1px solid var(--edge); }
}

/* =====================================================================
   PANE HEADER + PROPORTIONS (v2)
   A module page opens with one header - icon, name, what it does - and the
   form gets the room. It used to say the module's name three times (a tour
   banner, the title, the first card) and then leave half the width empty
   beside a short preview.
   ===================================================================== */
.pane .tour-banner { display: none; }

.pane-title-row {
  align-items: flex-start;
  gap: var(--space-4);
  padding-bottom: var(--space-5);
  margin-bottom: var(--space-6);
  border-bottom: 1px solid var(--edge);
}
.pane-title-text { display: flex; flex-direction: column; gap: 8px; min-width: 0; padding-top: 2px; }
.pane-title { font-size: var(--text-2xl); line-height: 1.15; letter-spacing: -0.02em; }
.pane-subtitle {
  font-family: var(--font);
  font-size: var(--text-md);
  font-weight: 400;
  line-height: 1.5;
  color: var(--text-muted);
  max-width: 70ch;
}
.pane-icon { width: 42px; height: 42px; margin-top: 2px; }

/* The form is the page; the preview is a companion to it. Scoped to .pane
   and gated to the same breakpoint as the mobile collapse above - this used
   to be a bare, unconditional .pane-grid rule that came after that collapse
   rule in the cascade, so at equal specificity it always won: a module
   pane's 1.45fr/1fr split was overriding every other .pane-grid on the page
   (including the overview's Modules/Activity columns), on every screen size
   including mobile, squashing them into an unreadable two-column mess. */
@media (min-width: 941px) {
  .pane .pane-grid { grid-template-columns: minmax(0, 1.45fr) minmax(300px, 1fr); }
  .pane .pane-grid-wide { grid-template-columns: minmax(0, 1.6fr) minmax(300px, 1fr); }
}

/* Cards sit a step above the page instead of dissolving into it. */
.pane .settings-group {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.03), rgba(255, 255, 255, 0.008)), #101013;
  border-color: rgba(255, 255, 255, 0.11);
}
.pane .settings-group > h3 { font-size: var(--text-base); }

/* Label, then control - reading order, not opposite ends of the card. */
@media (min-width: 720px) {
  .pane .settings-group > .field { grid-template-columns: minmax(140px, 200px) minmax(0, 1fr); column-gap: var(--space-5); }
  .pane .settings-group > .field > input,
  .pane .settings-group > .field > select,
  .pane .settings-group > .field > .cs { max-width: 460px; }
}

:root[data-theme="light"] .pane .settings-group {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.9), rgba(255, 255, 255, 0.6)), #fff;
  border-color: rgba(15, 15, 25, 0.12);
}

/* =====================================================================
   PRODUCT SWITCH
   The Dashboard | Host switch. It exists only in the desktop app, where the
   preload script puts it in the title bar; the websites do not have it.
   Everything from here to the end of this file is copied into the Host site
   by scripts/sync-host.mjs (the app loads that site too), so keep it
   self-contained.
   ===================================================================== */
.app-switch {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--border-hi);
  border-radius: 999px;
  background: var(--surface);
  flex-shrink: 0;
}
.app-switch a {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--text-muted);
  text-decoration: none;
  padding: 5px 14px;
  border-radius: 999px;
  transition: color 0.2s var(--ease-out), background-color 0.2s var(--ease-out);
}
.app-switch a:hover { color: var(--text-bright); }
.app-switch a.is-active { background: var(--text-bright); color: var(--bg); }
.iridex-app-chrome .nav-static { display: none; }
@media (max-width: 640px) { .app-switch a { padding: 5px 10px; } }

/* =====================================================================
   DESKTOP APP CHROME
   The app window has no OS title bar (main.js hides it), so the strip
   below is the title bar: the mark on the left, the window's name in the
   middle, and empty space on the right where Windows paints its own
   minimise / maximise / close buttons. Discord's shape, a little thicker
   and in Iridex's own colours. The class is set by the app's preload
   script, so a browser never sees any of this.
   ===================================================================== */
.app-titlebar { display: none; }

.iridex-app-chrome .app-titlebar {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 200;
  height: 56px;
  display: flex;
  align-items: center;
  gap: var(--space-4);
  /* Room on the right for the window controls Windows draws over us. */
  padding: 0 158px 0 var(--space-5);
  /* Opaque, and one flat colour. --surface-hi is a translucent tint meant to
     sit on something, so on its own the page scrolled straight through the
     bar; layering it over --bg keeps the tint in both themes and gives the
     app a real colour to sample for the window buttons. */
  background: linear-gradient(0deg, var(--surface-hi), var(--surface-hi)), var(--bg);
  border-bottom: 1px solid var(--border-hi);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04), 0 14px 34px -26px #000;
  -webkit-app-region: drag;
  user-select: none;
}

/* The bar drags the window, so everything in it that can be clicked has to
   opt out of that, or the menus would never open. */
.iridex-app-chrome .app-titlebar > *:not(.app-titlebar-name) { -webkit-app-region: no-drag; }

/* The account menu sits against the window controls; the rest stays left. */
.iridex-app-chrome .app-titlebar #navUser { margin-left: auto; }

/* Centred on the window, not on the space left over after the padding --
   otherwise the strip reserved on the right would push the name off-centre. */
.iridex-app-chrome .app-titlebar-name {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--font-mono);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-bright);
  text-shadow: 0 0 18px rgba(255, 255, 255, 0.14);
  pointer-events: none;
}

/* The page starts below the bar, and the site header stops sliding under it. */
.iridex-app-chrome body { padding-top: 56px; }
.iridex-app-chrome .site-header { top: 56px; }
.iridex-app-chrome .site-header,
.iridex-app-chrome .site-header * { user-select: none; }

.iridex-app-chrome .app-titlebar > .brand-menu,
.iridex-app-chrome .app-titlebar > .nav-brand { order: 0; }
.iridex-app-chrome .app-titlebar > .app-switch { order: 1; }
.iridex-app-chrome .app-titlebar > #themeToggle { order: 2; }
.iridex-app-chrome .app-titlebar > #navUser { order: 3; }

/* Iridex Host frames server.html directly for its Modules tab's "Configure" (see server.html's
   inline script, which adds this class from ?embed=1). Strips it down to just the one settings
   pane - no header, no server-picker chrome, nothing that would try to navigate the frame itself. */
.iridex-embed .site-header,
.iridex-embed .site-footer,
.iridex-embed .skip-link,
.iridex-embed #backToServers,
.iridex-embed .settings-tabs,
.iridex-embed #serverOverview,
.iridex-embed #moduleGrid,
.iridex-embed #templatesView,
.iridex-embed #backToGrid,
.iridex-embed .page-loader-overlay {
  display: none !important;
}
.iridex-embed body { background: transparent; }
.iridex-embed .settings-shell { padding-top: var(--space-4); }

/* only the account settings dialog is a tall two-pane window; prompts (email, migration) fit their content */
.acct-modal-card[aria-label="Account settings"] { height: min(86vh, 760px); }
.acct-email-prompt-card { width: min(480px, 100%); }
@media (max-width: 640px) {
  .acct-modal-card { height: auto; max-height: 92vh; }
  .acct-modal-card[aria-label="Account settings"] { height: min(92vh, 760px); }
}
