:root {
  --bg: #0f1117;
  --panel: #171a23;
  --text: #e8eaf0;
  --muted: #9aa1b5;
  --accent: #5865f2;
  --border: #262a38;
  --ok: #3ba55d;
  --bad: #ed4245;
  --max: 1100px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  line-height: 1.6;
}

a { color: inherit; text-decoration: none; }
a:hover { color: var(--accent); }

.site-header {
  /* nav stays centered; the Dashboard button / user chip sits on the right */
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 24px;
  /* the whole width of the page, so the user chip and Log out have room on the right */
  max-width: none;
  margin: 0;
  padding: 16px 32px;
}
.site-header nav { grid-column: 2; }
.site-header > :last-child { grid-column: 3; justify-self: end; }
.site-header nav { display: flex; gap: 24px; flex-wrap: wrap; }
.site-header nav a { color: var(--muted); font-weight: 500; }
.site-header nav a:hover { color: var(--text); }

.btn {
  display: inline-block;
  padding: 10px 22px;
  border-radius: 6px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  font-size: 1rem;
}
.btn:hover { color: #fff; filter: brightness(1.1); }
.btn-outline { background: transparent; color: var(--text); }
.btn-outline:hover { color: var(--text); background: var(--panel); }

main { max-width: var(--max); margin: 0 auto; padding: 0 20px; }

.hero { text-align: center; padding: 96px 0 72px; }
.eyebrow { letter-spacing: .2em; color: var(--accent); font-weight: 700; margin: 0; }
.hero h1 { font-size: clamp(2.2rem, 6vw, 3.8rem); margin: 8px 0 16px; }
.lead { max-width: 640px; margin: 0 auto 32px; color: var(--muted); font-size: 1.15rem; }

.about, .stories { padding: 48px 0; border-top: 1px solid var(--border); }
.about h2, .stories h2 { margin-top: 0; letter-spacing: .08em; }

.stats { display: flex; gap: 48px; flex-wrap: wrap; margin-bottom: 32px; }
.stats h3 { margin: 0; color: var(--muted); font-size: .85rem; letter-spacing: .15em; }
.stat { margin: 0; font-size: 2.4rem; font-weight: 800; }

.features { display: grid; gap: 12px; }
details {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 18px;
}
summary { cursor: pointer; font-weight: 700; }
details p, details ul { color: var(--muted); }
details ul { padding-left: 20px; margin: 8px 0 0; }

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  max-width: 420px;
  margin: 24px 0;
}
.card img { width: 100%; display: block; }
.card h3, .card p { margin: 0; padding: 12px 18px 0; }
.card p { padding-bottom: 18px; color: var(--muted); }

.site-footer {
  border-top: 1px solid var(--border);
  margin-top: 48px;
  padding: 40px 20px;
  max-width: var(--max);
  margin-left: auto;
  margin-right: auto;
}
.site-footer .cols { display: flex; gap: 64px; flex-wrap: wrap; margin-bottom: 32px; }
.site-footer h4 { margin: 0 0 10px; }
.site-footer a:not(.btn) { display: block; color: var(--muted); padding: 2px 0; }

@media (max-width: 640px) {
  .site-header { grid-template-columns: 1fr; justify-items: start; }
  .site-header nav, .site-header > :last-child { grid-column: 1; justify-self: start; }
  .hero { padding: 56px 0 40px; }
}

/* Dashboard page */
.dash-hero { padding: 64px 0 40px; }
.dash-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 20px; }
.dash-card { margin: 0; max-width: none; padding-bottom: 18px; }
.dash-card h3 { padding-top: 18px; }
.dash-add p { padding-top: 12px; }

/* Logged-in user chip (replaces the Dashboard button) */
.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 4px 14px 4px 4px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--panel);
  color: var(--text);
  font-weight: 600;
}
.user-chip:hover { color: var(--text); border-color: var(--accent); }
.user-chip img { width: 32px; height: 32px; border-radius: 50%; display: block; }

/* Dashboard server grid */
.dash-main {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 80px);
  padding: 24px 20px 48px;
}
.server-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, 180px);
  justify-content: center;
  gap: 0.25in;
  width: 100%;
  max-width: var(--max);
}
.server-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 20px 14px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  text-align: center;
}
.server-icon { width: 80px; height: 80px; border-radius: 50%; object-fit: cover; display: block; }
.server-icon-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--border);
  color: var(--text);
  font-size: 2rem;
  font-weight: 700;
}
.server-name { font-weight: 600; word-break: break-word; }
.dash-empty { color: var(--muted); font-size: 1.1rem; text-align: center; }

