/* ==========================================================================
   Kuroneko dashboard — "chat noir & clair de lune"
   Colours taken from the logo: night #021F31, moonlit sky #90DCF4, halo #CDEEFA,
   sakura #F2719A (kept for one meaning: something changed / not saved yet).
   Type: JetBrains Mono for the whole interface, Victor Mono italic for titles.
   ========================================================================== */

/* ---------- fonts (self-hosted, SIL OFL — see fonts/LICENSE-*.txt) ---------- */
@font-face {
  font-family: "JetBrains Mono";
  src: url("fonts/jetbrains-mono-wght.woff2") format("woff2");
  font-weight: 100 800;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "JetBrains Mono";
  src: url("fonts/jetbrains-mono-wght-italic.woff2") format("woff2");
  font-weight: 100 800;
  font-style: italic;
  font-display: swap;
}
@font-face {
  font-family: "Victor Mono";
  src: url("fonts/victor-mono-600-italic.woff2") format("woff2");
  font-weight: 600;
  font-style: italic;
  font-display: swap;
}
@font-face {
  font-family: "Victor Mono";
  src: url("fonts/victor-mono-700-italic.woff2") format("woff2");
  font-weight: 700;
  font-style: italic;
  font-display: swap;
}

/* ---------- tokens ---------- */
:root {
  /* night scale (the logo's background is --night-900) */
  --night-950: #011522;   /* page */
  --night-900: #021f31;   /* wells inside panels, sidebar */
  --panel: #03263b;       /* section panels */
  --night-850: #052b43;   /* raised surface */
  --night-800: #07314c;   /* controls */
  --night-750: #0a3a58;   /* control hover */
  --night-700: #0d4263;   /* highlighted item */
  --line: #174d6c;        /* strong borders */
  --line-soft: rgba(144, 220, 244, 0.12);

  /* text (all ≥ 4.5:1 on panels) */
  --text: #e6f4fb;
  --text-muted: #a3c0d1;
  --text-subtle: #8aa8bc;

  /* accent: the moonlit sky of the logo (variables keep their historical "moon" name) */
  --moon: #90dcf4;
  --moon-strong: #b9eafa;
  --moon-ink: #021f31;
  --moon-soft: rgba(144, 220, 244, 0.12);
  --moon-line: rgba(144, 220, 244, 0.45);
  --halo: #cdeefa;

  /* sakura: changed, not saved yet */
  --sakura: #f2719a;
  --sakura-soft: rgba(242, 113, 154, 0.14);
  --sakura-line: rgba(242, 113, 154, 0.5);

  /* status */
  --danger: #ff7b72;
  --danger-soft: rgba(255, 123, 114, 0.12);
  --danger-line: rgba(255, 123, 114, 0.45);
  --ok: #7fe0b8;
  --ok-soft: rgba(127, 224, 184, 0.12);

  /* shape */
  --radius-sm: 8px;
  --radius: 10px;
  --radius-lg: 14px;
  --radius-panel: 18px;
  --shadow-surface: 0 1px 0 rgba(205, 238, 250, 0.04) inset;
  --shadow-pop: 0 20px 40px -16px rgba(0, 0, 0, 0.8), 0 0 0 1px var(--line);

  /* motion */
  --grow-xs: 1.015;   /* large controls (selects) */
  --grow-sm: 1.03;    /* buttons, tags, tabs */
  --grow-md: 1.06;    /* small controls, icons */
  --grow-lg: 1.12;    /* tiny marks (checkbox, nav icons) */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in: cubic-bezier(0.7, 0, 0.84, 0);
  --dur-fast: 150ms;
  --dur: 200ms;
  --dur-slow: 250ms;

  /* type */
  --font-display: "Victor Mono", "JetBrains Mono", ui-monospace, monospace;
  --font-sans: "JetBrains Mono", ui-monospace, "Cascadia Code", Consolas, monospace;
  --font-mono: "JetBrains Mono", ui-monospace, "Cascadia Code", Consolas, monospace;

  /* shell */
  --topbar-h: 60px;
  --sidebar-w: 296px;
  --gutter: 40px;

  /* layers */
  --z-sticky: 20;
  --z-savebar: 40;
  --z-popover: 45;      /* menus open above the save bar */
  --z-drawer: 55;
  --z-topbar: 50;
  --z-toast: 60;

  color-scheme: dark;
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }
@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}

body {
  margin: 0;
  min-height: 100dvh;
  font: 400 15px/1.6 var(--font-sans);
  font-feature-settings: "calt" 0;   /* no ligatures in prose: "->" stays two characters */
  color: var(--text);
  background-color: var(--night-950);
  /* the halo behind the logo's moon, very far up-right */
  background-image: radial-gradient(900px 480px at 85% -160px, rgba(87, 198, 243, 0.13) 0%, rgba(87, 198, 243, 0) 70%);
  background-repeat: no-repeat;
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; font-weight: 600; line-height: 1.2; }
h1 {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 700;
  font-size: clamp(30px, 4vw, 42px);
  letter-spacing: -0.02em;
  color: var(--halo);
}
h2 {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 700;
  font-size: 24px;
  letter-spacing: -0.01em;
  color: var(--halo);
}
p { margin: 0; }
a { color: inherit; }
img { display: block; max-width: 100%; }
button { font: inherit; color: inherit; }

.icon { flex: none; width: 20px; height: 20px; }

:focus-visible {
  outline: 2px solid var(--moon);
  outline-offset: 2px;
}

.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: fixed;
  top: 12px; left: 12px;
  z-index: 100;
  padding: 10px 16px;
  border-radius: var(--radius);
  background: var(--moon);
  color: var(--moon-ink);
  font-weight: 600;
  text-decoration: none;
  transform: translateY(-160%);
  transition: transform var(--dur) var(--ease-out);
}
.skip-link:focus { transform: none; }

main:focus { outline: none; }

.eyebrow {
  margin-bottom: 6px;
  font-family: var(--font-display);
  font-style: italic;
  font-size: 16px;
  font-weight: 600;
  color: var(--moon);
}
.lede { margin-top: 12px; color: var(--text-muted); max-width: 76ch; line-height: 1.7; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 15px;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  touch-action: manipulation;
  transition:
    background-color var(--dur-fast) var(--ease-out),
    border-color var(--dur-fast) var(--ease-out),
    color var(--dur-fast) var(--ease-out),
    box-shadow var(--dur) var(--ease-out),
    transform var(--dur) var(--ease-out);
}
.btn:active:not(:disabled) { transform: scale(0.97); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.45; cursor: not-allowed; }
.btn .icon { width: 18px; height: 18px; }

.btn-sm { min-height: 36px; padding: 0 12px; font-size: 14px; }
.btn-lg { min-height: 52px; padding: 0 26px; font-size: 16px; }

.btn-primary { background: var(--moon); color: var(--moon-ink); }
.btn-primary:hover:not(:disabled) {
  background: var(--moon-strong);
  box-shadow: 0 10px 22px -12px rgba(0, 0, 0, 0.9);
}

.btn-secondary {
  background: var(--night-800);
  border-color: var(--line);
  color: var(--text);
}
.btn-secondary:hover:not(:disabled) {
  background: var(--night-750);
  border-color: var(--moon-line);
}
.btn-secondary .icon { transition: color var(--dur-fast) var(--ease-out), transform var(--dur) var(--ease-out); }
.btn-secondary:hover:not(:disabled) .icon { color: var(--moon); }
.btn-secondary[aria-expanded="true"] { border-color: var(--moon-line); background: var(--night-750); }
.btn-secondary[aria-expanded="true"] .icon { color: var(--moon); transform: rotate(45deg); }

.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover:not(:disabled) { background: var(--night-800); color: var(--text); }

/* loading state */
.spinner {
  display: none;
  width: 16px; height: 16px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
}
.btn.is-loading { cursor: progress; }
.btn.is-loading .spinner { display: inline-block; animation: spin 700ms linear infinite; }

.icon-btn {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 36px; height: 36px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: background-color var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
}
.icon-btn::after { content: ""; position: absolute; inset: -4px; } /* 44px hit area */
.icon-btn:hover { background: var(--night-750); color: var(--text); }
.icon-btn--sm { width: 28px; height: 28px; }
.icon-btn--sm .icon { width: 16px; height: 16px; }
.icon-btn--danger:hover { background: var(--danger-soft); color: var(--danger); }
.icon-btn .icon { width: 18px; height: 18px; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: var(--z-topbar);
  height: var(--topbar-h);
  background: rgba(1, 21, 34, 0.9);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line-soft);
}
.topbar-inner {
  display: flex;
  align-items: center;
  gap: 18px;
  height: 100%;
  padding: 0 24px;
}
.menu-btn { display: none; }
.brand {
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  border-radius: var(--radius);
}
.brand-logo {
  width: 34px; height: 34px;
  border-radius: 50%;
  box-shadow: 0 0 0 1px var(--line), 0 0 18px -2px rgba(87, 198, 243, 0.45);
  transition: box-shadow var(--dur) var(--ease-out);
}
.brand:hover .brand-logo { box-shadow: 0 0 0 2px var(--moon-line), 0 0 22px 0 rgba(87, 198, 243, 0.55); }
.brand-name {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 21px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--halo);
}

.crumbs { flex: 0 1 auto; min-width: 0; overflow: hidden; padding-left: 18px; border-left: 1px solid var(--line-soft); }
.crumbs ol { display: flex; align-items: center; gap: 8px; margin: 0; padding: 0; list-style: none; min-width: 0; }
.crumbs li { display: flex; align-items: center; gap: 8px; min-width: 0; font-size: 13px; color: var(--text-muted); }
.crumbs li + li::before { content: "/"; color: var(--text-subtle); }
.crumbs a {
  text-decoration: none;
  border-radius: 4px;
  transition: color var(--dur-fast) var(--ease-out);
}
.crumbs a:hover { color: var(--moon); }
.crumbs [aria-current="page"] {
  color: var(--text);
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.account-avatar { width: 30px; height: 30px; border-radius: 50%; box-shadow: 0 0 0 1px var(--line); }
.account-name { font-size: 13px; font-weight: 600; }
.account-logout { margin: 0 0 0 4px; }

/* ---------- notifications ---------- */
.toasts {
  position: fixed;
  top: 76px;
  right: 16px;
  z-index: var(--z-toast);
  display: grid;
  gap: 10px;
  width: min(400px, calc(100% - 32px));
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 10px 12px 14px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--ok);
  border-radius: var(--radius-lg);
  background: var(--night-800);
  box-shadow: var(--shadow-pop);
  pointer-events: auto;
  animation: toast-in var(--dur-slow) var(--ease-out);
}
.toast--error { border-left-color: var(--danger); }
.toast--info { border-left-color: var(--moon); }
.toast-icon { margin-top: 1px; color: var(--ok); }
.toast--error .toast-icon { color: var(--danger); }
.toast--info .toast-icon { color: var(--moon); }
.toast-text { flex: 1; font-size: 15px; padding-top: 1px; }
.toast-action {
  flex: none;
  min-height: 28px;
  border: 0;
  padding: 0 8px;
  border-radius: 6px;
  background: transparent;
  color: var(--moon);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: background-color var(--dur-fast) var(--ease-out);
}
.toast-action:hover { background: var(--moon-soft); }
.toast.is-leaving { animation: toast-out var(--dur-fast) var(--ease-in) forwards; }

/* ---------- alerts ---------- */
.alert {
  display: flex;
  gap: 12px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--night-850);
  text-align: left;
}
.alert > .icon { margin-top: 2px; }
.alert--error { border-color: var(--danger-line); background: var(--danger-soft); }
.alert--error > .icon { color: var(--danger); }
.alert--info > .icon { color: var(--moon); }
.alert:focus { outline: none; box-shadow: 0 0 0 2px var(--danger-line); }
.alert-title { font-weight: 600; }
.alert-list { margin: 6px 0 0; padding-left: 18px; color: var(--text-muted); }
.alert-list a { color: var(--text); text-underline-offset: 3px; }
.alert-list a:hover { color: var(--moon); }

/* ---------- layout ---------- */
.page { max-width: 1180px; margin: 0 auto; padding: 40px 24px 80px; }
.page--narrow { max-width: 760px; }
.page-head { margin-bottom: 28px; }

/* ---------- login ---------- */
.login {
  display: grid;
  place-items: center;
  min-height: calc(100dvh - 65px);
  padding: 40px 16px 80px;
}
.login-card { width: min(460px, 100%); text-align: center; }
.login-logo {
  width: 128px; height: 128px;
  margin: 0 auto 28px;
  border-radius: 50%;
  /* moon ring: two flat rings, no glow */
  box-shadow: 0 0 0 6px var(--night-900), 0 0 0 7px var(--line);
}
.login-title { font-size: clamp(40px, 8vw, 52px); }
.login .lede { margin: 12px auto 28px; }
.login .alert { margin-bottom: 20px; }
.login-cta { width: 100%; }
.login-cta .icon { transition: transform var(--dur) var(--ease-out); }
.login-cta:hover .icon { transform: translateX(2px); }
.fineprint { margin-top: 16px; font-size: 14px; color: var(--text-subtle); }

