: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;
  max-width: var(--max);
  margin: 0 auto;
  padding: 16px 20px;
}
.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; }
/* 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; }
/* 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; }

/* /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; }
.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; }