/* Chip + log out button */
.user-area { display: flex; align-items: center; gap: 10px; }
.logout-btn { padding: 7px 16px; font-size: .95rem; white-space: nowrap; }
.user-chip span { white-space: nowrap; }
/* Signed-out: Dashboard button with "Remember me" tick box below it */
.login-area { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.remember {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: .8rem;
  cursor: pointer;
  user-select: none;
}
.remember input { accent-color: var(--accent); margin: 0; cursor: pointer; }
.remember:hover { color: var(--text); }

/* Servers with an authorizedBy value get an orange outline */
.server-card.authorized {
  border-color: #ff8a1f;
  box-shadow: 0 0 0 1px #ff8a1f; /* ring instead of a thicker border, so the layout doesn't shift */
}

/* Heading above the server grid */
.dash-content { display: flex; flex-direction: column; align-items: center; gap: 40px; width: 100%; }
.dash-title {
  margin: 0;
  max-width: 900px;
  text-align: center;
  font-size: clamp(2rem, 5vw, 3.25rem);
  line-height: 1.2;
}
.dash-title:empty { display: none; } /* signed out: the login prompt shows instead */

/* Heading + small "Refresh server list" text under it */
.dash-head { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.refresh-link {
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  font-size: .9rem;
  color: var(--muted);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.refresh-link:hover:not(:disabled) { color: var(--text); }
.refresh-link:disabled { cursor: default; opacity: .6; text-decoration: none; }
.refresh-link[hidden], .server-grid[hidden] { display: none; }

/* Premium page: "Current Plan" box */
.premium-main { display: flex; flex-direction: column; align-items: center; gap: 36px; padding: 42px 20px 64px; }
.plan-status { margin: 0; align-self: flex-start; font-size: 1.4rem; color: var(--text); text-align: center; width: 100%; }
.plan-status[hidden], .plan-box[hidden], .auth-section[hidden], .auth-msg[hidden] { display: none; }
#subscribe-box .plan-preview { margin-top: 4px; }
#subscribe-box .plan-btn-primary { font-size: .95rem; padding: 10px 12px; }
.sub-cycles[hidden] { display: none; }
.sub-cycles { margin: 14px 0 0; padding: 0; border: 0; display: grid; gap: 8px; }
.sub-cycles legend { margin: 0 auto 8px; padding: 0; text-align: center; width: 100%; }
.sub-cycle { display: grid; grid-template-columns: auto 1fr auto; grid-template-areas: "radio name save" "radio price save"; align-items: center; column-gap: 10px; padding: 9px 12px; border: 1px solid #3a4054; border-radius: 6px; background: var(--bg); cursor: pointer; }
.sub-cycle:hover { border-color: var(--accent); }
.sub-locked .sub-cycle, .sub-locked .plan-panel { opacity: .5; cursor: not-allowed; }
.sub-locked .sub-cycle:hover { border-color: #3a4054; }
.sub-cycle:has(input:checked) { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.sub-cycle:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.sub-cycle input { grid-area: radio; margin: 0; accent-color: var(--accent); }
.sub-cycle-name { grid-area: name; font-weight: 600; }
.sub-cycle-price { grid-area: price; color: var(--muted); font-size: .85rem; }
.sub-cycle-save { grid-area: save; padding: 2px 8px; border-radius: 999px; background: #15301f; color: #d7f5df; border: 1px solid var(--ok); font-size: .75rem; font-weight: 700; white-space: nowrap; }
/* plan box: 75% of its original size */
.plan-box {
  width: 100%;
  max-width: 420px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 21px 24px;
}
.plan-title {
  margin: 0 0 16px;
  padding-bottom: 6px;
  text-align: center;
  font-size: 1.6rem;
  font-weight: 400;
  border-bottom: 2px solid var(--border);
}
.plan-line { margin: 5px 0; font-size: 1rem; }
.plan-actions { display: flex; flex-direction: column; align-items: center; gap: 12px; margin-top: 21px; }
.plan-btn {
  box-sizing: border-box;
  width: 70%;
  min-width: 165px;
  padding: 8px 12px;
  text-align: center;
  background: var(--bg);
  color: var(--text);
  border: 1px solid #3a4054;
  border-radius: 4px;
  font: inherit;
  font-size: .8rem;
  cursor: pointer;
}
.plan-btn:hover:not(:disabled) { border-color: var(--accent); color: var(--text); }
/* greyed-out look when a button has the `disabled` attribute */
.plan-btn:disabled { opacity: .4; cursor: not-allowed; }
.plan-btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.plan-btn-primary:hover:not(:disabled) { filter: brightness(1.1); color: #fff; }
.plan-btn-danger { background: #3b1517; border-color: var(--bad); color: #ffd9d9; font-weight: 600; }
.plan-btn-danger:hover:not(:disabled) { border-color: var(--bad); background: #4a1a1d; color: #fff; }
/* confirmation line under the buttons: green = done, red = failed, grey = working / nothing changed */
.plan-msg[hidden], .plan-panel[hidden] { display: none; }
.plan-msg { margin: 16px 0 0; padding: 10px 14px; border-radius: 6px; text-align: center; font-size: .92rem; line-height: 1.45; border: 1px solid var(--border); color: var(--muted); }
.plan-msg-ok { color: #d7f5df; background: #15301f; border-color: var(--ok); }
.plan-msg-error { color: #ffd9d9; background: #3b1517; border-color: var(--bad); }
.plan-msg-info { color: var(--text); background: var(--bg); }
.plan-panel { margin-top: 16px; padding: 14px; border: 1px solid var(--border); border-radius: 6px; background: var(--bg); display: flex; flex-direction: column; align-items: center; gap: 10px; }
.plan-qty-label { font-size: .9rem; color: var(--muted); }
.plan-qty-row { display: flex; align-items: center; gap: 8px; }
.plan-qty { width: 76px; padding: 6px 8px; text-align: center; font: inherit; font-size: 1.1rem; color: var(--text); background: var(--panel); border: 1px solid #3a4054; border-radius: 4px; }
.plan-step { width: 34px; height: 34px; font-size: 1.2rem; line-height: 1; color: var(--text); background: var(--panel); border: 1px solid #3a4054; border-radius: 4px; cursor: pointer; }
.plan-step:hover { border-color: var(--accent); }
.plan-preview { margin: 0; text-align: center; font-size: .9rem; line-height: 1.45; color: var(--text); }
.plan-panel-actions { display: flex; flex-direction: column; align-items: center; gap: 8px; width: 100%; }

/* /premium: authorized servers under the plan box (cards reuse the /dash server-grid look) */
.auth-section { display: flex; flex-direction: column; align-items: center; gap: 22px; width: 100%; }
.auth-title { margin: 0; font-size: 1.6rem; font-weight: 400; text-align: center; }
.auth-msg { margin: -8px auto 0; max-width: 560px; padding: 10px 14px; color: #ffd9d9; background: #3b1517; border: 1px solid #ed4245; border-radius: 6px; text-align: center; }
button.server-card {
  font: inherit;
  color: var(--text);
  cursor: pointer;
  transition: opacity .12s ease, border-color .12s ease;
}
button.server-card:hover:not(:disabled) { border-color: var(--accent); }
button.server-card.authorized:hover:not(:disabled) { border-color: #ff8a1f; }
#auth-grid button.server-card:not(.authorized) { opacity: .5; } /* deauthorized: dimmed, click to authorize again */
button.server-card:disabled { cursor: progress; }

/* /dash cards are buttons that open /dash/home */
button.server-card.pick { font: inherit; color: var(--text); cursor: pointer; transition: border-color .12s ease; }
button.server-card.pick:hover:not(:disabled) { border-color: var(--accent); }
button.server-card.pick.authorized:hover:not(:disabled) { border-color: #ff8a1f; }

/* /dash/home: server menu on the left */
.server-home { display: flex; align-items: stretch; min-height: calc(100vh - 73px); }
.server-sidebar {
  flex: 0 0 240px;
  box-sizing: border-box;
  padding: 28px 16px;
  background: var(--panel);
  border-right: 1px solid var(--border);
  /* follows the user down the page */
  position: sticky;
  top: 0;
  align-self: flex-start;
  height: 100vh;
  overflow-y: auto;
}
.server-sidebar[hidden] { display: none; }
.sidebar-back { display: block; box-sizing: border-box; margin-bottom: 16px; padding: 9px 12px; text-align: center; text-decoration: none; font-weight: 600; font-size: .9rem; color: var(--text); background: var(--bg); border: 1px solid var(--border); border-radius: 6px; }
.sidebar-back:hover { border-color: var(--accent); }
.sidebar-server { display: flex; flex-direction: column; align-items: center; gap: 12px; padding-bottom: 22px; text-align: center; border-bottom: 1px solid var(--border); }
.sidebar-server .server-icon[hidden] { display: none; }
.sidebar-menu { list-style: none; margin: 14px 0 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.sidebar-home { padding-bottom: 12px; margin-bottom: 10px; border-bottom: 1px solid var(--border); }
.sidebar-item {
  display: block;
  width: 100%;
  padding: 10px 14px;
  text-align: left;
  background: none;
  border: 0;
  border-radius: 6px;
  color: var(--muted);
  font: inherit;
  font-weight: 500;
  cursor: pointer;
}
.sidebar-item:hover { background: var(--bg); color: var(--text); }
.sidebar-item.active { background: var(--bg); color: var(--text); box-shadow: inset 3px 0 0 var(--accent); }
.server-content { flex: 1; max-width: none; margin: 0; padding: 36px 40px; min-width: 0; } /* it is a <main>: no 1100px cap, so it uses all the space beside the sidebar */
/* Centre the page content on the screen, not on the space beside the 240px sidebar: the same space is left empty on the right */
@media (min-width: 1100px) { .server-content { padding-right: 280px; } }
.section-title { margin: 0; font-size: 1.8rem; font-weight: 400; }
.server-content .section-title { text-align: center; } /* every sidebar page */
@media (max-width: 720px) {
  .server-home { flex-direction: column; }
  .server-sidebar { position: static; height: auto; align-self: stretch; flex-basis: auto; border-right: 0; border-bottom: 1px solid var(--border); }
}

/* sidebar items are links to their pages */
a.sidebar-item { box-sizing: border-box; text-decoration: none; }
a.sidebar-item:hover { color: var(--text); }

/* /dash/modules: Apply button (swapped for "Loading" while saving) with the result under it */
.apply-area[hidden], .apply-loading[hidden], .apply-btn[hidden], #apply-btn[hidden] { display: none; }
.apply-area { margin: 20px auto 0; max-width: 460px; text-align: center; }
.apply-loading { display: inline-block; padding: 10px 22px; color: var(--muted); border: 1px solid transparent; }
.apply-status { margin: 10px 0 0; min-height: 1.4em; font-weight: 600; }
.apply-ok { color: var(--ok); }
.apply-error { color: var(--bad); }

/* /dash/modules: centered list of module check boxes */
.modules-list[hidden], .modules-msg[hidden] { display: none; }
.modules-list { list-style: none; margin: 28px auto 0; padding: 0; max-width: 460px; }
.modules-list li { border-bottom: 1px solid var(--border); }
.modules-list label { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 6px; font-size: 1.1rem; cursor: pointer; }
.modules-list input[type="checkbox"] {
  /* slider toggle: red X = off, green check = on (matches .wl-switch) */
  appearance: none; -webkit-appearance: none;
  position: relative; flex: none; width: 54px; height: 28px; margin: 0;
  border-radius: 14px; background: var(--bad); border: 0;
  cursor: pointer; transition: background .15s;
}
.modules-list input[type="checkbox"]::before {
  content: "\2715"; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px;
  border-radius: 50%; background: #fff; color: var(--bad);
  font-size: 13px; font-weight: 700; line-height: 22px; text-align: center;
  transition: transform .15s;
}
.modules-list input[type="checkbox"]:checked { background: var(--ok); }
.modules-list input[type="checkbox"]:checked::before { content: "\2713"; color: var(--ok); transform: translateX(26px); }
.modules-list input[type="checkbox"]:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.modules-list input[type="checkbox"]:disabled { opacity: .5; cursor: default; }
.modules-msg { margin: 28px 0 0; text-align: center; color: var(--muted); font-size: 1.1rem; }
.server-content:has(.modules-list) .section-title { text-align: center; }

/* /dash/logging: log channel per event (read-only for now) */
.logging-list[hidden] { display: none; }
.logging-list { display: flex; flex-wrap: wrap; justify-content: center; align-items: flex-start; gap: 48px; margin: 28px auto 0; }
.logging-list[hidden] { display: none; }
.log-section { flex: 1 1 400px; max-width: 460px; min-width: 0; }
.logging-list ul { list-style: none; margin: 0; padding: 0; }
.logging-list li { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 6px; border-bottom: 1px solid var(--border); font-size: 1.05rem; }
.log-value { color: var(--muted); font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .9rem; word-break: break-all; text-align: right; }
.log-value.none { font-family: inherit; font-style: italic; }
.log-heading { margin: 30px 0 4px; padding: 0 6px; font-size: 1.15rem; font-weight: 500; color: var(--text); }
.server-content:has(.logging-list) .section-title { text-align: center; }

/* /dash/home: overview list (values in normal text) */
.home-value { color: var(--text); text-align: right; }
.home-value a { color: var(--accent); }
.home-value a:hover { text-decoration: underline; }
.home-value.none { color: var(--muted); font-style: italic; }
/* Premium Activated: bright green when on, bright red (both texts linking to /premium) when off */
li.home-good > span:first-child, .home-value.home-good { color: #23d160; font-weight: 600; }
li.home-bad > a, .home-value.home-bad a { color: #ff3b3b; font-weight: 600; }
li.home-bad > a:hover, .home-value.home-bad a:hover { text-decoration: underline; }
.server-content:has(#home-list) .section-title, .server-content:has(#settings-list) .section-title { text-align: center; }
#settings-list li { align-items: flex-start; }
#settings-list .home-value { word-break: break-word; }

/* /dash/welcome-leave: embeds with an Enabled/Disabled label and a link to edit them */
.wl-embed-info { display: flex; align-items: center; gap: 14px; }
.wl-state { color: var(--muted); font-size: .9rem; }
.wl-state.on { color: #3ba55d; }
.wl-link { font-size: .9rem; }

/* /dash/logging: the two settings lists */
.log-section-title { margin: 0 0 6px; padding: 0 6px 8px; font-size: 1.4rem; font-weight: 500; border-bottom: 2px solid var(--border); }

/* /leaderboard/<server id>: public XP leaderboard (own dark palette, no site header) */
.leaderboard-page { --lb-bg: #212425; --lb-row: #1b1d1e; --lb-line: #7d776b; --lb-muted: #a39b87; background: var(--lb-bg); color: #e6e6e6; font-family: Roboto, system-ui, -apple-system, "Segoe UI", sans-serif; }
.lb-header { display: flex; align-items: center; justify-content: center; gap: 26px; padding: 14px 20px 34px; }
.lb-icon { width: 100px; height: 100px; border-radius: 50%; object-fit: cover; }
.lb-icon[hidden] { display: none; }
.lb-title { margin: 0; font-size: 2.2rem; font-weight: 400; }
.lb-main { max-width: 810px; margin: 0 auto; padding: 0 12px 60px; }
.lb-msg { text-align: center; color: var(--lb-muted); font-size: 1.1rem; margin: 40px 0; }
.lb-msg[hidden], .lb-list[hidden] { display: none; }
.lb-list { list-style: none; margin: 0; padding: 0; background: var(--lb-row); border-radius: 14px; overflow: hidden; }
.lb-row { display: flex; align-items: center; height: 86px; border-bottom: 2px solid var(--lb-line); }
.lb-row.lb-me { box-shadow: inset 0 0 0 2px var(--ok); border-radius: 6px; } /* the logged-in user's own entry */
.lb-rank { width: 100px; text-align: center; font-size: 1.25rem; }
.lb-avatar { width: 64px; height: 64px; border-radius: 50%; object-fit: cover; background: #2b2e30; flex: none; }
.lb-name { flex: 1; min-width: 0; margin-left: 20px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-stat { display: flex; flex-direction: column; align-items: center; width: 86px; line-height: 1.3; }
.lb-label { color: var(--lb-muted); font-size: .85rem; text-transform: uppercase; }
.lb-level { --progress: 0%; flex: none; width: 62px; height: 62px; margin: 0 18px 0 8px; border-radius: 50%; display: grid; place-items: center; background: conic-gradient(#7d8dff var(--progress), #2a2d2f 0); }
.lb-level-inner { width: 56px; height: 56px; border-radius: 50%; background: #202223; display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.1; }
.lb-level-inner .lb-label { font-size: .7rem; }
.lb-level-inner strong { font-size: .95rem; }
.lb-footer { display: flex; align-items: center; justify-content: center; height: 60px; font-weight: 700; }
.lb-footer.retry { cursor: pointer; color: var(--lb-muted); }
.lb-list.done .lb-row:last-child { border-bottom: 0; }
@media (max-width: 700px) {
  .lb-title { font-size: 1.5rem; }
  .lb-icon { width: 64px; height: 64px; }
  .lb-rank { width: 44px; font-size: 1rem; }
  .lb-avatar { width: 44px; height: 44px; }
  .lb-name { margin-left: 10px; }
  .lb-stat:not(.lb-stat-total) { display: none; } /* keep Total XP only */
  .lb-stat { width: 70px; }
  .lb-level { margin-right: 10px; }
}

/* /dash/welcome-leave: drop downs and number boxes in the settings list */
.wl-input { min-width: 190px; max-width: 240px; padding: 7px 10px; font: inherit; font-size: .95rem; color: var(--text); background: var(--bg); border: 1px solid var(--border); border-radius: 6px; }
.wl-input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.wl-number { width: 120px; min-width: 0; }
.server-content:has(#wl-list) .section-title { text-align: center; }
#wl-list { display: block; max-width: 580px; }
#wl-list[hidden] { display: none; }

/* /dash/welcome-leave: embed on/off slider (red X = disabled, green check = enabled) */
.wl-switch { position: relative; display: inline-block; width: 54px; height: 28px; flex: none; cursor: pointer; }
.wl-switch input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.wl-slider { position: absolute; inset: 0; border-radius: 14px; background: var(--bad); transition: background .15s; }
.wl-slider::before { content: "\2715"; position: absolute; left: 3px; top: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; color: var(--bad); font-size: 13px; font-weight: 700; line-height: 22px; text-align: center; transition: transform .15s; }
.wl-switch input:checked + .wl-slider { background: var(--ok); }
.wl-switch input:checked + .wl-slider::before { content: "\2713"; color: var(--ok); transform: translateX(26px); }
.wl-switch input:focus-visible + .wl-slider { outline: 2px solid var(--accent); outline-offset: 2px; }
.wl-edited { color: var(--muted); font-size: .85rem; font-style: italic; }
.wl-edited[hidden] { display: none; }
.wl-add { display: inline-block; margin: 12px 0 0 6px; padding: 7px 16px; font-size: .95rem; }

/* Logging: Ping Roles as inline pills (name and a red x; the x removes the role until Apply) and the add drop down */
.logging-list ul.ping-list { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px 6px 0; }
.logging-list ul.ping-list li { display: inline-flex; align-items: center; justify-content: flex-start; gap: 6px; padding: 4px 6px 4px 12px; font-size: .95rem; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; }
.logging-list ul.ping-list li.ping-none { padding: 4px 0; background: none; border: 0; }
.ping-remove { flex: none; width: 22px; height: 22px; padding: 0; font-size: .85rem; line-height: 1; color: #ed4245; background: transparent; border: 0; border-radius: 50%; cursor: pointer; }
.ping-remove:hover, .ping-remove:focus-visible { background: rgba(237, 66, 69, .18); outline: none; }
.ping-add { margin: 14px 6px 0; }
.ping-add:disabled { opacity: .5; }

/* Sidebar item that needs a premium (authorized) server: orange outline and an orange "Premium" on the right */
a.sidebar-item.sidebar-premium { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 9px 13px; border: 1px solid #ff8a1f; }
.sidebar-premium-tag { color: #ff8a1f; font-size: .78rem; font-weight: 600; letter-spacing: .03em; }

/* /dash/settings: the Punishments box (controls) with the rest of the data listed under it */
#settings-list { flex-direction: column; align-items: center; gap: 36px; }
#settings-list .log-section { flex: none; width: min(560px, 100%); max-width: 100%; }
#settings-list .settings-rest { width: min(560px, 100%); }
.wl-text { width: 260px; max-width: 100%; }
#settings-list .log-section li { align-items: center; }

/* /dash/settings: the note above the Punishments box */
.settings-note { width: min(560px, 100%); box-sizing: border-box; padding: 14px 18px; background: var(--bg-elev, #1a1d24); border: 1px solid var(--border); border-left: 3px solid var(--accent); border-radius: 6px; font-size: .95rem; line-height: 1.5; color: var(--muted); }
.settings-note p { margin: 0 0 4px; }
.settings-note p:last-child { margin-bottom: 0; }
.settings-note .settings-note-title { margin-bottom: 8px; color: var(--text); font-weight: 600; }
.settings-note code { color: var(--text); font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; background: var(--bg); padding: 1px 5px; border-radius: 4px; }

/* Aliases: tables of 10 rows, at most three side by side, continuing down the page */
.aliases-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 24px; align-items: start; }
.aliases-table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.aliases-table th, .aliases-table td { padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--border); overflow-wrap: anywhere; }
.aliases-table th { font-weight: 600; border-bottom-width: 2px; }
.aliases-table th:last-child, .aliases-table td:last-child { width: 90px; text-align: center; }
.aliases-table th { white-space: nowrap; overflow-wrap: normal; }
.alias-yes { color: #43b581; font-weight: 700; }
.alias-no { color: #f04747; font-weight: 700; }

.aliases-table td { vertical-align: middle; }
.aliases-table td .alias-input { width: 100%; box-sizing: border-box; }
.aliases-table td.alias-forced { text-align: center; }
.aliases-table td.alias-forced .wl-switch { vertical-align: middle; }
.aliases-table tr.alias-invalid td { background: rgba(240, 71, 71, .18); }
.aliases-table tr.alias-invalid .alias-input { border-color: #f04747; }
.alias-add-area { margin-top: 20px; text-align: center; }
.aliases-table th, .aliases-table td { padding-left: 4px; padding-right: 4px; }
.aliases-table td .alias-input { min-width: 0; padding: 6px 8px; }

/* Aliases: text boxes 50% longer (tables 430px wide), at most three tables per row (fewer when the page is narrower), a single table is centered */
.aliases-grid { grid-template-columns: repeat(auto-fit, 470px); width: 100%; max-width: 1458px; margin: 0 auto; justify-content: center; }
.aliases-grid.aliases-single { grid-template-columns: 470px; }
.aliases-table td .alias-input { font-size: .95rem; padding: 7px 10px; max-width: none; }
.alias-add-area { text-align: center; }
@media (max-width: 520px) { .aliases-grid, .aliases-grid.aliases-single { grid-template-columns: minmax(0, 1fr); } }
.aliases-table th:first-child, .aliases-table td:first-child { width: 40px; text-align: center; }
.alias-del { width: 28px; height: 28px; padding: 0; border: 1px solid var(--border); border-radius: 6px; background: transparent; color: #f04747; font-size: 15px; font-weight: 700; line-height: 1; cursor: pointer; }
.alias-del:hover { background: rgba(240, 71, 71, .18); border-color: #f04747; }
.alias-undo { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); z-index: 50; display: flex; align-items: center; gap: 16px; padding: 10px 14px 10px 18px; background: var(--bg-elev, #1a1d24); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 6px 24px rgba(0, 0, 0, .5); }
.alias-undo[hidden] { display: none; }
.wl-embed-info .alias-del { flex: none; }
#wl-list li[hidden] { display: none; }
.alias-add-area { margin: 0 0 20px; }

/* Custom commands: one table per 15 commands, as wide as the page allows. The page keeps the same margin on both sides of the screen
   (the sidebar plus a gap on the left, the same width on the right), so the content is centered on the screen */
.commands-grid { margin-top: 28px !important; display: grid; grid-template-columns: minmax(0, 1fr); gap: 24px; width: 100%; }
.commands-wrap { min-width: 0; overflow-x: clip; }
.commands-table { table-layout: auto; width: 100%; }
.commands-table th, .commands-table td { text-align: left; vertical-align: top; width: 1%; white-space: nowrap; }
.commands-table th.cc-response, .commands-table td.cc-response { width: 100%; white-space: normal; }
.commands-table th:first-child, .commands-table td:first-child, .commands-table th:last-child, .commands-table td:last-child { text-align: left; }
@media (min-width: 1100px) { .server-content:has(.commands-grid) { padding-left: 100px; padding-right: 340px; } }
.commands-table .cc-perm { min-width: 96px; width: auto; max-width: none; padding: 5px 8px; }
.commands-table td.cc-nowrap { white-space: nowrap; }
.commands-table th:nth-last-child(2), .commands-table td:nth-last-child(2) { padding-left: 36px; } /* DM Response */
.commands-table th:last-child, .commands-table td:last-child { padding-left: 28px; }
.cc-command { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.cc-toggle { flex: none; padding: 4px 10px; font-size: .8rem; white-space: nowrap; }
.cc-toggle { width: 140px; text-align: center; }
.cc-response-box { display: block; width: 100%; min-width: 0; max-width: none; box-sizing: border-box; resize: none; overflow: hidden; line-height: 1.4; font-family: inherit; }
.commands-table td { padding-top: 8px; padding-bottom: 8px; }
.commands-table tr[hidden] { display: none; }
.commands-table .cc-del-cell { padding-right: 8px; }

.commands-table tr.alias-invalid td { background: rgba(240, 71, 71, .18); }
.commands-table tr.alias-invalid .wl-input { border-color: #f04747; }

/* the column names stay at the top of the window while the commands scroll */
.commands-table th { position: sticky; top: 0; z-index: 5; background: var(--bg); }

/* Custom Commands: requires / musthave / deny role lists under each command, the Add role drop down at the right end of the list */
.commands-table tr.cc-roles-row[hidden] { display: none; }
.commands-table .cc-roles-row td { padding-top: 0; padding-bottom: 10px; white-space: normal; width: auto; }
.commands-table .cc-roles-row td:first-child { padding: 0; }
.cc-role-line { display: flex; align-items: flex-start; gap: 12px; margin-top: 6px; }
.cc-role-title { flex: none; width: 190px; padding-top: 7px; color: var(--muted); font-size: .9rem; }
ul.cc-role-list { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0; padding: 0; list-style: none; }
ul.cc-role-list li { display: inline-flex; align-items: center; gap: 6px; padding: 4px 6px 4px 12px; font-size: .95rem; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; }
ul.cc-role-list li.cc-role-picker { padding: 0; background: none; border: 0; }
.cc-role-add { min-width: 130px; width: auto; padding: 5px 8px; }
.cc-role-add:disabled { opacity: .5; }

.cc-response-box[readonly] { opacity: .7; cursor: not-allowed; }

.cc-links { display: flex; flex-wrap: wrap; gap: 4px 14px; padding: 4px 2px 0; font-size: .85rem; }
.cc-links[hidden] { display: none; }
.cc-links a { color: var(--accent); text-decoration: none; }
.cc-links a:hover { text-decoration: underline; }

.cc-toggle-cell { white-space: nowrap; }
.cc-toggle-cell .cc-toggle + .cc-toggle { margin-left: 8px; }

.cc-cooldown { min-width: 0; width: 84px; padding: 5px 8px; }

/* Custom Commands: the note box to the left of the heading and the Apply / Add / Reset buttons (they stay centered); the table starts under whichever is taller.
   On screens under 1700px the note goes above the heading instead. */
.cc-head { display: grid; grid-template-columns: 1fr auto 1fr; column-gap: 24px; align-items: start; }
.cc-head .cc-note { grid-column: 1; grid-row: 1; justify-self: start; width: min(440px, 100%); }
.cc-head .cc-center { grid-column: 2; grid-row: 1; }
@media (max-width: 1700px) { .cc-head { display: block; } .cc-head .cc-note { margin: 0 auto 20px; } }
@media (max-width: 1400px) { .commands-wrap { overflow-x: auto; } } /* narrow screens: scroll the table sideways (the sticky headings only work on wide screens) */

.commands-table .cc-target-cell { vertical-align: top; padding-top: 6px; }
.cc-target { display: inline-flex; align-items: center; gap: 24px; font-size: .95rem; cursor: pointer; }

/* Channel Moderation: one titled list per data object */
.cm-sections { display: flex; flex-direction: column; gap: 28px; max-width: 1100px; margin: 8px auto 0; }
.cm-title { margin: 0 0 10px; text-align: left; }
.cm-scroll { overflow-x: auto; }
.cm-table { width: 100%; table-layout: auto; }
.cm-table th, .cm-table td { text-align: left; vertical-align: top; width: auto; overflow-wrap: anywhere; }
.cm-table th:first-child, .cm-table td:first-child { width: auto; }
.cm-table th:last-child, .cm-table td:last-child { width: auto; text-align: left; }
.cm-table th:first-child, .cm-table td:first-child { text-align: left; }
.cm-sections { margin-top: 28px; }
.cm-table th, .cm-table td { padding-left: 12px; padding-right: 12px; }

/* Channel Moderation sub pages in the left menu */
.sidebar-sub-li { margin-left: 16px; }
.sidebar-sub-li .sidebar-item { font-size: .92rem; }

/* Channel Moderation: the ignored channels lists look like the Logging ones */
.cm-table ul.ping-list { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; padding: 0 0 0 0; list-style: none; }
.cm-table ul.ping-list li { display: inline-flex; align-items: center; justify-content: flex-start; gap: 6px; padding: 4px 6px 4px 12px; font-size: .95rem; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; }
.cm-table ul.ping-list li.ping-none { padding: 4px 0; background: none; border: 0; }
.cm-table .ping-add { margin: 10px 0 0; }

.cm-addrow { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
.cm-addrow .wl-input { min-width: 190px; }
.cm-add { padding: 6px 14px; white-space: nowrap; }

.slow-table .slow-time { width: 124px; min-width: 0; box-sizing: border-box; }
.slow-table tr.alias-invalid td { background: rgba(240, 71, 71, .18); }
.slow-table tr.alias-invalid .wl-input { border-color: #f04747; }
.cm-empty { text-align: center; }
.sticky-table .sticky-msg { width: 360px; max-width: 100%; box-sizing: border-box; resize: vertical; }
.sticky-edited { color: var(--muted, #b9bbbe); font-style: italic; }
.sticky-table td a { white-space: nowrap; }
.stat-table .stat-msg { width: 300px; max-width: 100%; box-sizing: border-box; }
.settings-note a { color: #8ea1ff; text-decoration: underline; }
.auto-table .auto-word { width: 220px; max-width: 100%; box-sizing: border-box; }
.auto-table .sticky-msg { width: 320px; }

/* Tickets pages (read only) */
.tk-table .tk-mail { min-width: 220px; max-width: 420px; max-height: 8em; overflow: auto; white-space: pre-wrap; }
.tk-table .tk-text { width: 420px; max-width: 100%; box-sizing: border-box; resize: vertical; }
.tk-table ul.ping-list li { margin-bottom: 4px; }
.tk-table .tk-add { margin-top: 6px; }
.tk-table button:disabled, .tk-table input:disabled { cursor: default; }
.tk-table .tk-add:disabled { opacity: .6; }
.tk-switch, .tk-switch input { cursor: default; }
.tk-table td:nth-child(-n+4) { white-space: nowrap; }
.tk-table td a { color: #8ea1ff; text-decoration: underline; }
.tk-table ul.ping-list li { padding: 4px 12px; }
.tk-message { display: flex; align-items: flex-start; gap: 12px; }
.tk-message .cc-toggle { flex: none; }
.tk-age { width: 110px; box-sizing: border-box; }

/* rows marked invalid on Apply in the settings lists */
.logging-list li.alias-invalid { background: rgba(240, 71, 71, .18); }
.commands-table .cc-target-cell, .cc-target { white-space: nowrap; }

/* Home page: popular servers showcase (filled from /api/top-servers) */
.top-servers[hidden] { display: none; }
.top-servers { padding: 48px 0; border-top: 1px solid var(--border); }
.top-servers h2 { margin: 0 0 24px; letter-spacing: .08em; text-align: center; }
.ts-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; }
.ts-card {
  position: relative; display: flex; flex-direction: column; min-width: 0;
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px; overflow: hidden;
  color: var(--text); transition: transform .15s, border-color .15s, box-shadow .15s;
}
a.ts-card:hover { color: var(--text); transform: translateY(-3px); border-color: var(--accent); box-shadow: 0 10px 28px rgba(0, 0, 0, .35); }
a.ts-card:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.ts-banner {
  height: 110px; background: linear-gradient(135deg, var(--accent), #3c2f8f) center / cover no-repeat;
}
.ts-icon {
  position: absolute; top: 74px; left: 18px; width: 72px; height: 72px; border-radius: 22px;
  border: 5px solid var(--panel); background: var(--panel); object-fit: cover;
}
.ts-initials { display: grid; place-items: center; background: var(--border); color: var(--text); font-weight: 700; font-size: 1.1rem; }
.ts-body { display: flex; flex-direction: column; gap: 2px; padding: 44px 18px 18px; flex: 1; }
.ts-body > :has(+ .ts-join) { margin-bottom: 14px; } /* gap above the button; margin-top: auto lines buttons up across a row */
.ts-name { margin: 0; font-size: 1.1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ts-members { margin: 0; color: var(--muted); font-size: .9rem; }
.ts-message { margin: 8px 0 0; color: var(--text); opacity: .85; font-size: .92rem; line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.ts-join {
  align-self: flex-start; margin-top: auto; padding: 6px 14px; border-radius: 6px;
  background: var(--accent); color: #fff; font-weight: 600; font-size: .9rem;
}
.ts-skeleton .ts-banner, .ts-skeleton .ts-icon, .ts-line { background: var(--border); animation: ts-pulse 1.4s ease-in-out infinite; }
.ts-line { display: block; height: 14px; width: 70%; border-radius: 4px; margin-top: 6px; }
.ts-line.short { width: 40%; }
@keyframes ts-pulse { 50% { opacity: .5; } }
@media (max-width: 860px) { .ts-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 540px) { .ts-grid { grid-template-columns: 1fr; } }
@media (prefers-reduced-motion: reduce) { .ts-card, .ts-skeleton * { transition: none; animation: none; } }

/* /dash/responses */
.responses-list[hidden] { display: none; }
.responses-list { width: 100%; max-width: 1100px; margin: 24px auto 0; }
.responses-table .cc-del-cell { width: 1%; padding-right: 8px; }
.responses-table .resp-name-cell { width: 170px; }
.responses-table .resp-name { width: 100%; box-sizing: border-box; }
/* the Edit Embed button is exactly as tall as the Name box */
.responses-table .resp-name, .responses-table .cc-toggle-cell .cc-toggle { height: 40px; box-sizing: border-box; }
.responses-table .cc-toggle-cell .cc-toggle { display: inline-flex; align-items: center; justify-content: center; padding-top: 0; padding-bottom: 0; }
.responses-table .resp-text[readonly] { cursor: default; }
.responses-table .resp-text-cell { min-width: 260px; }
.responses-table .cc-toggle-cell { width: 1%; }
.responses-table .resp-link { font-size: .85rem; word-break: break-all; }
@media (max-width: 640px) {
  /* each response becomes a small card: delete + name, then the text, then the buttons */
  .responses-table thead { display: none; }
  .responses-table tbody tr { display: grid; grid-template-columns: auto 1fr; gap: 8px; padding: 12px 0; border-bottom: 1px solid var(--border); }
  .responses-table tbody td { display: block; width: auto !important; min-width: 0 !important; padding: 0; border: 0; }
  .responses-table tbody td.resp-text-cell, .responses-table tbody td.cc-toggle-cell, .responses-table tbody td.cm-empty { grid-column: 1 / -1; }
}

/* /dash/custom-roles (read only) */
.roles-list[hidden] { display: none; }
.roles-list { width: 100%; max-width: 1200px; margin: 24px auto 0; }
.roles-table th, .roles-table td { vertical-align: middle; padding-left: 5px; padding-right: 5px; overflow-wrap: normal; word-break: normal; hyphens: none; }
.roles-table .cr-role { white-space: nowrap; }
.roles-table th { white-space: normal; line-height: 1.25; }
.roles-table td { font-size: .95rem; }
.cr-pills { display: flex; flex-wrap: wrap; gap: 6px; }
.cr-pill { padding: 2px 10px; border-radius: 999px; background: var(--border); font-size: .85rem; white-space: nowrap; }
.cr-role { font-weight: 600; }
.cr-pills .cr-role { padding: 2px 10px; border-radius: 999px; background: var(--border); font-size: .85rem; white-space: nowrap; }
.cr-deleted { color: var(--bad); font-style: italic; }
.cr-none { color: var(--muted); }
@media (max-width: 640px) {
  /* each custom role becomes a card: "Label   value" lines */
  .roles-table thead { display: none; }
  .roles-table tbody tr { display: block; padding: 12px 0; border-bottom: 1px solid var(--border); }
  .roles-table tbody td { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 4px 0; border: 0; }
  .roles-table tbody td::before { content: attr(data-label); color: var(--muted); font-size: .85rem; flex: none; }
  .roles-table tbody td .cr-pills { justify-content: flex-end; }
}

/* Auto Respond: saved response drop down next to Create / Edit Embed */
.auto-table .auto-response { min-width: 170px; max-width: 220px; margin-left: 8px; vertical-align: middle; }

/* /dash/custom-roles editing */
.roles-list .cm-scroll { overflow-x: auto; }
.roles-table th, .roles-table td { vertical-align: top; }
.roles-table .cr-num-wrap { display: flex; align-items: center; gap: 6px; }
.roles-table .cr-num { width: 62px; min-width: 0; box-sizing: border-box; }
/* Unique Group: the box is as wide as its column title */
.roles-table th:nth-child(4) { white-space: nowrap; }
.roles-table .cr-num-uniquenum { width: 108px; } /* set to the title's width by initCustomRoles */
.roles-table .cr-unit { white-space: nowrap; }
/* pill lists with nothing picked: just the drop down, no gap above it */
.roles-table .pill-wrap ul.ping-list:empty { display: none; }
.roles-table .pill-wrap ul.ping-list:empty + .ping-add { margin-top: 0; }
.roles-table .cr-unit { color: var(--muted); font-size: .8rem; }
.roles-table .cr-new-role { min-width: 0; width: 116px; }
.roles-table .cr-response { min-width: 0; width: 100px; }
.roles-table .pill-wrap { min-width: 118px; }
.roles-table td[data-label="List of options"] .pill-wrap { min-width: 124px; }
.roles-table td[data-label="Applied Channels"] .pill-wrap { min-width: 130px; }
.roles-table ul.ping-list li { white-space: nowrap; }
.roles-table .pill-wrap .ping-add { min-width: 0; width: 100%; box-sizing: border-box; }
.roles-table tr.alias-invalid .wl-input { border-color: #f04747; }
.roles-table .cc-del-cell { width: 1%; }
/* slightly smaller controls so all ten columns fit beside the sidebar */
.roles-table .wl-input, .roles-table ul.ping-list li { font-size: .86rem; }
.roles-table .wl-input { padding-left: 8px; padding-right: 8px; }

/* /dash/custom-commands: Expand opens a box under the command with everything but the name, response and embed buttons */
.commands-table th:nth-last-child(2), .commands-table td:nth-last-child(2) { padding-left: 10px; } /* Response (DM Response moved into the box) */
.commands-table .cc-expand { margin-top: 6px; padding: 3px 10px; font: inherit; font-size: .78rem; color: var(--muted); background: var(--bg); border: 1px solid #3a4054; border-radius: 4px; cursor: pointer; }
.commands-table .cc-expand:hover, .commands-table .cc-expand[aria-expanded="true"] { color: var(--text); border-color: var(--accent); }
.commands-table tr.cc-details-row[hidden] { display: none; }
.commands-table .cc-details-row td { padding-top: 0; padding-bottom: 12px; white-space: normal; width: auto; }
.commands-table .cc-details-row td:first-child { padding: 0; }
.cc-details { padding: 12px 14px; background: var(--panel); border: 1px solid var(--border); border-radius: 8px; }
.cc-detail-fields { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 14px 32px; margin-bottom: 8px; }
.cc-detail-field { display: flex; flex-direction: column; gap: 6px; }
.cc-detail-label { color: var(--muted); font-size: .82rem; }
.cc-detail-roles .cc-role-line:first-child { margin-top: 0; }
.commands-table tr.cc-main-row.alias-invalid + tr.cc-details-row td { background: rgba(240, 71, 71, .18); }

/* /dash/custom-roles: Expand opens a box under the role (same look as Custom Commands) */
.roles-table tr.cc-details-row[hidden] { display: none !important; }
.roles-table .cc-expand { margin-top: 6px; padding: 3px 10px; font: inherit; font-size: .78rem; color: var(--muted); background: var(--bg); border: 1px solid #3a4054; border-radius: 4px; cursor: pointer; }
.roles-table .cc-expand:hover, .roles-table .cc-expand[aria-expanded="true"] { color: var(--text); border-color: var(--accent); }
.roles-table .cc-details-row td { padding-top: 0; padding-bottom: 12px; }
.roles-table .cc-details-row td:first-child { padding: 0; }
.roles-table .cr-details .cc-detail-fields + .cc-detail-fields { margin-top: 12px; margin-bottom: 0; }
.roles-table .cr-details .pill-wrap { min-width: 170px; }
.roles-table tr.cc-main-row.alias-invalid + tr.cc-details-row td { background: rgba(240, 71, 71, .18); }
.roles-table td[data-label="List of options"] { min-width: 220px; }
.roles-table td[data-label="List of options"] .pill-wrap .ping-add { width: auto; min-width: 150px; }
.roles-list { max-width: 900px; }
@media (max-width: 640px) {
  .roles-table tbody tr.cc-details-row td { display: block; }
  .roles-table tbody tr.cc-details-row td:first-child { display: none; }
}

/* home page: Add this bot with Add with Admin Perms under it */
.hero-buttons { display: inline-flex; flex-direction: column; align-items: stretch; gap: 12px; }
/* one column per bot, in its branding colour (gaiusbot.me/branding) */
.hero-bots { display: flex; flex-wrap: wrap; justify-content: center; gap: 16px; }
.hero-buttons.bot-blue { --bot: #00acee; }
.hero-buttons.bot-plus { --bot: #ed6500; }
.hero-buttons.bot-play { --bot: #ed00b7; }
.hero-buttons[class*="bot-"] .btn { background: var(--bot); border-color: var(--bot); }
.hero-buttons[class*="bot-"] .btn-outline { background: transparent; color: var(--text); }
.hero-buttons[class*="bot-"] .btn-outline:hover { background: color-mix(in srgb, var(--bot) 18%, transparent); }
.hero-buttons .btn { text-align: center; }

/* Channel Moderation lists with nothing set: the message replaces the table */
.cm-scroll[hidden], .cm-empty-note[hidden] { display: none !important; }

/* Channel Moderation: whitelisted URLs / ignored channels listed in a box under the row */
.cm-filters tr.cm-list-row[hidden] { display: none !important; }
.cm-filters tr.cm-list-main td { vertical-align: top; }
.cm-filters tr.cm-list-main .cc-expand { margin-top: 6px; padding: 3px 10px; font: inherit; font-size: .78rem; color: var(--muted); background: var(--bg); border: 1px solid #3a4054; border-radius: 4px; cursor: pointer; }
.cm-filters tr.cm-list-main .cc-expand:hover, .cm-filters tr.cm-list-main .cc-expand[aria-expanded="true"] { color: var(--text); border-color: var(--accent); }
.cm-filters tr.cm-list-main:has(+ tr.cm-list-row:not([hidden])) td { border-bottom: 0; }
.cm-filters tr.cm-list-row td { padding-top: 0; }
.cm-filters .cm-list-box { padding: 12px 14px; }
.cm-filters .cm-list-box ul.ping-list { margin: 0; }
.cm-filters tr.cm-list-main .cm-addrow { margin-top: 0; }
.cm-filters tr.cm-list-main .pill-wrap .ping-add { margin-top: 0; }
/* fixed columns, so an opened list box wraps its items instead of moving the controls */
.cm-table.cm-filters { table-layout: fixed; }
.cm-table.cm-filters td:first-child { width: 50%; }
.cm-filters .cm-list-box { min-width: 0; overflow-wrap: anywhere; }
.cm-filters tr.cm-list-main .cm-addrow { flex-wrap: wrap; }
.cm-filters tr.cm-list-main .cm-addrow .wl-input { min-width: 0; flex: 1 1 140px; max-width: 240px; }
.cm-filters tr.cm-list-main .pill-wrap, .cm-filters tr.cm-list-main .pill-wrap .ping-add { min-width: 0; max-width: 100%; }

/* ---------------------------------------------------------------------------
   Documentation (/documentation)
   --------------------------------------------------------------------------- */
.docs-layout {
  display: grid;
  grid-template-columns: 253px minmax(0, 1fr);
  gap: 40px;
  max-width: var(--max);
  margin: 0 auto;
  padding: 24px 20px 80px;
  align-items: start;
}
.docs-layout .docs-main { max-width: none; margin: 0; padding: 0; min-width: 0; }

.docs-side { position: sticky; top: 16px; max-height: calc(100vh - 32px); overflow-y: auto; }
.docs-side-title { margin: 0 0 8px; padding: 0 12px; font-size: .75rem; font-weight: 700; letter-spacing: .15em; text-transform: uppercase; color: var(--muted); }
.docs-side-nav { display: flex; flex-direction: column; gap: 2px; }
.doc-side-item {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: 7px 12px; border-radius: 6px; color: var(--muted); font-size: .92rem; font-weight: 500;
}
.doc-side-item:hover { background: var(--panel); color: var(--text); }
.doc-side-item.active { background: var(--panel); color: var(--text); box-shadow: inset 3px 0 0 var(--accent); }
.doc-count { font-size: .75rem; color: var(--muted); font-variant-numeric: tabular-nums; }

.docs-crumb { margin: 0 0 4px; font-size: .9rem; color: var(--muted); }
.docs-crumb a { color: var(--accent); }
.docs-title { margin: 0 0 8px; font-size: clamp(1.8rem, 4vw, 2.4rem); }
.docs-lead { margin: 0 0 28px; color: var(--muted); font-size: 1.08rem; max-width: 70ch; }

.docs-section { padding: 28px 0; border-top: 1px solid var(--border); }
.docs-section h2 { margin: 0 0 12px; letter-spacing: .04em; }
.docs-section h3 { margin: 22px 0 8px; font-size: 1.05rem; }
.docs-section p { max-width: 75ch; }
.docs-section a, .doc-desc a { color: var(--accent); }
.docs-list { padding-left: 20px; color: var(--muted); }
.docs-list li { margin: 4px 0; }

.docs-main code, .doc-code {
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: .88em;
}
.docs-main :not(pre) > code {
  background: var(--panel); border: 1px solid var(--border); border-radius: 4px; padding: 1px 5px;
}

/* search */
.docs-search { position: relative; margin-bottom: 32px; max-width: 640px; }
.docs-search-label { display: block; margin-bottom: 6px; font-weight: 600; font-size: .9rem; }
.docs-search input {
  width: 100%; padding: 12px 14px; font: inherit; color: var(--text);
  background: var(--panel); border: 1px solid var(--border); border-radius: 8px;
}
.docs-search input:focus { outline: none; border-color: var(--accent); }
.docs-results {
  list-style: none; margin: 6px 0 0; padding: 6px; background: var(--panel);
  border: 1px solid var(--border); border-radius: 8px;
}
.docs-results a { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; padding: 8px 10px; border-radius: 6px; }
.docs-results a:hover, .docs-results a:focus { background: var(--bg); color: var(--text); outline: none; }
.docs-result-name { font-weight: 700; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }
.docs-result-sec { color: var(--accent); font-size: .8rem; align-self: center; }
.docs-result-desc { grid-column: 1 / -1; color: var(--muted); font-size: .88rem; }
.docs-result-empty { padding: 8px 10px; color: var(--muted); }

/* section cards */
.docs-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.docs-card {
  display: flex; flex-direction: column; gap: 6px; padding: 16px 18px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 8px;
}
.docs-card:hover { border-color: var(--accent); color: var(--text); }
.docs-card-title { font-weight: 700; }
.docs-card-blurb { color: var(--muted); font-size: .9rem; flex: 1; }
.docs-card-count { color: var(--accent); font-size: .8rem; font-weight: 600; }

/* jump list on section pages */
.docs-jump { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 28px; }
.docs-jump a {
  padding: 4px 10px; border: 1px solid var(--border); border-radius: 999px; font-size: .85rem;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace; color: var(--muted);
}
.docs-jump a:hover { border-color: var(--accent); color: var(--text); }

/* command cards */
.doc-cmd {
  padding: 22px 24px; margin-bottom: 16px; scroll-margin-top: 16px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px;
}
.doc-cmd:target { border-color: var(--accent); }
.doc-cmd-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; margin-bottom: 10px; }
.doc-cmd-head h3 { margin: 0; font-size: 1.25rem; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }
.doc-anchor:hover { color: var(--accent); }
.doc-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.doc-badge {
  display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: .75rem; font-weight: 600;
  border: 1px solid var(--border); color: var(--muted); white-space: nowrap;
}
.doc-perm-everyone { color: #3ba55d; border-color: rgba(59, 165, 93, .45); }
.doc-perm-helper { color: #4fa3e0; border-color: rgba(79, 163, 224, .45); }
.doc-perm-mod { color: #e3a33b; border-color: rgba(227, 163, 59, .45); }
.doc-perm-admin { color: #ed6b6d; border-color: rgba(237, 66, 69, .45); }
.doc-kind { text-transform: none; }

.doc-desc p { margin: 0 0 10px; color: var(--text); }
.doc-desc strong { color: var(--text); }
.doc-note {
  margin: 0 0 10px; padding: 8px 12px; font-size: .9rem; color: var(--muted);
  border-left: 3px solid var(--accent); background: var(--bg); border-radius: 0 6px 6px 0;
}
.doc-usage { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 14px; }
.doc-usage-col h4, .doc-extra h4 { margin: 0 0 6px; font-size: .75rem; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.doc-code {
  margin: 0; padding: 12px 14px; background: var(--bg); border: 1px solid var(--border); border-radius: 6px;
  white-space: pre-wrap; word-break: break-word; line-height: 1.7; color: var(--text);
}
.doc-arg { color: var(--accent); font-style: italic; }
.doc-arg::before { content: "<"; opacity: .6; font-style: normal; }
.doc-arg::after { content: ">"; opacity: .6; font-style: normal; }
.doc-extra { margin-top: 14px; }
.doc-extra p { margin: 0 0 8px; color: var(--muted); }

.doc-slash { margin-top: 14px; padding: 10px 14px; background: var(--bg); }
.doc-slash summary { font-weight: 600; font-size: .92rem; }
.doc-slash[open] summary { margin-bottom: 10px; }
.doc-sub { margin-bottom: 12px; }
.doc-sub:last-child { margin-bottom: 0; }
.doc-sub-name { margin: 0 0 6px; }
.doc-muted { color: var(--muted); font-size: .9rem; }
.doc-table-wrap { overflow-x: auto; }
.doc-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.doc-table th, .doc-table td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
.doc-table th { color: var(--muted); font-weight: 600; font-size: .75rem; letter-spacing: .1em; text-transform: uppercase; }
.doc-table tr:last-child td { border-bottom: 0; }
.doc-req { color: var(--bad); font-size: .75rem; }
.doc-choices { margin-top: 4px; color: var(--muted); font-size: .85rem; }
.doc-quote { margin: 14px 0 0; color: var(--muted); font-style: italic; font-size: .88rem; }

.docs-pager { display: flex; justify-content: space-between; gap: 12px; margin-top: 32px; padding-top: 20px; border-top: 1px solid var(--border); }
.docs-pager a { color: var(--accent); font-weight: 600; }
.docs-pager-next { margin-left: auto; }

@media (max-width: 860px) {
  .docs-layout { grid-template-columns: minmax(0, 1fr); gap: 20px; padding-top: 8px; }
  .docs-side { position: static; max-height: none; overflow: visible; }
  .docs-side-title { display: none; }
  .docs-side-nav { flex-direction: row; overflow-x: auto; gap: 6px; padding-bottom: 6px; scrollbar-width: thin; }
  .doc-side-item { flex: none; border: 1px solid var(--border); border-radius: 999px; padding: 5px 12px; font-size: .85rem; }
  .doc-side-item .doc-count { display: none; }
  .doc-side-item.active { box-shadow: none; border-color: var(--accent); }
  .doc-usage { grid-template-columns: minmax(0, 1fr); }
  .doc-cmd { padding: 18px 16px; }
}

/* documentation sidebar: one collapsible group per bot */
.docs-side-group { margin: 6px 0 0; padding: 0; background: none; border: 0; border-radius: 0; }
.docs-side-group-title {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: 7px 12px; border-radius: 6px; list-style: none;
  font-size: .92rem; font-weight: 700; color: var(--text); cursor: pointer;
}
.docs-side-group-title::-webkit-details-marker { display: none; }
.docs-side-group-title::before {
  content: ""; flex: none; width: 6px; height: 6px; margin-right: 2px;
  border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted);
  transform: rotate(-45deg); transition: transform .15s ease;
}
.docs-side-group[open] > .docs-side-group-title::before { transform: rotate(45deg); }
.docs-side-group-title > .doc-count { margin-left: auto; }
.docs-side-group-title:hover { background: var(--panel); }
.docs-side-group-items { display: flex; flex-direction: column; gap: 2px; margin: 2px 0 6px 10px; padding-left: 8px; border-left: 1px solid var(--border); }

@media (max-width: 860px) {
  .docs-side-nav { flex-direction: column; overflow: visible; gap: 4px; padding-bottom: 0; }
  .docs-side-nav > .doc-side-item { align-self: flex-start; }
  .docs-side-group { margin: 0; }
  .docs-side-group-title { padding: 6px 4px; }
  .docs-side-group-items { flex-direction: row; flex-wrap: nowrap; overflow-x: auto; gap: 6px; margin: 4px 0 6px; padding: 0 0 6px; border-left: 0; scrollbar-width: thin; }
}

/* ---------------------------------------------------------------------------
   Top bar (logged in): server selector and user menu dropdowns
   --------------------------------------------------------------------------- */
.hdr-dd { position: relative; }
.hdr-dd-btn {
  display: inline-flex; align-items: center; gap: 10px;
  max-width: 260px; padding: 6px 12px 6px 6px;
  font: inherit; color: var(--text); text-align: left;
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px; cursor: pointer;
}
.hdr-dd-btn:hover, .hdr-dd.open .hdr-dd-btn { border-color: var(--accent); }
.hdr-dd-btn .server-icon, .hdr-avatar { width: 36px; height: 36px; flex: none; border-radius: 50%; font-size: .8rem; }
.hdr-unknown { display: grid; place-items: center; background: #fff; color: #111; font-weight: 800; font-size: 1.2rem !important; }
.hdr-lines { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.hdr-line1 { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 150px; }
.hdr-line2 { color: var(--muted); font-size: .8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 150px; }
.hdr-caret { width: 18px; height: 18px; flex: none; margin-left: 4px; fill: none; stroke: var(--muted); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; transition: transform .15s ease; }
.hdr-dd.open .hdr-caret { transform: rotate(180deg); }

.hdr-dd-panel {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 50;
  width: 300px; max-width: calc(100vw - 32px);
  padding: 6px; background: var(--panel); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, .45);
}
.hdr-dd-panel[hidden] { display: none; }
.hdr-search { width: 100%; box-sizing: border-box; margin: 2px 0 6px; }
.hdr-list { max-height: min(60vh, 420px); overflow-y: auto; }
.hdr-item {
  display: flex; align-items: center; gap: 10px; width: 100%; box-sizing: border-box;
  padding: 8px; font: inherit; color: var(--text); text-align: left; text-decoration: none;
  background: none; border: 0; border-radius: 8px; cursor: pointer;
}
.hdr-item:hover, .hdr-item:focus-visible { background: rgba(255, 255, 255, .06); color: var(--text); }
.hdr-item.current { background: rgba(88, 101, 242, .16); }
.hdr-item:disabled { cursor: progress; opacity: .7; }
.hdr-item .server-icon { width: 34px; height: 34px; flex: none; border-radius: 50%; font-size: .75rem; }
.hdr-item .hdr-line1 { max-width: 220px; }
.hdr-item.no-bot .server-icon, .hdr-item.no-bot .hdr-line1 { opacity: .55; }
.hdr-bots { display: flex; align-items: center; gap: 4px; margin-top: 3px; min-height: 16px; }
.hdr-bots img { width: 16px; height: 16px; border-radius: 50%; display: block; }
.hdr-bots.none { color: var(--accent); font-size: .78rem; font-weight: 600; }
.hdr-empty { padding: 12px 8px; color: var(--muted); text-align: center; }
.hdr-all { display: block; margin-top: 4px; padding: 8px; border-top: 1px solid var(--border); color: var(--muted); font-size: .88rem; text-align: center; }
.hdr-all:hover { color: var(--text); }

.hdr-user .hdr-dd-panel { width: 200px; }
.hdr-menu-item { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; color: var(--text); font-weight: 500; }
.hdr-menu-item:hover { background: rgba(255, 255, 255, .06); color: var(--text); }
.hdr-menu-icon { width: 18px; height: 18px; flex: none; fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* server list page: servers without a bot */
a.server-card.no-bot { color: var(--text); text-decoration: none; }
a.server-card.no-bot .server-icon, a.server-card.no-bot .server-name { opacity: .55; }
a.server-card.no-bot:hover { border-color: var(--accent); }
.server-add { color: var(--accent); font-size: .85rem; font-weight: 600; }

@media (max-width: 640px) {
  .user-area { flex-wrap: wrap; }
  .hdr-dd-panel { right: auto; left: 0; }
  .hdr-user .hdr-dd-panel { right: 0; left: auto; }
}

/* fixed-width server selector; its dropdown is exactly as wide as the button (and the user menu's as its button) */
.hdr-servers .hdr-dd-btn { width: 250px; max-width: none; box-sizing: border-box; }
.hdr-servers .hdr-lines { flex: 1; }
.hdr-servers .hdr-dd-btn .hdr-line1, .hdr-servers .hdr-dd-btn .hdr-line2 { max-width: none; }
.hdr-dd .hdr-dd-panel, .hdr-user .hdr-dd-panel { left: 0; right: 0; width: auto; max-width: none; box-sizing: border-box; }
.hdr-user .hdr-dd-panel { min-width: 160px; }
.hdr-item .hdr-lines { flex: 1; }
.hdr-item .hdr-line1 { max-width: none; }
@media (max-width: 640px) {
  .hdr-dd-panel, .hdr-user .hdr-dd-panel { left: 0; right: 0; }
}
.hdr-dd-btn .hdr-caret { min-width: 18px; }
.hdr-dd-btn .hdr-lines { overflow: hidden; }

/* ---------------------------------------------------------------------------
   Server Home page: Server Info panel
   --------------------------------------------------------------------------- */
#home-list:has(.home-info) { display: block; width: 100%; max-width: 1080px; margin: 0 auto; }
.home-info { padding: 26px 28px; background: var(--panel); border: 1px solid var(--border); border-radius: 12px; }
.hi-title { margin: 0 0 18px; font-size: .95rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--text); }
.hi-top { display: flex; flex-direction: column; gap: 12px; padding-bottom: 18px; margin-bottom: 18px; border-bottom: 1px solid var(--border); }
.hi-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px 24px; }
.hi-item { display: flex; align-items: center; gap: 8px; min-width: 0; }
.hi-label { flex: none; white-space: nowrap; }
.hi-grid .hi-value { min-width: 0; }
.hi-label { color: var(--muted); font-weight: 600; }
.hi-value { color: var(--text); font-weight: 700; overflow-wrap: anywhere; }
.hi-value.none { color: var(--muted); font-weight: 500; font-style: italic; }
.hi-link { color: var(--accent); }
.hi-link:hover { text-decoration: underline; }
.hi-item.home-good .hi-label, .hi-value.home-good { color: #23d160; }
.hi-item.home-bad .hi-label, .hi-value.home-bad { color: #ff3b3b; }
.hi-item.home-bad a:hover { text-decoration: underline; }
.hi-person { display: inline-flex; align-items: center; gap: 8px; min-width: 0; }
.hi-avatar { width: 24px; height: 24px; border-radius: 50%; flex: none; }
.hi-play { padding: 5px 12px; font-size: .85rem; border-color: #ed00b7; background: #ed00b7; }
.copy-btn { display: inline-flex; align-items: center; gap: 5px; padding: 3px 8px; font: inherit; font-size: .8rem; font-weight: 600;
  color: #e8436b; background: none; border: 1px solid transparent; border-radius: 6px; cursor: pointer; }
.copy-btn:hover { border-color: #e8436b; }
.copy-btn.copied { color: #23d160; border-color: transparent; }
.copy-icon { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linejoin: round; }
.hi-footer { margin-top: 20px; padding-top: 14px; border-top: 1px solid var(--border); }
.hi-footer .copy-btn { padding-left: 0; font-size: .9rem; }
.hi-footer .copy-btn:hover { border-color: transparent; text-decoration: underline; }
@media (max-width: 640px) { .hi-grid { grid-template-columns: 1fr; } .home-info { padding: 20px 16px; } }
/* the Server Info panel uses the width beside the sidebar */
@media (min-width: 1100px) { .server-content:has(.home-info) { padding-right: 40px; } }
.hi-play { white-space: nowrap; }