/* ---------- guild list ---------- */
.guild-list {
  margin: 0;
  padding: 0;
  list-style: none;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-lg);
  background: var(--night-900);
  box-shadow: var(--shadow-surface);
  overflow: hidden;
}
.guild-list > li + li, .guild-row + .guild-row { border-top: 1px solid var(--line-soft); }
.guild-row {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 16px;
  min-height: 76px;
  padding: 14px 18px;
  text-decoration: none;
  transition: background-color var(--dur-fast) var(--ease-out);
}
a.guild-row:hover { background: var(--night-850); }
a.guild-row:focus-visible { outline-offset: -2px; border-radius: var(--radius-lg); }
.guild-icon { width: 48px; height: 48px; border-radius: 50%; object-fit: cover; }
.guild-icon--fallback {
  display: grid;
  place-items: center;
  background: var(--night-800);
  border: 1px solid var(--line);
  font-family: var(--font-display);
  font-style: italic;
  font-size: 20px;
  font-weight: 600;
  color: var(--moon);
}
.guild-main { display: grid; gap: 2px; min-width: 0; }
.guild-name {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.guild-meta { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; color: var(--text-muted); }
.guild-meta .icon { width: 15px; height: 15px; }
.row-chevron { color: var(--text-subtle); transition: transform var(--dur) var(--ease-out), color var(--dur-fast); }
a.guild-row:hover .row-chevron { color: var(--moon); transform: translateX(3px); }

.badge {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  transition: border-color var(--dur) var(--ease-out), color var(--dur) var(--ease-out);
}
a.guild-row:hover .badge { border-color: var(--moon-line); color: var(--moon); }

.guild-row--skeleton { grid-template-columns: 48px minmax(0, 1fr); }
.skeleton {
  display: block;
  background: linear-gradient(90deg, var(--night-800) 0%, var(--night-750) 50%, var(--night-800) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
}
.skeleton--circle { width: 48px; height: 48px; border-radius: 50%; }
.skeleton--line { width: min(240px, 70%); height: 14px; border-radius: 4px; }
.loading-note { margin-top: 14px; font-size: 14px; color: var(--text-muted); }

/* ---------- empty states ---------- */
.empty-state {
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 48px 24px;
  text-align: center;
  border: 1px dashed var(--line);
  border-radius: var(--radius-lg);
  background: var(--night-900);
}
.empty-state--inline { padding: 40px 24px; }
.empty-mark {
  display: grid;
  place-items: center;
  width: 48px; height: 48px;
  margin-bottom: 6px;
  border-radius: 50%;
  background: var(--moon-soft);
  color: var(--moon);
}
.empty-title { font-family: var(--font-display); font-style: italic; font-size: 20px; font-weight: 700; }
.empty-text { max-width: 44ch; color: var(--text-muted); }
.empty-state > .btn, .empty-state > .popover-anchor { margin-top: 12px; }

/* ---------- server pages: shell ----------
   [ sidebar | page content (left aligned, up to 1280px) | "on this page" ]
   The sidebar is glued to the left edge; on phones it becomes a drawer. */
.guild-layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1280px);
  justify-content: start;
  min-height: calc(100dvh - var(--topbar-h));
}
.guild-layout > .config { padding: 36px var(--gutter) 180px; }
@media (min-width: 1500px) {
  .guild-layout { grid-template-columns: var(--sidebar-w) minmax(0, 1240px) 232px; }
}

/* ----- sidebar ----- */
.sidebar {
  position: sticky;
  top: var(--topbar-h);
  align-self: start;
  display: flex;
  flex-direction: column;
  height: calc(100dvh - var(--topbar-h));
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
  padding: 20px 16px 32px;
  border-right: 1px solid var(--line-soft);
  background: linear-gradient(180deg, rgba(2, 31, 49, 0.85), rgba(2, 31, 49, 0.55));
}
.sidebar-head { display: flex; align-items: flex-start; gap: 8px; }
.sidebar-close { display: none; }

/* server switcher: the server's icon sits in the logo's glowing moon ring */
.server-switch { position: relative; flex: 1; min-width: 0; }
.server-current {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--panel);
  cursor: pointer;
  list-style: none;
  transition: border-color var(--dur-fast) var(--ease-out), background-color var(--dur-fast) var(--ease-out);
}
.server-current::-webkit-details-marker { display: none; }
.server-current:hover, .server-switch[open] .server-current { border-color: var(--moon-line); }
.server-mark {
  flex: none;
  width: 40px; height: 40px;
  border-radius: 50%;
  object-fit: cover;
  box-shadow: 0 0 0 2px var(--night-900), 0 0 0 3px rgba(144, 220, 244, 0.55), 0 0 16px 2px rgba(87, 198, 243, 0.35);
}
.server-mark--letter {
  display: grid;
  place-items: center;
  background: radial-gradient(circle at 50% 35%, #8fdcf4 0%, #3aa8d8 55%, #0a4a6e 100%);
  color: var(--night-900);
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 700;
  font-size: 19px;
}
.server-text { display: grid; min-width: 0; flex: 1; }
.server-name { font-weight: 700; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.server-meta { font-size: 12px; color: var(--text-muted); }
.server-chevron { width: 18px; height: 18px; color: var(--text-muted); transition: transform var(--dur) var(--ease-out); }
.server-switch[open] .server-chevron { transform: rotate(180deg); color: var(--moon); }
.server-menu {
  position: absolute;
  left: 0; right: 0; top: calc(100% + 6px);
  z-index: var(--z-popover);
  display: grid;
  gap: 4px;
  padding: 8px;
  border-radius: var(--radius-lg);
  background: var(--night-800);
  box-shadow: var(--shadow-pop);
  animation: pop-in var(--dur) var(--ease-out);
}
.server-menu-title { padding: 4px 8px 6px; font-size: 12px; color: var(--text-subtle); }
.server-menu ul { display: grid; gap: 2px; margin: 0; padding: 0; list-style: none; }
.server-option, .server-all {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 0 8px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  text-decoration: none;
  transition: background-color var(--dur-fast) var(--ease-out);
}
.server-option .server-mark { width: 28px; height: 28px; box-shadow: 0 0 0 1px var(--line); font-size: 14px; }
.server-option > span:not(.server-mark) { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.server-option:hover, .server-all:hover { background: var(--night-750); }
.server-option[aria-current="true"] { color: var(--moon); }
.server-check { width: 16px; height: 16px; }
.server-all { margin-top: 4px; border-top: 1px solid var(--line-soft); border-radius: 0 0 var(--radius-sm) var(--radius-sm); color: var(--text-muted); }
.server-all .icon { width: 16px; height: 16px; }

/* page groups */
.side-nav { display: grid; gap: 22px; margin-top: 24px; }
.side-group ul { display: grid; gap: 2px; margin: 0; padding: 0; list-style: none; }
.side-group-title {
  margin: 0 0 6px;
  padding: 0 12px;
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 600;
  font-size: 15px;
  color: var(--moon);
}
.side-link {
  position: relative;
  display: flex;
  align-items: center;
  gap: 11px;
  min-height: 40px;
  padding: 0 12px;
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 13.5px;
  font-weight: 500;
  text-decoration: none;
  transition: background-color var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
}
.side-link .icon { width: 17px; height: 17px; transition: transform var(--dur) var(--ease-out); }
.side-label { flex: 1; min-width: 0; }
.side-link:hover { background: var(--night-800); color: var(--text); }
.side-link:hover .icon { transform: scale(var(--grow-lg)); }
.side-link[aria-current="page"] {
  background: var(--moon);
  color: var(--moon-ink);
  font-weight: 700;
  box-shadow: 0 6px 20px -10px rgba(144, 220, 244, 0.8);
}
.side-link[aria-current="page"]:focus-visible { outline-color: var(--halo); }
/* a module that is turned off: greyed, with an "off" chip */
.side-link.is-off { color: var(--text-subtle); }
.side-link.is-off .icon, .side-link.is-off .side-label { opacity: 0.6; }
.side-off {
  flex: none;
  padding: 1px 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-subtle);
}
.side-link.is-off:hover .icon, .side-link.is-off:hover .side-label { opacity: 1; }
.side-link[aria-current="page"].is-off { color: var(--moon-ink); }
.side-link[aria-current="page"].is-off .icon, .side-link[aria-current="page"].is-off .side-label { opacity: 1; }
.side-link[aria-current="page"] .side-off { border-color: rgba(2, 31, 49, 0.35); color: var(--moon-ink); }

/* sections of the current page, under its link (filled by dashboard.js) */
.side-group .side-sub {
  display: grid;
  gap: 1px;
  margin: 6px 0 6px 20px;
  padding: 0 0 0 12px;
  border-left: 1px solid var(--line);
  list-style: none;
}
.side-sub a, .toc a {
  position: relative;
  display: block;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  color: var(--text-muted);
  text-decoration: none;
  transition: color var(--dur-fast) var(--ease-out), background-color var(--dur-fast) var(--ease-out);
}
.side-sub a:hover, .toc a:hover { color: var(--text); background: var(--night-800); }
.side-sub a[aria-current="true"], .toc a[aria-current="true"] { color: var(--moon); font-weight: 600; }
.side-sub a::before, .toc a::before {
  content: "";
  position: absolute;
  left: -13px; top: 8px; bottom: 8px;
  width: 2px;
  border-radius: 2px;
  background: var(--moon);
  transform: scaleY(0);
  transition: transform var(--dur) var(--ease-out);
}
.side-sub a[aria-current="true"]::before, .toc a[aria-current="true"]::before { transform: scaleY(1); }

/* ----- "on this page" (wide screens; dashboard.js builds it from the section titles) ----- */
.toc {
  position: sticky;
  top: calc(var(--topbar-h) + 36px);
  align-self: start;
  display: none;
  padding: 0 24px 0 0;
}
.toc-title {
  margin-bottom: 10px;
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 700;
  font-size: 17px;
  color: var(--halo);
}
.toc ul { display: grid; gap: 1px; margin: 0; padding: 0 0 0 12px; border-left: 1px solid var(--line); list-style: none; }
@media (min-width: 1500px) {
  .toc { display: block; }
  .side-group .side-sub { display: none; }
}

.config { min-width: 0; }

/* ----- page head ----- */
.page-head {
  position: relative;
  margin-bottom: 28px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--line-soft);
}
.config > .alert { margin-bottom: 20px; }

/* ----- section panels: one panel per part of a page ----- */
.settings-section {
  display: grid;
  grid-template-columns: minmax(0, 300px) minmax(0, 1fr);
  gap: 20px 48px;
  margin-bottom: 20px;
  padding: 28px 32px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-panel);
  background: var(--panel);
  box-shadow: var(--shadow-surface);
  scroll-margin-top: calc(var(--topbar-h) + 20px);
}
.section-head h2 { display: flex; align-items: center; gap: 10px; }
.section-head p { margin-top: 8px; font-size: 13.5px; line-height: 1.65; color: var(--text-muted); }
.section-body { display: grid; gap: 24px; min-width: 0; align-content: start; }

/* stacked: the title above, the content on the whole width */
.settings-section--stacked { grid-template-columns: minmax(0, 1fr); }
.settings-section--stacked > .section-head {
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line-soft);
}
.settings-section--stacked > .section-head p { max-width: 90ch; }
.section-head--row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px 24px;
  flex-wrap: wrap;
}
.section-head--row > div:first-child { max-width: 72ch; }

@media (max-width: 1180px) {
  .settings-section { grid-template-columns: minmax(0, 1fr); }
  .settings-section > .section-head { padding-bottom: 16px; border-bottom: 1px solid var(--line-soft); }
}

/* ---------- fields ---------- */
.field { display: grid; gap: 6px; }
.field-label { font-weight: 500; font-size: 15px; }
.field-help { font-size: 14px; color: var(--text-muted); }
.field-error {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 14px;
  color: var(--danger);
}
.field-error .icon { width: 16px; height: 16px; margin-top: 2px; }

/* select: native control, custom chevron. Customizable picker where supported. */
.select { position: relative; margin-top: 4px; max-width: 520px; }
.select select {
  appearance: none;
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 46px;
  padding: 0 44px 0 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--night-800);
  color: var(--text);
  font: 400 15px/1.3 var(--font-sans);
  cursor: pointer;
  transition: border-color var(--dur-fast) var(--ease-out), background-color var(--dur-fast) var(--ease-out);
}
.select select:hover { background: var(--night-750); border-color: #245a7a; }
.select select:focus-visible { outline: 2px solid var(--moon); outline-offset: 2px; }
.select select[aria-invalid="true"] { border-color: var(--danger-line); }
.select-icon {
  position: absolute;
  right: 14px;
  top: 50%;
  width: 18px; height: 18px;
  margin-top: -9px;
  color: var(--text-muted);
  pointer-events: none;
  transition: transform var(--dur) var(--ease-out), color var(--dur-fast) var(--ease-out);
}
.select:hover .select-icon { color: var(--moon); transform: translateY(2px); }

.opt-hash { color: var(--text-subtle); margin-right: 2px; }
.opt-meta { color: var(--text-subtle); font-size: 13px; }

/* Customizable <select> (Chromium): same native control, styled picker. */
@supports (appearance: base-select) {
  .select select, .select ::picker(select) { appearance: base-select; }
  .select select::picker-icon { display: none; }

  .select:has(select:open) .select-icon { color: var(--moon); transform: rotate(180deg); }
  .select:has(select:open) select { border-color: var(--moon-line); background: var(--night-750); }

  .select ::picker(select) {
    margin-top: 6px;
    padding: 6px;
    max-height: min(340px, 60vh);
    border: 0;
    border-radius: var(--radius-lg);
    background: var(--night-850);
    box-shadow: var(--shadow-pop);
    color: var(--text);
    opacity: 0;
    transform: translateY(-4px);
    transition:
      opacity var(--dur-fast) var(--ease-out),
      transform var(--dur) var(--ease-out),
      overlay var(--dur) allow-discrete,
      display var(--dur) allow-discrete;
  }
  .select ::picker(select):popover-open { opacity: 1; transform: none; }
  @starting-style {
    .select ::picker(select):popover-open { opacity: 0; transform: translateY(-4px); }
  }

  .select option {
    display: flex;
    align-items: center;
    gap: 2px;
    min-height: 40px;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: 15px;
    cursor: pointer;
    transition: background-color 120ms var(--ease-out), color 120ms var(--ease-out);
  }
  .select option:hover, .select option:focus-visible {
    background: var(--night-700);
    color: var(--text);
    outline: none;
  }
  .select option:focus-visible { box-shadow: inset 2px 0 0 var(--moon); }
  .select option:checked { background: var(--moon-soft); color: var(--text); font-weight: 500; }
  .select option::checkmark { order: 1; margin-left: auto; padding-left: 12px; color: var(--moon); font-weight: 600; }
  .select option:disabled { opacity: 0.45; cursor: not-allowed; }
  .select option:disabled:hover { background: transparent; color: var(--text-muted); }
  .select .opt-label--empty { color: var(--text-muted); font-style: italic; }
  .select option:checked .opt-hash { color: var(--moon); }
}

/* switch (checkbox semantics, role="switch") */
.switch {
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: start;
  gap: 14px;
  margin: -10px -12px;
  padding: 10px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background-color var(--dur-fast) var(--ease-out);
}
.switch-input {
  position: absolute;
  opacity: 0;
  width: 1px; height: 1px;
  margin: 0;
}
.switch-track {
  position: relative;
  width: 44px; height: 26px;
  margin-top: 1px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--night-800);
  transition: background-color var(--dur) var(--ease-out), border-color var(--dur-fast) var(--ease-out);
}
.switch-thumb {
  position: absolute;
  top: 3px; left: 3px;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: transform var(--dur) var(--ease-out), background-color var(--dur) var(--ease-out);
}
.switch-text { display: grid; gap: 2px; }
.switch-label { font-weight: 500; font-size: 15px; color: var(--text-muted); transition: color var(--dur-fast) var(--ease-out); }
.switch-help { font-size: 14px; color: var(--text-subtle); transition: color var(--dur-fast) var(--ease-out); }

/* hovering the text or the track highlights both */
.switch:hover { background: var(--night-900); }
.switch:hover .switch-label { color: var(--text); }
.switch:hover .switch-help { color: var(--text-muted); }
.switch:hover .switch-track { border-color: var(--moon-line); }
.switch-input:checked + .switch-track { background: var(--moon); border-color: var(--moon); }
.switch-input:checked + .switch-track .switch-thumb { transform: translateX(18px); background: var(--moon-ink); }
.switch-input:checked ~ .switch-text .switch-label { color: var(--text); }
.switch:hover .switch-input:checked + .switch-track { background: var(--moon-strong); }
.switch-input:focus-visible + .switch-track { outline: 2px solid var(--moon); outline-offset: 3px; }
.switch:has(.switch-input:disabled) { opacity: 0.45; cursor: not-allowed; }
.switch:has(.switch-input:disabled):hover { background: transparent; }

/* ---------- popovers (role picker, permission menu) ---------- */
.popover-anchor { position: relative; }
.popover-anchor--center { display: flex; justify-content: center; }

.popover {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: var(--z-popover);
  width: max-content;
  min-width: 260px;
  max-width: min(340px, calc(100vw - 32px));
  padding: 6px;
  border-radius: var(--radius-lg);
  background: var(--night-850);
  box-shadow: var(--shadow-pop);
  transform-origin: top left;
  animation: pop-in var(--dur) var(--ease-out);
  text-align: left;
}
.popover--align-right { left: auto; right: 0; transform-origin: top right; }
.popover--above { top: auto; bottom: calc(100% + 8px); transform-origin: bottom left; }
.popover--above.popover--align-right { transform-origin: bottom right; }
.popover-anchor--center > .popover { left: 50%; translate: -50% 0; transform-origin: top center; }
.popover--picker { width: 300px; }

.popover-title {
  padding: 8px 10px 6px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-subtle);
}
.popover-search {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  padding: 0 10px;
  border-bottom: 1px solid var(--line-soft);
  color: var(--text-subtle);
  transition: color var(--dur-fast) var(--ease-out);
}
.popover-search .icon { width: 18px; height: 18px; }
.popover-search input {
  flex: 1;
  min-width: 0;
  min-height: 44px;
  border: 0;
  background: transparent;
  color: var(--text);
  font: 400 15px var(--font-sans);
}
.popover-search input::placeholder { color: var(--text-subtle); }
.popover-search input:focus { outline: none; }
.popover-search:focus-within { color: var(--moon); }

.option-list { max-height: 280px; margin: 0; padding: 0; list-style: none; overflow-y: auto; }
.option-list:empty { display: none; }
.popover-empty { padding: 12px 10px; font-size: 14px; color: var(--text-muted); }

.menu-item, .option {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 42px;
  padding: 8px 10px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  text-align: left;
  font-size: 15px;
  cursor: pointer;
  transition: background-color 120ms var(--ease-out), color 120ms var(--ease-out);
}
.menu-item:hover, .menu-item:focus-visible,
.option:hover, .option.is-active {
  background: var(--night-700);
  color: var(--text);
  outline: none;
}
.menu-item:focus-visible, .option.is-active { box-shadow: inset 2px 0 0 var(--moon); }
.menu-item .cmd { font-family: var(--font-mono); font-size: 14px; color: var(--moon); }
.menu-item .menu-label { margin-left: auto; padding-left: 16px; font-size: 14px; color: var(--text-subtle); }
.menu-item:hover .menu-label, .menu-item:focus-visible .menu-label { color: var(--text-muted); }
.option .role-dot { width: 10px; height: 10px; box-shadow: none; }
.option-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- roles & permissions ---------- */
.role-area { display: grid; gap: 12px; }
.role-list { display: grid; gap: 12px; }
.role-list:empty { display: none; }

.role-card {
  position: relative;
  padding: 14px 16px 16px 20px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-lg);
  background: var(--night-900);
  box-shadow: var(--shadow-surface);
  transition: border-color 700ms var(--ease-out);
  animation: role-in var(--dur-slow) var(--ease-out);
}
/* Discord role colour as a left stripe (the name is always shown too) */
.role-card::before {
  content: "";
  position: absolute;
  left: -1px; top: 14px; bottom: 14px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--role-color, var(--text-subtle));
}
.role-card.is-new { border-color: var(--moon-line); transition-duration: 0ms; }
.role-card.is-leaving { animation: role-out var(--dur-fast) var(--ease-in) forwards; pointer-events: none; }

.role-head { display: flex; align-items: center; gap: 10px; min-height: 36px; }
.role-dot {
  flex: none;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--role-color, var(--text-subtle));
  box-shadow: 0 0 0 2px var(--night-900), 0 0 0 3px var(--line);
}
.role-name {
  min-width: 0;
  font-family: var(--font-sans);
  font-size: 16px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.role-at { color: var(--text-subtle); font-weight: 500; }
.role-count {
  flex: none;
  padding: 2px 8px;
  border-radius: 6px;
  background: var(--night-800);
  font-size: 13px;
  color: var(--text-muted);
}
.role-remove { margin-left: auto; }

.role-perms {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
}
.role-empty { font-size: 14px; color: var(--text-subtle); font-style: italic; }
.role-card:not(.is-empty) .role-empty { display: none; }

.tag-list { display: contents; margin: 0; padding: 0; list-style: none; }

/* permission tag */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 34px;
  padding: 0 5px 0 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--night-800);
  transition:
    background-color var(--dur-fast) var(--ease-out),
    border-color var(--dur-fast) var(--ease-out),
    transform var(--dur) var(--ease-out);
  animation: tag-in var(--dur) var(--ease-out);
}
.tag-cmd { font-family: var(--font-mono); font-size: 14px; color: var(--moon); }
.tag-label { font-size: 14px; color: var(--text-muted); transition: color var(--dur-fast) var(--ease-out); }
.tag-remove {
  position: relative;
  display: grid;
  place-items: center;
  width: 24px; height: 24px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text-subtle);
  cursor: pointer;
  opacity: 0;
  transform: scale(0.7);
  transition:
    opacity var(--dur-fast) var(--ease-out),
    transform var(--dur-fast) var(--ease-out),
    color var(--dur-fast) var(--ease-out),
    background-color var(--dur-fast) var(--ease-out);
}
.tag-remove::after { content: ""; position: absolute; inset: -5px; } /* bigger hit area */
.tag-remove .icon { width: 15px; height: 15px; }

.tag:hover, .tag:has(:focus-visible) {
  background: var(--night-700);
  border-color: rgba(242, 211, 107, 0.32);
  transform: scale(var(--grow-sm));
}
.tag:hover .tag-label, .tag:has(:focus-visible) .tag-label { color: var(--text); }
.tag:hover .tag-remove, .tag:has(:focus-visible) .tag-remove { opacity: 1; transform: none; }

.tag:has(.tag-remove:hover), .tag:has(.tag-remove:focus-visible) { border-color: var(--danger-line); }
.tag-remove:hover, .tag-remove:focus-visible {
  background: var(--danger-soft);
  color: var(--danger);
}
.tag-remove:hover .icon { animation: x-shake 260ms ease-in-out; }
.tag-remove:focus-visible { outline: 2px solid var(--danger); outline-offset: 1px; }

.tag.is-leaving { animation: tag-out 140ms var(--ease-in) forwards; pointer-events: none; }

/* touch screens have no hover: keep the × visible */
@media (hover: none) {
  .tag-remove { opacity: 0.75; transform: none; }
}

/* "+" add permission */
.add-btn {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 34px; height: 34px;
  padding: 0;
  border: 1px dashed var(--line);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition:
    border-color var(--dur-fast) var(--ease-out),
    color var(--dur-fast) var(--ease-out),
    background-color var(--dur-fast) var(--ease-out);
}
.add-btn::after { content: ""; position: absolute; inset: -5px; }
.add-btn .icon { width: 18px; height: 18px; transition: transform var(--dur) var(--ease-out); }
.add-btn:hover:not([aria-disabled="true"]),
.add-btn[aria-expanded="true"] {
  border-style: solid;
  border-color: var(--moon-line);
  background: var(--moon-soft);
  color: var(--moon);
}
.add-btn:hover:not([aria-disabled="true"]) .icon { transform: rotate(90deg); }
.add-btn[aria-expanded="true"] .icon,
.add-btn[aria-expanded="true"]:hover .icon { transform: rotate(45deg); } /* "+" becomes "×": click again to close */
.add-btn[aria-disabled="true"] { opacity: 0.4; cursor: not-allowed; }

/* ---------- save bar ----------
   Fixed at the bottom of the screen, aligned on the page content (not the sidebar). */
.savebar {
  position: fixed;
  left: calc(var(--sidebar-w) + var(--gutter));
  bottom: 20px;
  z-index: var(--z-savebar);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  width: min(820px, calc(100vw - var(--sidebar-w) - 2 * var(--gutter)));
  padding: 10px 10px 10px 18px;
  border: 1px solid var(--sakura-line);
  border-radius: var(--radius-lg);
  background: rgba(7, 49, 76, 0.96);
  backdrop-filter: blur(8px);
  box-shadow: var(--shadow-pop), 0 0 0 4px rgba(242, 113, 154, 0.06);
  transition:
    transform var(--dur-slow) var(--ease-out),
    opacity var(--dur) var(--ease-out),
    visibility 0s linear 0s;
}
.savebar.is-hidden {
  opacity: 0;
  visibility: hidden;
  transform: translateY(calc(100% + 28px));
  transition:
    transform var(--dur) var(--ease-in),
    opacity var(--dur-fast) var(--ease-in),
    visibility 0s linear var(--dur);
}
body:not(.has-sidebar) .savebar { left: 50%; transform: translateX(-50%); }
.savebar-status { display: flex; align-items: center; gap: 10px; min-width: 0; font-size: 13.5px; font-weight: 600; }
.savebar-dot {
  flex: none;
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--sakura);
  box-shadow: 0 0 0 4px var(--sakura-soft);
}
form.has-savebar .form-submit { display: none; }
@media (max-width: 1023px) {
  .savebar { left: var(--gutter); width: calc(100vw - 2 * var(--gutter)); }
}
@media (max-width: 640px) {
  .savebar {
    left: 8px;
    bottom: max(8px, env(safe-area-inset-bottom));
    width: calc(100vw - 16px);
    padding: 8px 8px 8px 14px;
    gap: 8px;
  }
  .savebar-status { flex: 1; font-size: 12.5px; line-height: 1.3; }
  .savebar-actions { gap: 4px; }
  .savebar-actions .btn { padding: 0 12px; }
}
.savebar-actions { display: flex; gap: 8px; flex: none; }

/* ==========================================================================
   Welcome / goodbye editor
   ========================================================================== */

/* ---------- tabs ---------- */
.tabs {
  display: flex;
  gap: 4px;
  margin: 4px 0 20px;
  border-bottom: 1px solid var(--line-soft);
}
.tab {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 46px;
  padding: 0 16px;
  border: 0;
  background: transparent;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 15px;
  cursor: pointer;
  transition: color var(--dur-fast) var(--ease-out);
}
.tab::after {
  content: "";
  position: absolute;
  left: 12px; right: 12px; bottom: -1px;
  height: 2px;
  border-radius: 2px;
  background: var(--moon);
  transform: scaleX(0);
  transition: transform var(--dur) var(--ease-out);
}
.tab:hover { color: var(--text); }
.tab[aria-selected="true"] { color: var(--text); }
.tab[aria-selected="true"]::after { transform: scaleX(1); }
.tab:focus-visible { outline-offset: -2px; border-radius: var(--radius-sm); }
.tab-state {
  padding: 2px 8px;
  border-radius: 6px;
  background: var(--night-800);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-subtle);
  transition: background-color var(--dur) var(--ease-out), color var(--dur) var(--ease-out);
}
.tab-state.is-on { background: var(--moon-soft); color: var(--moon); }

.greet-panel { display: grid; gap: 20px; }
.greet-top { max-width: 640px; }
.greet-body { display: grid; gap: 20px; }
.greet-body.is-off { display: none; }
.greet-settings {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 20px 24px;
}
.greet-settings .select { max-width: none; }

/* ---------- segmented control (radio group) ---------- */
.segmented-field { margin: 0; padding: 0; border: 0; min-width: 0; }
.segmented-field legend { padding: 0; margin-bottom: 10px; }
.segmented {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--night-900);
}
.segment { position: relative; }
.segment input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.segment-face {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 0 14px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: background-color var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
}
.segment-face .icon { width: 17px; height: 17px; }
.segment:hover .segment-face { background: var(--night-800); color: var(--text); }
.segment input:checked + .segment-face { background: var(--moon); color: var(--moon-ink); }
.segment input:focus-visible + .segment-face { outline: 2px solid var(--moon); outline-offset: 2px; }

/* ---------- editor + preview ---------- */
.greet-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 28px;
  align-items: start;
}
.greet-editor { min-width: 0; }
.mode-panel { display: grid; gap: 20px; animation: fade-in var(--dur) var(--ease-out); }
.greet-preview {
  position: sticky;
  top: 88px;
  display: grid;
  gap: 10px;
  min-width: 0;
}
.preview-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.preview-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-subtle);
}
.preview-label .icon { width: 16px; height: 16px; color: var(--moon); }
.preview-note { font-size: 13px; color: var(--text-subtle); }
.preview-tip { font-size: 13px; color: var(--text-subtle); }
.preview-tip code {
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--night-800);
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--moon);
}

/* ---------- text inputs ---------- */
.input,
.tf-box input,
.tf-box textarea {
  display: block;
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--night-800);
  color: var(--text);
  font: 400 15px/1.5 var(--font-sans);
  transition: border-color var(--dur-fast) var(--ease-out), background-color var(--dur-fast) var(--ease-out);
}
.input--mono { font-family: var(--font-mono); font-size: 14px; }
.tf-box textarea { resize: vertical; min-height: 48px; }
.input::placeholder, .tf-box input::placeholder, .tf-box textarea::placeholder { color: var(--text-subtle); }
.input:hover, .tf-box input:hover, .tf-box textarea:hover { border-color: #245a7a; }
.input:focus, .tf-box input:focus, .tf-box textarea:focus {
  outline: none;
  border-color: var(--moon-line);
  background: var(--night-750);
}
.input:focus-visible, .tf-box input:focus-visible, .tf-box textarea:focus-visible {
  outline: 2px solid var(--moon);
  outline-offset: 2px;
}
[aria-invalid="true"].input, .tf-box [aria-invalid="true"] { border-color: var(--danger-line); }

/* token field */
.tf-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.tf-counter {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-subtle);
  font-variant-numeric: tabular-nums;
  transition: color var(--dur-fast);
}
.tf-counter.is-near { color: var(--moon); }
.tf-counter.is-over { color: var(--danger); }
.tf-box { position: relative; margin-top: 4px; }
/* insert buttons sit inside the field: discreet until hover/focus, no layout shift */
.tf-box > input[data-tokens] { padding-right: 116px; }
.tf-box > input[data-tokens="url"] { padding-right: 52px; }
.tf-box > textarea[data-tokens] { padding-bottom: 44px; }
.tf-toolbar {
  position: absolute;
  right: 7px;
  bottom: 7px;
  display: flex;
  gap: 3px;
  opacity: 0.6;
  transition: opacity var(--dur-fast) var(--ease-out);
}
.tf-box > input ~ .tf-toolbar { top: 50%; bottom: auto; transform: translateY(-50%); }
.tf-box:hover .tf-toolbar, .tf-box:focus-within .tf-toolbar { opacity: 1; }
.tf-btn {
  display: inline-grid;
  place-items: center;
  min-width: 32px;
  height: 30px;
  padding: 0 7px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: var(--night-750);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: border-color var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out), background-color var(--dur-fast) var(--ease-out);
}
.tf-btn--sigil { color: var(--moon); }
.tf-btn:hover { border-color: var(--moon-line); background: var(--moon-soft); color: var(--text); }
.tf-btn:focus-visible { outline: 2px solid var(--moon); outline-offset: 1px; }
@media (hover: none) { .tf-toolbar { opacity: 1; } }

/* token suggestions (shares .popover / .option) */
.popover--tokens { width: min(360px, 100%); max-width: 100%; }
.token-group {
  padding: 8px 10px 4px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-subtle);
}
.option .token-code { font-family: var(--font-mono); font-size: 13.5px; color: var(--moon); white-space: nowrap; }
.option .token-desc { margin-left: auto; padding-left: 12px; font-size: 13px; color: var(--text-subtle); text-align: right; }
.option.is-active .token-desc { color: var(--text-muted); }

/* ---------- checkbox ---------- */
.check {
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: start;
  gap: 12px;
  margin: -6px -10px;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background-color var(--dur-fast) var(--ease-out);
}
.check-input { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; }
.check-box {
  display: grid;
  place-items: center;
  width: 20px; height: 20px;
  margin-top: 1px;
  border: 1.5px solid var(--line);
  border-radius: 6px;
  background: var(--night-800);
  color: var(--moon-ink);
  transition: background-color var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out);
}
.check-box .icon { width: 14px; height: 14px; stroke-width: 3; opacity: 0; transform: scale(0.6); transition: opacity var(--dur-fast), transform var(--dur) var(--ease-out); }
.check-text { display: grid; gap: 2px; }
.check-label { font-size: 15px; color: var(--text-muted); transition: color var(--dur-fast) var(--ease-out); }
.check-help { font-size: 13px; color: var(--text-subtle); }
.check:hover { background: var(--night-900); }
.check:hover .check-label { color: var(--text); }
.check:hover .check-box { border-color: var(--moon-line); }
.check-input:checked + .check-box { background: var(--moon); border-color: var(--moon); }
.check-input:checked + .check-box .icon { opacity: 1; transform: none; }
.check-input:checked ~ .check-text .check-label { color: var(--text); }
.check-input:focus-visible + .check-box { outline: 2px solid var(--moon); outline-offset: 2px; }
.check:has(.check-input:disabled) { opacity: 0.45; cursor: not-allowed; }
.check-row { display: flex; flex-wrap: wrap; gap: 8px 28px; padding-left: 10px; }
.tf + .check { margin-top: -10px; }

.field-row { display: grid; grid-template-columns: minmax(0, 200px) minmax(0, 1fr); gap: 16px; }
.color-input { display: flex; gap: 8px; margin-top: 4px; }
.color-input input[type="color"] {
  flex: none;
  width: 46px; height: 46px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--night-800);
  cursor: pointer;
}
.color-input input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
.color-input input[type="color"]::-webkit-color-swatch { border: 0; border-radius: 6px; }
.color-input input[type="color"]:hover { border-color: var(--moon-line); }

/* ---------- embed fields editor ---------- */
.ef-list { display: grid; gap: 10px; margin-top: 6px; }
.ef-list:empty { display: none; }
.ef-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px 10px;
  padding: 12px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: var(--night-900);
  animation: role-in var(--dur) var(--ease-out);
}
.ef-item.is-leaving { animation: role-out var(--dur-fast) var(--ease-in) forwards; }
.ef-inputs { display: grid; gap: 8px; min-width: 0; }
.ef-item .tf-box { margin-top: 0; }
.ef-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; grid-column: 1 / -1; }
.ef-index { font-family: var(--font-mono); font-size: 12px; color: var(--text-subtle); }
.embed-fields > .btn { justify-self: start; margin-top: 8px; }

/* ---------- background dropzone ---------- */
.dropzone {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  gap: 16px;
  align-items: center;
  margin-top: 6px;
  padding: 12px;
  border: 1px dashed var(--line);
  border-radius: var(--radius-lg);
  background: var(--night-900);
  transition: border-color var(--dur-fast) var(--ease-out), background-color var(--dur-fast) var(--ease-out);
}
.dropzone.is-dragover { border-color: var(--moon); border-style: solid; background: var(--moon-soft); }
.dropzone-thumb {
  width: 100%;
  height: auto;
  aspect-ratio: 1024 / 420;
  object-fit: cover;
  border-radius: var(--radius-sm);
  background: var(--night-800);
}
.dropzone-body { display: grid; gap: 8px; min-width: 0; }
.dropzone-state { font-weight: 500; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dropzone-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.dropzone-hint { font-size: 13px; color: var(--text-subtle); }
.file-btn { position: relative; }
.file-input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }
.file-btn:has(.file-input:focus-visible) { outline: 2px solid var(--moon); outline-offset: 2px; }

/* ---------- range ---------- */
.range {
  width: 100%;
  max-width: 420px;
  height: 28px;
  margin: 4px 0 0;
  background: transparent;
  accent-color: var(--moon);
  cursor: pointer;
}
.range::-webkit-slider-runnable-track { height: 6px; border-radius: 6px; background: var(--night-750); }
.range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px; height: 20px;
  margin-top: -7px;
  border: 3px solid var(--night-950);
  border-radius: 50%;
  background: var(--moon);
  transition: transform var(--dur-fast) var(--ease-out);
}
.range:hover::-webkit-slider-thumb { transform: scale(1.12); }
.range:focus-visible { outline: none; }
.range:focus-visible::-webkit-slider-thumb { outline: 2px solid var(--moon); outline-offset: 2px; }
.range::-moz-range-track { height: 6px; border-radius: 6px; background: var(--night-750); }
.range::-moz-range-thumb { width: 16px; height: 16px; border: 3px solid var(--night-950); border-radius: 50%; background: var(--moon); }

/* ---------- Discord message preview (Discord's own dark palette) ---------- */
.dc {
  --dc-bg: #313338;
  --dc-text: #dbdee1;
  --dc-muted: #949ba4;
  --dc-embed: #2b2d31;
  --dc-link: #00a8fc;
  min-height: 120px;
  padding: 16px 16px 18px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--dc-bg);
  color: var(--dc-text);
  font-family: "gg sans", "Noto Sans", "Fira Sans", sans-serif;
  font-size: 15px;
  line-height: 1.375;
  overflow: hidden;
}
.dc-noscript { color: var(--dc-muted); font-size: 14px; }
.dc-msg { display: grid; grid-template-columns: 40px minmax(0, 1fr); gap: 0 14px; }
.dc-avatar { width: 40px; height: 40px; border-radius: 50%; }
.dc-body { min-width: 0; }
.dc-head { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.dc-name { font-weight: 600; color: #f2f3f5; }
.dc-bot {
  padding: 0 4px;
  border-radius: 3px;
  background: #5865f2;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  line-height: 15px;
}
.dc-time { font-size: 12px; color: var(--dc-muted); }
.dc-content { margin-top: 2px; white-space: pre-wrap; overflow-wrap: anywhere; }
.dc-content:empty { display: none; }
.dc-empty { color: var(--dc-muted); font-style: italic; }
.dc strong { font-weight: 700; }
.dc code {
  padding: 0 3px;
  border-radius: 4px;
  background: #2b2d31;
  font-family: "Fira Code", Consolas, monospace;
  font-size: 85%;
}
.dc pre { margin: 6px 0 0; padding: 8px; border: 1px solid #1e1f22; border-radius: 4px; background: #2b2d31; white-space: pre-wrap; }
.dc pre code { padding: 0; background: none; }
.dc-quote { display: block; padding-left: 12px; border-left: 4px solid #4e5058; }
.dc-h1, .dc-h2, .dc-h3 { display: block; font-weight: 700; line-height: 1.25; margin: 4px 0 2px; color: #f2f3f5; }
.dc-h1 { font-size: 24px; } .dc-h2 { font-size: 20px; } .dc-h3 { font-size: 16px; }
.dc-sub { display: block; font-size: 13px; color: var(--dc-muted); }
.dc-spoiler { border-radius: 3px; background: #1e1f22; color: transparent; }
.dc-mention {
  padding: 0 2px;
  overflow-wrap: normal;
  word-break: keep-all;
  border-radius: 3px;
  background: rgba(88, 101, 242, 0.3);
  color: #c9cdfb;
  font-weight: 500;
}
.dc-mention--role { background: color-mix(in srgb, var(--mention-color, #5865f2) 18%, transparent); color: var(--mention-color, #c9cdfb); }
.dc-unknown {
  text-decoration: wavy underline var(--danger);
  text-underline-offset: 3px;
  color: var(--danger);
}

.dc-embed {
  display: grid;
  gap: 8px;
  max-width: 520px;
  margin-top: 6px;
  padding: 10px 16px 14px 12px;
  border-left: 4px solid var(--embed-color, #1e1f22);
  border-radius: 4px;
  background: var(--dc-embed);
  font-size: 14px;
}
.dc-embed-grid { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; }
.dc-embed-main { display: grid; gap: 6px; min-width: 0; }
.dc-author { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 14px; color: #f2f3f5; }
.dc-author img { width: 24px; height: 24px; border-radius: 50%; }
.dc-title { font-weight: 700; font-size: 16px; color: #f2f3f5; overflow-wrap: anywhere; }
.dc-title.is-link { color: var(--dc-link); }
.dc-desc { white-space: pre-wrap; overflow-wrap: anywhere; }
.dc-fields { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px 12px; margin-top: 2px; }
.dc-embed.has-thumb .dc-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.dc-field { grid-column: 1 / -1; min-width: 0; }
.dc-field.is-inline { grid-column: span 1; }
.dc-field-name { font-weight: 600; color: #f2f3f5; overflow-wrap: anywhere; }
.dc-field-value { white-space: pre-wrap; overflow-wrap: anywhere; }
.dc-thumb { width: 80px; height: 80px; border-radius: 4px; object-fit: cover; }
.dc-image { max-width: 100%; border-radius: 4px; }
.dc-image-ext {
  display: grid;
  place-items: center;
  min-height: 90px;
  padding: 10px;
  border: 1px dashed #4e5058;
  border-radius: 4px;
  color: var(--dc-muted);
  font-size: 13px;
  text-align: center;
  overflow-wrap: anywhere;
}
.dc-footer { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--dc-muted); }
.dc-footer img { width: 20px; height: 20px; border-radius: 50%; }
.dc-attachment { max-width: 520px; margin-top: 6px; border-radius: 8px; overflow: hidden; }

/* variables cheat sheet */
.var-help { border: 1px solid var(--line-soft); border-radius: var(--radius); background: var(--night-900); }
.var-help summary {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 12px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  list-style: none;
  border-radius: var(--radius);
  transition: color var(--dur-fast) var(--ease-out), background-color var(--dur-fast) var(--ease-out);
}
.var-help summary::-webkit-details-marker { display: none; }
.var-help summary:hover { color: var(--text); background: var(--night-850); }
.var-help-icon { width: 16px; height: 16px; transform: rotate(-90deg); transition: transform var(--dur) var(--ease-out); }
.var-help[open] .var-help-icon { transform: none; color: var(--moon); }
.var-list { display: grid; gap: 2px; margin: 0; padding: 4px 12px 12px; }
.var-row { display: grid; grid-template-columns: minmax(0, auto) minmax(0, 1fr); gap: 4px 14px; padding: 4px 0; border-top: 1px solid var(--line-soft); }
.var-row:first-child { border-top: 0; }
.var-row dt code { font-family: var(--font-mono); font-size: 13px; color: var(--moon); white-space: nowrap; }
.var-row dd { margin: 0; font-size: 13px; color: var(--text-muted); }
.var-note { color: var(--text-subtle); }

/* ---------- temp voice channels ---------- */
.tv-body { display: grid; gap: 24px; min-width: 0; }
.tv-body.is-off { display: none; }
.alert--warn { border-color: var(--moon-line); background: var(--moon-soft); }
.alert--warn > .icon { color: var(--moon); }
.alert-text { margin-top: 2px; font-size: 14px; color: var(--text-muted); }
.opt-hash .opt-icon { width: 14px; height: 14px; vertical-align: -2px; }

.tv-name { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 250px); gap: 16px 24px; align-items: start; }
.vc-preview { display: grid; gap: 8px; min-width: 0; }
/* a slice of Discord's channel list (Discord's own palette) */
.vc-list {
  display: grid;
  gap: 2px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: #2b2d31;
  font-family: "gg sans", "Noto Sans", "Fira Sans", sans-serif;
}
.vc-row {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  padding: 0 8px;
  border-radius: 6px;
  color: #949ba4;
  font-size: 15px;
  font-weight: 500;
}
.vc-row .icon { flex: none; width: 18px; height: 18px; }
.vc-row--new { background: #404249; color: #f2f3f5; }
.vc-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vc-member { display: flex; align-items: center; gap: 8px; min-height: 28px; padding: 0 8px 0 32px; color: #dbdee1; font-size: 14px; }
.vc-member img { width: 20px; height: 20px; border-radius: 50%; object-fit: cover; }

.tv-perms { margin: 0; padding: 0; border: 0; min-width: 0; }
.tv-perms legend { padding: 0; }
.tv-perm-list { display: grid; gap: 14px; margin-top: 8px; padding-left: 10px; }
.tv-perm { display: grid; gap: 4px; }
.tv-perm-warn { display: flex; align-items: flex-start; gap: 6px; padding-left: 32px; font-size: 13px; color: var(--moon); }
.tv-perm-warn .icon { flex: none; width: 14px; height: 14px; margin-top: 2px; }

@keyframes fade-in { from { opacity: 0; } }

@media (max-width: 1100px) {
  .tv-name { grid-template-columns: minmax(0, 1fr); }
  .greet-grid { grid-template-columns: minmax(0, 1fr); }
  .greet-preview { position: static; }
}
@media (max-width: 640px) {
  .greet-settings { grid-template-columns: minmax(0, 1fr); }
  .segmented { display: flex; }
  .segment { flex: 1; }
  .segment-face { justify-content: center; width: 100%; padding: 0 8px; }
  .field-row { grid-template-columns: minmax(0, 1fr); }
  .dropzone { grid-template-columns: minmax(0, 1fr); }
  .dc-fields { grid-template-columns: minmax(0, 1fr); }
  .dc-field.is-inline { grid-column: 1 / -1; }
  .tabs { overflow-x: auto; scrollbar-width: none; }
}

/* ==========================================================================
   Hover growth — transform only, so nothing around moves
   ========================================================================== */
.icon-btn, .add-btn, .tf-btn, .tab, .segment-face, .select, .switch-track, .check-box,
.guild-icon, .badge, .brand-logo, .dropzone-thumb, .toast-action,
.color-input input[type="color"], .var-help-icon {
  transition-property: background-color, border-color, color, box-shadow, opacity, transform;
  transition-duration: var(--dur);
  transition-timing-function: var(--ease-out);
}
.btn:hover:not(:disabled):not([aria-disabled="true"]) { transform: scale(var(--grow-sm)); }
.btn:active:not(:disabled):not([aria-disabled="true"]) { transform: scale(0.97); transition-duration: 80ms; }
.icon-btn:hover { transform: scale(var(--grow-md)); }
.add-btn:hover:not([aria-disabled="true"]), .add-btn[aria-expanded="true"] { transform: scale(var(--grow-md)); }
.tf-btn:hover { transform: scale(var(--grow-md)); }
.tab:hover { transform: scale(var(--grow-sm)); }
.segment:hover .segment-face { transform: scale(var(--grow-sm)); }
.select:hover { transform: scale(var(--grow-xs)); }
.switch:hover .switch-track { transform: scale(var(--grow-md)); }
.check:hover .check-box { transform: scale(var(--grow-lg)); }
a.guild-row:hover .guild-icon { transform: scale(var(--grow-md)); }
a.guild-row:hover .badge { transform: scale(var(--grow-md)); }
.brand:hover .brand-logo { transform: scale(var(--grow-md)); }
.dropzone:hover .dropzone-thumb { transform: scale(var(--grow-sm)); }
.toast-action:hover { transform: scale(var(--grow-md)); }
.color-input input[type="color"]:hover { transform: scale(var(--grow-md)); }
.var-help summary:hover .var-help-icon { transform: rotate(-90deg) scale(var(--grow-lg)); }
.var-help[open] summary:hover .var-help-icon { transform: scale(var(--grow-lg)); }
/* role cards hold menus: no transform (it would trap them under the save bar), a light border instead */
.role-card:hover { border-color: rgba(242, 211, 107, 0.22); }

/* ==========================================================================
   Arrival animations
   early.js adds .js on <html> before the first paint (and removes it if
   dashboard.js never starts), dashboard.js reveals blocks as they scroll in.
   ========================================================================== */
/* (sections no longer slide in one by one: the page appears at once) */

/* elements rendered on page load don't play their entrance animation */
.no-enter { animation: none; }

/* ---------- animations ---------- */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fade-in { from { opacity: 0; } }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(-6px); } }
@keyframes pop-in { from { opacity: 0; transform: translateY(-4px) scale(0.98); } }
@keyframes role-in { from { opacity: 0; transform: translateY(8px); } }
@keyframes role-out { to { opacity: 0; transform: translateY(-4px); } }
@keyframes tag-in { from { opacity: 0; transform: scale(0.85); } }
@keyframes tag-out { to { opacity: 0; transform: scale(0.85); } }
@keyframes x-shake {
  0%, 100% { transform: translateX(0) rotate(0); }
  20% { transform: translateX(-1.5px) rotate(-8deg); }
  40% { transform: translateX(1.5px) rotate(8deg); }
  60% { transform: translateX(-1px) rotate(-4deg); }
  80% { transform: translateX(1px) rotate(4deg); }
}

@media (prefers-reduced-motion: reduce) {
  :root { --grow-xs: 1; --grow-sm: 1; --grow-md: 1; --grow-lg: 1; }
  .btn:active:not(:disabled):not([aria-disabled="true"]) { transform: none; }
  *, *::before, *::after {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
    scroll-behavior: auto !important;
  }
  .tag:hover, .tag:has(:focus-visible), .btn-primary:hover:not(:disabled),
  a.guild-row:hover .row-chevron, .select:hover .select-icon { transform: none; }
  .tag-remove:hover .icon, .skeleton { animation: none; }
}

/* ---------- responsive ---------- */
/* tablets and phones: the sidebar becomes a drawer opened from the top bar */
@media (max-width: 1023px) {
  :root { --gutter: 24px; }
  .menu-btn { display: inline-grid; margin-left: -6px; }
  .account-name { display: none; }
  .guild-layout { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed;
    top: 0; bottom: 0; left: 0;
    z-index: var(--z-drawer);
    width: min(330px, 88vw);
    height: 100dvh;
    padding-top: 16px;
    background: var(--night-900);
    box-shadow: 24px 0 60px -20px rgba(0, 0, 0, 0.8);
    transform: translateX(-102%);
    visibility: hidden;
    transition: transform var(--dur-slow) var(--ease-out), visibility 0s linear var(--dur-slow);
  }
  .sidebar.is-open { transform: none; visibility: visible; transition: transform var(--dur-slow) var(--ease-out); }
  .sidebar-close { display: inline-grid; flex: none; margin-top: 14px; }
  .drawer-backdrop {
    position: fixed;
    inset: 0;
    z-index: calc(var(--z-drawer) - 1);
    background: rgba(1, 12, 20, 0.6);
    backdrop-filter: blur(2px);
    animation: fade-in var(--dur) var(--ease-out);
  }
  .side-link { min-height: 46px; font-size: 14px; }
  .side-sub a { padding: 9px 10px; font-size: 13px; }
}
@media (min-width: 1024px) {
  .drawer-backdrop { display: none !important; }
}

@media (max-width: 640px) {
  :root { --gutter: 14px; --topbar-h: 56px; }
  body { font-size: 14px; }
  .topbar-inner { gap: 10px; padding: 0 12px; }
  .crumbs li:not(:last-child) { display: none; }
  .crumbs { padding-left: 10px; }
  .account-name, .account-avatar, .btn-label-optional { display: none; }
  .brand-name { display: none; }
  .page { padding: 28px 16px 64px; }
  .guild-layout > .config { padding-top: 22px; padding-bottom: 150px; }
  .page-head { margin-bottom: 18px; padding-bottom: 18px; }
  .settings-section { padding: 20px 16px; margin-bottom: 14px; border-radius: var(--radius-lg); gap: 16px; }
  h2 { font-size: 21px; }
  .guild-row { grid-template-columns: 44px minmax(0, 1fr) auto; gap: 12px; padding: 12px 14px; }
  .guild-row .badge { display: none; }
  .guild-row .guild-icon { width: 44px; height: 44px; }
  .select { max-width: none; }
  .toasts { top: auto; bottom: 16px; right: 12px; width: calc(100% - 24px); }
}

/* ==========================================================================
   One-time message composer
   ========================================================================== */
.compose { display: grid; gap: 20px; }
.composer .greet-settings .select { max-width: none; }
#error-slot .alert { margin-bottom: 24px; }
#error-slot:empty { display: none; }

.channel-warn { display: flex; align-items: flex-start; gap: 8px; margin-top: -8px; font-size: 14px; color: var(--moon); }
.channel-warn .icon { flex: none; width: 16px; height: 16px; margin-top: 2px; }
.channel-warn.is-blocking { color: var(--danger); }

/* ---------- attachments ---------- */
.attach-zone {
  display: grid;
  gap: 10px;
  margin-top: 6px;
  padding: 12px;
  border: 1px dashed var(--line);
  border-radius: var(--radius-lg);
  background: var(--night-900);
  transition: border-color var(--dur-fast) var(--ease-out);
}
.attach-zone.has-files { border-style: solid; border-color: var(--line-soft); }
.attach-zone:hover { border-color: var(--moon-line); }
.attach-list { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; container-type: inline-size; }
.attach-list:empty { display: none; }
.attach-item {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr) auto;
  grid-template-areas: "thumb info actions" "thumb alt alt";
  gap: 6px 12px;
  align-items: center;
  padding: 8px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: var(--night-850);
  transition: border-color var(--dur) var(--ease-out);
  animation: role-in var(--dur) var(--ease-out);
}
.attach-item.is-embed { border-color: var(--moon-line); }
.attach-item.is-leaving { animation: role-out var(--dur-fast) var(--ease-in) forwards; pointer-events: none; }
.attach-thumb {
  grid-area: thumb;
  position: relative;
  align-self: start;
  width: 72px; height: 72px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--night-800);
}
.attach-thumb img { width: 100%; height: 100%; object-fit: cover; transition: filter var(--dur) var(--ease-out), transform var(--dur) var(--ease-out); }
.attach-thumb.is-spoiler img { filter: blur(8px) brightness(0.7); transform: scale(1.15); }
.attach-badge {
  position: absolute;
  left: 4px; bottom: 4px;
  padding: 0 5px;
  border-radius: 4px;
  background: rgba(1, 20, 31, 0.85);
  font: 500 11px/18px var(--font-mono);
  color: var(--text);
}
.attach-main { display: contents; }
.attach-name, .attach-meta { grid-area: info; min-width: 0; }
.attach-name { align-self: start; padding-top: 2px; font-weight: 500; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attach-meta { align-self: end; padding-bottom: 2px; font-size: 12px; color: var(--text-subtle); font-variant-numeric: tabular-nums; }
.attach-item { grid-template-rows: 40px auto; }
.attach-alt { grid-area: alt; }
.input--sm { padding: 7px 10px; font-size: 14px; }
.attach-actions { grid-area: actions; display: flex; align-items: center; gap: 6px; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--night-800);
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out), transform var(--dur) var(--ease-out);
}
.chip .icon { width: 16px; height: 16px; }
.chip:hover:not(:disabled) { border-color: var(--moon-line); color: var(--text); transform: scale(var(--grow-sm)); }
.chip[aria-pressed="true"] { background: var(--moon-soft); border-color: var(--moon-line); color: var(--moon); }
.chip:disabled { opacity: 0.4; cursor: not-allowed; }
/* narrow column: icon-only chips (their label stays in aria-label) */
@container (max-width: 470px) {
  .chip { width: 32px; padding: 0; justify-content: center; }
  .chip span { display: none; }
}

.attach-empty { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.attach-hint { font-size: 13px; color: var(--text-subtle); }
.kbd {
  display: inline-block;
  min-width: 20px;
  padding: 0 5px;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: var(--night-800);
  font: 500 11px/17px var(--font-mono);
  color: var(--text-muted);
  text-align: center;
}
.kbd--on-moon { margin-left: 2px; border-color: rgba(16, 32, 44, 0.25); background: rgba(16, 32, 44, 0.08); color: var(--moon-ink); }
@media (hover: none) { .kbd--on-moon { display: none; } }

/* drop anywhere */
.drop-overlay {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(1, 20, 31, 0.84);
  animation: fade-in var(--dur) var(--ease-out);
}
.drop-overlay * { pointer-events: none; }
.drop-card {
  display: grid;
  justify-items: center;
  gap: 6px;
  padding: 40px 56px;
  border: 2px dashed var(--moon);
  border-radius: 20px;
  background: var(--night-900);
  text-align: center;
}
.drop-card .icon { width: 40px; height: 40px; margin-bottom: 6px; color: var(--moon); animation: drop-bob 900ms var(--ease-out) infinite alternate; }
.drop-card p { font-family: var(--font-display); font-style: italic; font-size: 24px; font-weight: 700; }
.drop-card span { font-size: 14px; color: var(--text-muted); }
@keyframes drop-bob { to { transform: translateY(-6px); } }

/* ---------- delivery options ---------- */
.send-options { margin: 0; padding: 0; border: 0; min-width: 0; }
.send-options legend { padding: 0; }
.send-option-list { display: grid; gap: 14px; margin-top: 10px; padding-left: 10px; }

/* ---------- preview: images under the message ---------- */
.dc-gallery { display: grid; gap: 4px; max-width: 520px; margin-top: 6px; border-radius: 8px; overflow: hidden; }
.dc-gallery--2, .dc-gallery--4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.dc-gallery--3, .dc-gallery--5 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.dc-gallery-item { position: relative; overflow: hidden; aspect-ratio: 1; background: #2b2d31; }
.dc-gallery-item img { width: 100%; height: 100%; object-fit: cover; }
.dc-gallery--1 { justify-items: start; max-width: 400px; }
.dc-gallery--1 .dc-gallery-item { aspect-ratio: auto; border-radius: 8px; }
.dc-gallery--1 .dc-gallery-item img { width: auto; height: auto; max-width: 100%; max-height: 350px; }
.dc-gallery-item.is-spoiler img { filter: blur(40px) brightness(0.8); transform: scale(1.2); }
.dc-spoiler-tag {
  position: absolute;
  top: 50%; left: 50%;
  translate: -50% -50%;
  padding: 4px 12px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
}
.dc-silent { display: flex; align-items: center; gap: 6px; margin-top: 6px; font-size: 12px; color: var(--dc-muted); }
.dc-silent .icon { width: 14px; height: 14px; }

/* ---------- sent this session ---------- */
.sent-log {
  margin-bottom: 24px;
  padding: 10px 12px 10px 16px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-lg);
  background: var(--night-900);
}
.sent-log-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.sent-log-title {
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-subtle);
}
.sent-list { display: grid; gap: 2px; margin: 4px 0 0; padding: 0; list-style: none; }
.sent-item { display: flex; align-items: center; gap: 10px; min-height: 44px; animation: role-in var(--dur-slow) var(--ease-out); }
.sent-mark { display: grid; flex: none; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--ok-soft); color: var(--ok); }
.sent-mark .icon { width: 14px; height: 14px; stroke-width: 3; }
.sent-text { flex: 1; min-width: 0; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sent-channel { font-weight: 600; }
.sent-time { color: var(--text-muted); }
.sent-open { flex: none; }
.sent-open .icon { width: 16px; height: 16px; }

/* ---------- send bar ---------- */
.sendbar { border-color: var(--line); transition: border-color var(--dur) var(--ease-out); }
.sendbar .savebar-dot { background: var(--text-subtle); transition: background-color var(--dur) var(--ease-out); }
.sendbar.is-ready { border-color: var(--moon-line); }
.sendbar.is-ready .savebar-dot { background: var(--moon); }
.sendbar .savebar-status span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.send-icon { width: 17px !important; height: 17px !important; transition: transform var(--dur) var(--ease-out); }
.btn-primary:hover:not(:disabled) .send-icon { transform: translate(2px, -2px); }
.btn.is-loading .send-icon, .btn.is-loading .kbd { display: none; }
.btn.is-confirm { background: var(--danger); color: #2a0d0b; animation: confirm-pulse 900ms var(--ease-out) 2; }
.btn.is-confirm:hover:not(:disabled) { background: #ffa59d; }
.btn.is-confirm .kbd { border-color: rgba(42, 13, 11, 0.3); color: #2a0d0b; }
@keyframes confirm-pulse { 50% { box-shadow: 0 0 0 6px var(--danger-soft); } }

@media (max-width: 640px) {
  .attach-item { grid-template-columns: 56px minmax(0, 1fr); grid-template-areas: "thumb info" "thumb actions" "alt alt"; grid-template-rows: auto auto auto; }
  .attach-thumb { width: 56px; height: 56px; }
  .attach-name { align-self: end; }
  .attach-actions { justify-content: flex-start; }
  .attach-meta { display: none; }
  .sent-open span { display: none; }
  .sendbar .savebar-status { font-size: 13px; }
  .sendbar #send-btn { padding: 0 14px; }
}
.composer .greet-editor { display: grid; gap: 28px; align-content: start; }
@media (max-width: 640px) {
  .sendbar .savebar-status span:last-child {
    white-space: normal;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
  }
}

/* ---------- mentions by ID, image links ---------- */
.dc-mention.is-pending { opacity: 0.6; }
.dc-thumb--broken { display: grid; place-items: center; border: 1px dashed #4e5058; color: var(--dc-muted); }
.dc-thumb--broken .icon { width: 24px; height: 24px; }
.dc-embed .dc-image { max-height: 400px; object-fit: contain; justify-self: start; }
.var-tip { padding: 0 12px 12px; font-size: 12.5px; color: var(--text-subtle); }

/* ==========================================================================
   Roles by XP level (tiers)
   ========================================================================== */
.tier-list { position: relative; display: grid; gap: 10px; margin: 6px 0 0; padding: 0; list-style: none; }
/* the ladder: a rail linking the tiers, brighter towards the top levels */
.tier-list::before {
  content: "";
  position: absolute;
  left: 7px; top: 28px; bottom: 28px;
  width: 2px;
  border-radius: 2px;
  background: linear-gradient(var(--line), var(--moon-line));
}
.tier {
  position: relative;
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr) auto;
  grid-template-areas: "level arrow role remove" "hint hint hint hint" "warn warn warn warn";
  align-items: center;
  gap: 6px 10px;
  margin-left: 26px;
  padding: 10px 10px 10px 12px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: var(--night-900);
  transition: border-color var(--dur) var(--ease-out);
  animation: role-in var(--dur) var(--ease-out);
}
.tier:hover { border-color: rgba(242, 211, 107, 0.22); }
.tier.has-warning { border-color: var(--moon-line); }
.tier.is-leaving { animation: role-out var(--dur-fast) var(--ease-in) forwards; pointer-events: none; }
.tier-node {
  position: absolute;
  left: -26px; top: 24px;
  width: 16px; height: 16px;
  border: 2px solid var(--line);
  border-radius: 50%;
  background: var(--night-950);
  transition: border-color var(--dur) var(--ease-out), background-color var(--dur) var(--ease-out), transform var(--dur) var(--ease-out);
}
.tier.has-role .tier-node {
  border-color: var(--role-color, var(--moon));
  background: color-mix(in srgb, var(--role-color, var(--moon)) 35%, var(--night-950));
}
.tier:focus-within .tier-node { transform: scale(var(--grow-lg)); }

.tier-level {
  grid-area: level;
  display: flex;
  align-items: center;
  padding-left: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--night-800);
  cursor: text;
  transition: border-color var(--dur-fast) var(--ease-out), background-color var(--dur-fast) var(--ease-out);
}
.tier-level:hover { border-color: #245a7a; }
.tier-level:focus-within { border-color: var(--moon-line); background: var(--night-750); outline: 2px solid var(--moon); outline-offset: 2px; }
.tier-prefix { font-size: 12px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-subtle); }
.tier-input {
  width: 64px;
  min-height: 44px;
  padding: 0 10px 0 6px;
  border: 0;
  background: transparent;
  color: var(--moon);
  font: 500 18px var(--font-mono);
  text-align: center;
  -moz-appearance: textfield;
  appearance: textfield;
}
.tier-input::-webkit-outer-spin-button, .tier-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.tier-input:focus { outline: none; }
.tier-arrow { grid-area: arrow; display: grid; color: var(--text-subtle); }
.tier-arrow .icon { width: 18px; height: 18px; }
.tier:focus-within .tier-arrow { color: var(--moon); }
.select.tier-role { grid-area: role; margin-top: 0; max-width: none; }
.tier-remove { grid-area: remove; }
.tier-hint { grid-area: hint; padding-left: 2px; font-size: 12.5px; color: var(--text-subtle); font-variant-numeric: tabular-nums; }
.tier-hint:empty { display: none; }
.tier-warn { grid-area: warn; display: flex; align-items: flex-start; gap: 6px; font-size: 13px; color: var(--moon); }
.tier-warn .icon { flex: none; width: 14px; height: 14px; margin-top: 3px; }
.select option .role-dot { width: 10px; height: 10px; margin-right: 8px; box-shadow: none; }

.tier-empty {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 6px;
  padding: 14px 16px;
  border: 1px dashed var(--line);
  border-radius: var(--radius-lg);
  background: var(--night-900);
}
.tier-empty-mark { display: grid; flex: none; place-items: center; width: 40px; height: 40px; border-radius: 50%; background: var(--moon-soft); color: var(--moon); }
.tier-empty-mark .icon { width: 20px; height: 20px; }
.tier-empty-title { font-weight: 600; }
.tier-empty-text { font-size: 14px; color: var(--text-muted); }
.tier-add { justify-self: start; margin-top: 8px; }
.tier-preview { display: grid; gap: 8px; margin-top: 14px; }
.dc--compact { min-height: 0; padding: 12px 14px 12px 10px; }
.tiers .alert { margin: 6px 0 4px; }

@media (max-width: 640px) {
  .tier {
    grid-template-columns: auto minmax(0, 1fr) auto;
    grid-template-areas: "level . remove" "role role role" "hint hint hint" "warn warn warn";
  }
  .tier-arrow { display: none; }
}

/* ---------- level-up announcements ---------- */
.levelup-msg { display: grid; gap: 6px; }
.tier-default-msg { margin-top: 18px; }
.announce-tools { display: flex; justify-content: flex-end; min-height: 0; }
.announce-tools:not(:has(:not([hidden]))) { display: none; }
.link-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  padding: 0 8px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: color var(--dur-fast) var(--ease-out), background-color var(--dur-fast) var(--ease-out);
}
.link-btn .icon { width: 14px; height: 14px; transform: rotate(45deg); }
.link-btn:hover { background: var(--night-850); color: var(--moon); }
.levelup-msg .tier-preview { margin-top: 4px; }

.tier { grid-template-areas: "level arrow role remove" "foot foot foot foot" "msg msg msg msg" "warn warn warn warn"; }
.tier-foot { grid-area: foot; display: flex; align-items: center; justify-content: space-between; gap: 8px 12px; flex-wrap: wrap; }
.tier-foot .tier-hint { grid-area: auto; }
.tier-msg-toggle { height: 30px; font-size: 12.5px; }
.tier-msg { grid-area: msg; margin-top: 4px; animation: fade-in var(--dur) var(--ease-out); }
.tier-msg .field-label { font-size: 14px; }
.tier-msg .tf-box { margin-top: 2px; }
@media (max-width: 640px) {
  .tier { grid-template-areas: "level . remove" "role role role" "foot foot foot" "msg msg msg" "warn warn warn"; }
}

/* ==========================================================================
   Reaction roles
   ========================================================================== */
.rr-page > .alert { margin-bottom: 24px; }
.rr-count {
  display: inline-grid;
  place-items: center;
  min-width: 26px;
  height: 26px;
  margin-left: 6px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--night-800);
  color: var(--text-muted);
  font: 600 13px/1 var(--font-sans);
  vertical-align: 3px;
}
.rr-list { display: grid; gap: 14px; }
.rr-card {
  display: grid;
  gap: 14px;
  padding: 16px 18px 18px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-lg);
  background: var(--night-900);
  box-shadow: var(--shadow-surface);
  scroll-margin-top: 100px;
}
.rr-card:target { border-color: var(--moon-line); }
.rr-head { display: flex; align-items: center; justify-content: space-between; gap: 10px 16px; flex-wrap: wrap; }
.rr-where { display: flex; align-items: center; gap: 8px 12px; flex-wrap: wrap; min-width: 0; }
.rr-title { font: 600 16px/1.3 var(--font-sans); overflow-wrap: anywhere; }
.rr-hash { margin-right: 2px; color: var(--text-subtle); }
.rr-jump .icon { transform: none; }
.rr-delete { display: flex; align-items: center; gap: 4px 10px; flex-wrap: wrap; }
.rr-inline-check { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-muted); cursor: pointer; }
.rr-inline-check input { width: 16px; height: 16px; accent-color: var(--moon); }
.rr-danger:hover:not(:disabled) { background: var(--danger-soft); color: var(--danger); }
.rr-excerpt {
  padding: 10px 14px;
  border-left: 3px solid var(--line);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  background: var(--night-850);
  color: var(--text-muted);
  font-size: 14px;
  white-space: pre-line;
  overflow-wrap: anywhere;
}
.rr-warn, .rr-pair-warn { display: flex; align-items: flex-start; gap: 8px; font-size: 13px; color: var(--moon); }
.rr-warn .icon, .rr-pair-warn .icon { flex: none; width: 16px; height: 16px; margin-top: 1px; }
.rr-pairs { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; padding: 0; list-style: none; }
.rr-pair {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 4px 0 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--night-800);
  font-size: 14px;
}
.rr-pair.has-problem { flex-wrap: wrap; border-color: var(--moon-line); padding-top: 4px; padding-bottom: 4px; }
.rr-pair.has-problem .rr-pair-warn { order: 9; flex-basis: 100%; padding-bottom: 4px; }
.rr-emoji { display: inline-grid; place-items: center; min-width: 24px; font-size: 20px; line-height: 1; }
.rr-emoji img { width: 22px; height: 22px; object-fit: contain; }
.rr-arrow { display: inline-grid; color: var(--text-subtle); }
.rr-arrow .icon { width: 16px; height: 16px; }
.rr-role { font-weight: 600; overflow-wrap: anywhere; }
.rr-pair-remove { display: inline-flex; }
.rr-none { font-size: 14px; color: var(--text-muted); }
.rr-add-pair, .rr-row {
  display: grid;
  grid-template-columns: 112px auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px 10px;
}
.rr-add-pair .select, .rr-row .select { max-width: none; margin-top: 0; }
.rr-emoji-input { text-align: center; font-size: 17px; }
.rr-text summary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 0 10px;
  margin-left: -10px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  list-style: none;
}
.rr-text summary::-webkit-details-marker { display: none; }
.rr-text summary:hover { background: var(--night-850); color: var(--text); }
.rr-text summary .icon { width: 16px; height: 16px; }
.rr-auto { padding: 2px 8px; border-radius: 999px; background: var(--moon-soft); color: var(--moon); font-size: 12px; }
.rr-text-form { display: grid; gap: 6px; margin-top: 8px; }
.rr-text-form textarea, .rr-create textarea { resize: vertical; min-height: 96px; }
.rr-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
.rr-optional { margin-left: 6px; color: var(--text-subtle); font-size: 13px; font-weight: 400; }
.rr-pairs-field { margin: 0; padding: 0; border: 0; min-width: 0; }
.rr-pairs-field legend { padding: 0; margin-bottom: 6px; }
.rr-pairs-field code, .rr-page .empty-text code { font-family: var(--font-mono); font-size: 13px; color: var(--moon); }
.rr-rows { display: grid; gap: 8px; margin: 6px 0 0; padding: 0; list-style: none; }
.rr-add-row { justify-self: start; margin-top: 4px; }

@media (max-width: 640px) {
  .rr-add-pair, .rr-row { grid-template-columns: 84px minmax(0, 1fr) auto; }
  .rr-add-pair .rr-arrow, .rr-row .rr-arrow { display: none; }
  .rr-add-pair .btn { grid-column: 1 / -1; }
  .rr-card { padding: 14px; }
}
.rr-emoji-input::placeholder { opacity: 0.4; }


/* ==========================================================================
   Forbidden words
   ========================================================================== */
.wf-page > .alert { margin-bottom: 24px; }
.wf-variants { font-family: var(--font-mono); font-size: 0.9em; color: var(--text); }
.wf-variants span { white-space: nowrap; }
.wf-page code { font-family: var(--font-mono); font-size: 13px; color: var(--moon); }
.wf-actions { display: flex; justify-content: flex-end; }
.wf-test-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; }
.wf-result--ok { border-color: rgba(127, 217, 174, 0.45); background: var(--ok-soft); }
.wf-result--ok > .icon { color: var(--ok); }
.wf-result > .icon { flex: none; }
.wf-result code { overflow-wrap: anywhere; }
.wf-add { display: grid; gap: 10px; margin-bottom: 8px; }
.wf-add textarea { resize: vertical; min-height: 84px; }
.wf-list { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.wf-word {
  display: grid;
  gap: 8px;
  padding: 10px 12px 12px 16px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-lg);
  background: var(--night-900);
}
.wf-word-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.wf-term { font: 500 15px/1.4 var(--font-mono); overflow-wrap: anywhere; }
.wf-exempt { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 8px; }
.wf-exempt-label { font-size: 13px; color: var(--text-muted); }
.wf-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 30px;
  padding: 0 4px 0 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--night-800);
  font-size: 13px;
  font-weight: 600;
}
.wf-chip .tag-remove { width: 24px; height: 24px; opacity: 0.75; transform: none; }
.wf-chip .tag-remove:hover, .wf-chip .tag-remove:focus-visible { opacity: 1; }
.wf-chip:has(.tag-remove:hover) { border-color: var(--danger-line); }
.wf-exempt-add { display: inline-flex; align-items: center; gap: 6px; margin-left: auto; }
.wf-exempt-add .select { margin-top: 0; min-width: 210px; }
.wf-exempt-add .select select { min-height: 34px; font-size: 14px; }
@media (max-width: 640px) {
  .wf-exempt-add { margin-left: 0; width: 100%; }
  .wf-exempt-add .select { flex: 1; min-width: 0; }
  .wf-test-row { grid-template-columns: minmax(0, 1fr); }
}

/* ---------- ready-made lists ---------- */
.wf-presets {
  display: grid;
  gap: 12px;
  margin: 8px 0 16px;
  padding: 16px 18px 18px;
  border: 1px solid var(--moon-line);
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, var(--moon-soft), transparent 70%), var(--night-900);
  scroll-margin-top: 100px;
}
.wf-presets-head { display: grid; gap: 4px; }
.wf-presets-title { display: flex; align-items: center; gap: 8px; font: 600 16px/1.3 var(--font-sans); }
.wf-presets-title .icon { width: 18px; height: 18px; color: var(--moon); }
.wf-preset-form { display: grid; gap: 10px; }
.wf-preset-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 8px; margin: 0; padding: 0; list-style: none; }
.wf-preset {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: var(--night-850);
}
.wf-preset.is-added { border-color: var(--line); }
.wf-preset-check { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; min-width: 0; }
span.wf-preset-check { cursor: default; }
.wf-preset-check input { flex: none; width: 17px; height: 17px; margin-top: 2px; accent-color: var(--moon); }
.wf-preset-done { display: grid; flex: none; place-items: center; width: 18px; height: 18px; margin-top: 1px; border-radius: 50%; background: var(--ok-soft); color: var(--ok); }
.wf-preset-done .icon { width: 12px; height: 12px; stroke-width: 3; }
.wf-preset-text { display: grid; gap: 2px; min-width: 0; }
.wf-preset-name { font-weight: 600; font-size: 14px; }
.wf-preset-note { margin-left: 4px; color: var(--text-subtle); font-weight: 400; font-size: 12px; }
.wf-preset-desc { font-size: 13px; color: var(--text-muted); }
.wf-preset .badge { flex: none; }
.wf-group-title { display: flex; align-items: center; gap: 4px; margin: 8px 0 2px; font: 600 15px/1.3 var(--font-sans); }
.wf-group { border: 1px solid var(--line-soft); border-radius: var(--radius-lg); background: var(--night-900); }
.wf-group + .wf-group, .wf-list + .wf-group { margin-top: 8px; }
.wf-group summary {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 14px;
  border-radius: var(--radius-lg);
  font-weight: 600;
  cursor: pointer;
  list-style: none;
}
.wf-group summary::-webkit-details-marker { display: none; }
.wf-group summary:hover { background: var(--night-850); }
.wf-group-chevron { width: 16px; height: 16px; color: var(--text-subtle); transition: transform var(--dur) var(--ease-out); }
.wf-group[open] .wf-group-chevron { transform: rotate(90deg); }
.wf-group-hint { margin-left: auto; color: var(--text-subtle); font-size: 13px; font-weight: 400; }
.wf-group-body { display: grid; gap: 10px; padding: 4px 12px 12px; }
.wf-group-remove { justify-self: end; }
.wf-group .wf-word { background: var(--night-850); }
.wf-preset-meta { margin-top: 2px; font-size: 12px; font-weight: 600; color: var(--text-subtle); }
.wf-preset-meta.is-done { color: var(--ok); }
.wf-exception { display: grid; gap: 4px; margin: 4px 0 8px; padding: 14px 16px; border: 1px solid var(--line-soft); border-radius: var(--radius-lg); background: var(--night-900); }
.wf-exception-row { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr) auto; align-items: center; gap: 10px; margin-top: 6px; }
.wf-exception-row .select { margin-top: 0; max-width: none; }
.wf-exception-verb { color: var(--text-muted); font-size: 14px; white-space: nowrap; }
@media (max-width: 640px) {
  .wf-exception-row { grid-template-columns: minmax(0, 1fr); }
  .wf-exception-verb { display: none; }
}
.wf-list { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
.wf-word { padding: 6px 6px 6px 14px; align-content: center; }
.wf-word:has(.wf-exempt) { grid-column: 1 / -1; padding-bottom: 10px; }
.wf-term { font-size: 14px; }

/* ---------- word groups ---------- */
.wf-add-foot { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 10px; }
.wf-add-group { display: inline-flex; align-items: center; gap: 8px; color: var(--text-muted); font-size: 14px; }
.wf-add-group .select { margin-top: 0; min-width: 220px; }
.wf-add-group .select select { min-height: 42px; }
.wf-groups-head { display: grid; gap: 2px; margin-top: 8px; }
.wf-slug { padding: 2px 8px; border-radius: 6px; background: var(--moon-soft); color: var(--moon); font: 500 13px/1.4 var(--font-mono); }
.wf-group-hint.is-quiet { color: var(--text-muted); font-style: italic; }
.wf-group-tools { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 4px; }
.wf-new-group { display: grid; gap: 8px; margin-top: 12px; padding: 14px 16px; border: 1px dashed var(--line); border-radius: var(--radius-lg); }
.wf-new-group-row { display: grid; grid-template-columns: minmax(0, 200px) minmax(0, 1fr) auto auto; align-items: center; gap: 10px; }
@media (max-width: 640px) {
  .wf-new-group-row { grid-template-columns: minmax(0, 1fr); }
  .wf-add-group { width: 100%; }
  .wf-add-group .select { flex: 1; min-width: 0; }
}

/* ==========================================================================
   Warnings
   ========================================================================== */
.wn-page > .alert { margin-bottom: 24px; }
.wn-page code, .as-page code { font-family: var(--font-mono); font-size: 13px; color: var(--moon); }
.wn-step { display: grid; gap: 10px; }
.wn-inline { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 14px; padding-left: 58px; color: var(--text-muted); font-size: 14px; }
.wn-inline label { display: inline-flex; align-items: center; gap: 8px; }
.wn-num { width: 74px; padding: 8px 10px; text-align: center; }
.wn-num--wide { width: 96px; }
.wn-top { display: grid; gap: 8px; margin-bottom: 12px; }
.wn-top-list { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; list-style: none; }
.wn-top-list a { display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 6px 0 8px; border: 1px solid var(--line); border-radius: 999px; background: var(--night-850); color: var(--text); text-decoration: none; font-size: 14px; }
.wn-top-list a:hover { border-color: var(--moon-line); }
.wn-who { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; }
.wn-who img { width: 22px; height: 22px; border-radius: 50%; }
.wn-who.is-gone { color: var(--text-muted); font-weight: 400; }
.wn-list { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.wn-item { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 12px 14px; border: 1px solid var(--line-soft); border-radius: var(--radius-lg); background: var(--night-900); }
.wn-item:target { border-color: var(--moon-line); }
.wn-item.is-revoked { opacity: 0.6; }
.wn-item.is-revoked .wn-reason { text-decoration: line-through; }
.wn-main { display: grid; gap: 4px; min-width: 0; }
.wn-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 12px; font-size: 13px; color: var(--text-muted); }
.wn-id { font-family: var(--font-mono); }
.wn-member { color: inherit; text-decoration: none; }
.wn-member:hover .wn-who span { text-decoration: underline; }
.wn-source { display: inline-flex; align-items: center; gap: 6px; padding: 2px 8px; border-radius: 999px; background: var(--night-800); font-weight: 600; }
.wn-source--wordfilter { background: var(--danger-soft); color: var(--danger); }
.wn-source--spam { background: var(--moon-soft); color: var(--moon); }
.wn-source code { font-size: 12px; color: inherit; }
.wn-reason { font-size: 15px; overflow-wrap: anywhere; }
.wn-by { font-size: 13px; color: var(--text-muted); }
.wn-revoke { flex: none; }
.wn-revoke summary { list-style: none; }
.wn-revoke summary::-webkit-details-marker { display: none; }
.wn-revoke[open] summary { display: none; }
.wn-revoke form { display: flex; gap: 6px; }
.wn-revoke .input { min-width: 220px; padding: 8px 10px; font-size: 14px; }
@media (max-width: 640px) {
  .wn-inline { padding-left: 0; }
  .wn-item { flex-direction: column; }
  .wn-revoke .input { min-width: 0; flex: 1; }
}

/* ==========================================================================
   Anti-spam
   ========================================================================== */
.as-page > .alert { margin-bottom: 24px; }
.as-numbers { padding-left: 0; }
.as-rules { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 380px), 1fr)); gap: 10px; }
.as-rule { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; border: 1px solid var(--line-soft); border-radius: var(--radius-lg); background: var(--night-900); cursor: pointer; }
.as-rule-text { display: grid; gap: 2px; min-width: 0; }
.as-rule-name { font-weight: 600; font-size: 14px; }
.as-rule-name code { margin-left: 4px; font-size: 12px; color: var(--text-subtle); }
.as-rule-help { font-size: 13px; color: var(--text-muted); }
.as-rule-value { display: grid; justify-items: center; gap: 2px; flex: none; }
.as-rule-default { font-size: 11px; color: var(--text-subtle); }
.as-rule-default.is-changed { color: var(--sakura); }
.as-exempt { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.as-box { margin: 0; padding: 12px 14px; border: 1px solid var(--line-soft); border-radius: var(--radius-lg); min-width: 0; }
.as-box legend { padding: 0 6px; }
.as-checks { display: grid; gap: 6px; max-height: 260px; overflow-y: auto; }
.as-save { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line-soft); }

/* ==========================================================================
   Birthdays
   ========================================================================== */
.bd-page > .alert { margin-bottom: 24px; }
.bd-page code { font-family: var(--font-mono); font-size: 13px; color: var(--moon); }
.bd-row { display: grid; grid-template-columns: minmax(0, 160px) minmax(0, 1fr); gap: 16px; }
.bd-row .select { max-width: none; }
.bd-page textarea { resize: vertical; min-height: 64px; }
.bd-preview { display: block; margin-top: 6px; padding: 10px 14px; border-left: 3px solid var(--moon-line); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; background: var(--night-850); font-size: 14px; overflow-wrap: anywhere; }
.bd-preview strong { font-weight: 700; color: var(--text); }
.bd-preview-label { display: block; margin-bottom: 4px; font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-subtle); }
.bd-add { display: grid; gap: 8px; margin-bottom: 14px; padding: 14px 16px; border: 1px dashed var(--line); border-radius: var(--radius-lg); }
.bd-add-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 220px) auto; align-items: start; gap: 10px; }
.bd-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 8px; margin: 0; padding: 0; list-style: none; }
.bd-item { display: flex; align-items: center; gap: 12px; padding: 8px 8px 8px 10px; border: 1px solid var(--line-soft); border-radius: var(--radius-lg); background: var(--night-900); }
.bd-item.is-today { border-color: var(--moon-line); background: linear-gradient(90deg, var(--moon-soft), transparent 70%), var(--night-900); }
.bd-date { display: grid; justify-items: center; flex: none; width: 46px; padding: 4px 0; border-radius: var(--radius-sm); background: var(--night-800); line-height: 1.1; }
.bd-item.is-today .bd-date { background: var(--moon); color: var(--moon-ink); }
.bd-day { font: 600 18px/1.1 var(--font-display); }
.bd-month { font-size: 11px; }
.bd-who { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; }
.bd-who img { width: 28px; height: 28px; border-radius: 50%; }
.bd-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bd-when { flex: none; font-size: 13px; color: var(--text-muted); }
@media (max-width: 640px) {
  .bd-row, .bd-add-row { grid-template-columns: minmax(0, 1fr); }
}

/* ==========================================================================
   Economy, command channels
   ========================================================================== */
.eco-page code, .cc-page code { font-family: var(--font-mono); font-size: 13px; color: var(--moon); }
.eco-page > .alert, .cc-page > .alert { margin-bottom: 24px; }
.eco-row { display: grid; grid-template-columns: minmax(0, 1fr) 160px minmax(0, 1.4fr); gap: 12px 16px; align-items: start; }
.eco-row .select { max-width: none; }
.eco-toggle { margin-bottom: 14px; }
.eco-input { display: inline-flex; align-items: center; gap: 6px; }
.eco-unit { font-size: 13px; color: var(--text-muted); white-space: nowrap; }
.as-rule.has-error { border-color: var(--danger-line); }
.as-rule .field-error { margin: 4px 0 0; }
.eco-curve { display: grid; gap: 8px; margin-top: 14px; }
.eco-curve-title { font-size: 13px; font-weight: 600; color: var(--text-muted); }
.eco-curve ul { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; list-style: none; }
.eco-curve li { display: grid; justify-items: center; gap: 2px; min-width: 72px; padding: 8px 10px; border: 1px solid var(--line-soft); border-radius: var(--radius); background: var(--night-900); font-size: 12px; color: var(--text-muted); }
.eco-curve li strong { font-size: 15px; color: var(--moon); }
.eco-rich { display: grid; gap: 6px; margin: 0; padding: 0; list-style: none; counter-reset: rich; }
.eco-rich li { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 10px 14px; border: 1px solid var(--line-soft); border-radius: var(--radius-lg); background: var(--night-900); counter-increment: rich; }
.eco-rich li::before { content: counter(rich); width: 22px; font-family: var(--font-mono); font-size: 13px; color: var(--text-subtle); }
.eco-rich .wn-who { flex: 1; min-width: 0; }
.eco-rich-amount { font-weight: 600; font-variant-numeric: tabular-nums; }
.eco-rich-amount small { font-weight: 400; color: var(--text-muted); }
.cc-help { margin: 0 0 8px; }
.cc-help code { margin-right: 2px; }
.cc-categories { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 8px; align-items: start; }
.cc-cat { padding: 10px 14px; border: 1px solid var(--line-soft); border-radius: var(--radius-lg); background: var(--night-900); }
.cc-cat[open] { border-color: var(--line); }
.cc-cat summary { display: flex; align-items: center; justify-content: space-between; gap: 8px; cursor: pointer; list-style: none; min-height: 32px; }
.cc-cat summary::-webkit-details-marker { display: none; }
.cc-cat-name { font-weight: 600; font-size: 14px; }
.cc-cat-state { font-size: 12px; color: var(--text-subtle); }
.cc-cat[open] .cc-cat-state { color: var(--moon); }
.cc-cat .cc-help { margin-top: 6px; }
.cc-anywhere { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); max-height: none; }
.cc-staff { padding: 1px 6px; border-radius: 999px; background: var(--moon-soft); color: var(--moon); font-size: 11px; }
.cc-actions { gap: 8px; flex-direction: row-reverse; justify-content: flex-start; }
@media (max-width: 760px) {
  .eco-row { grid-template-columns: 1fr 1fr; }
  .eco-row .field:last-child { grid-column: 1 / -1; }
}

/* actions next to a page title (e.g. "Tout retirer") */
.page-actions { position: absolute; top: 0; right: 0; margin: 0; }
@media (max-width: 640px) {
  .page-actions { position: static; margin-top: 12px; }
}
@media (max-width: 640px) {
  .crumbs li:last-child::before { content: none; }
  .tabs { overflow-x: auto; scrollbar-width: none; }
  .tab { flex: none; }
}

.sb-short { display: none; }
@media (max-width: 640px) {
  .sb-long { display: none; }
  .sb-short { display: inline; }
}

/* one-time message: the composer is a panel like the settings sections */
.composer .compose, .composer .sent-log {
  margin-bottom: 20px;
  padding: 28px 32px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-panel);
  background: var(--panel);
  box-shadow: var(--shadow-surface);
}
.sendbar { box-shadow: var(--shadow-pop); }
@media (max-width: 640px) {
  .composer .compose, .composer .sent-log { padding: 20px 16px; border-radius: var(--radius-lg); }
}
