/* ───────────────────────────────────────────────────────────────────────────
   PrimeBot Dashboard — refined dark control panel
   Accent: Discord blurple (#5865f2) · Type: Sora + Hanken Grotesk
   ─────────────────────────────────────────────────────────────────────────── */

:root {
  /* Surfaces */
  --bg: #0a0b10;
  --surface-1: #111319;
  --surface-2: #151922;
  --surface-3: #1b212c;
  --surface-hover: #1a212e;
  --border: #232b39;
  --border-strong: #2d3747;
  --border-soft: #181e29;

  /* Brand / accent — Discord blurple, refined */
  --accent: #5865f2;
  --accent-strong: #6e7bf7;
  --accent-soft: rgba(88,101,242, 0.14);
  --accent-glow: rgba(88,101,242, 0.38);

  /* Semantic */
  --on: #3ecf8e;
  --on-soft: rgba(62, 207, 142, 0.13);
  --danger: #f4585f;
  --danger-soft: rgba(244, 88, 95, 0.13);
  --warn: #f5b14c;
  --warn-soft: rgba(245, 177, 76, 0.13);

  /* Donut variables (consumed by renderDonut in app.js — keep names) */
  --green: #3ecf8e;
  --blurple: #5865f2;
  --yellow: #f5b14c;
  --gold: #e9b949;
  --red: #f4585f;

  /* Text */
  --text: #e9ecf3;
  --text-dim: #9aa3b5;
  --text-faint: #6a7384;

  /* Type */
  --font-display: 'Sora', 'Segoe UI', system-ui, sans-serif;
  --font-body: 'Hanken Grotesk', 'Segoe UI', Roboto, system-ui, sans-serif;

  /* Shape & depth */
  --radius: 14px;
  --radius-sm: 10px;
  --radius-xs: 7px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.45), 0 2px 8px rgba(0, 0, 0, 0.28);
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.42);
  --shadow-lg: 0 24px 60px rgba(0, 0, 0, 0.55);
  --ring: 0 0 0 3px var(--accent-soft);
  --maxw: 1560px;
  --transition: 180ms cubic-bezier(0.4, 0, 0.2, 1);

  /* Legacy token aliases — older rules (side menu, save bar, beta / upcoming /
   * notfound overlays, node stats, website logs, badges, ...) reference these
   * surface/accent names. They map onto the refined token set above so the
   * whole dashboard shares one palette. */
  --bg-soft: var(--surface-1);
  --bg-card: var(--surface-2);
  --bg-card-hover: var(--surface-3);
  --blurple-soft: var(--accent-soft);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  /* Respect device notches / rounded corners on mobile (viewport-fit=cover). */
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}

/* Atmospheric backdrop */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(900px 520px at 82% -12%, rgba(88,101,242, 0.12), transparent 60%),
    radial-gradient(680px 420px at -5% 4%, rgba(62, 207, 142, 0.05), transparent 55%);
}

h1, h2, h3, h4, h5 {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text);
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color var(--transition);
}
a:hover { color: var(--accent-strong); text-decoration: underline; }

code {
  font-family: 'SF Mono', 'Fira Code', ui-monospace, Consolas, monospace;
  font-size: 0.9em;
}

/* ── Inline SVG icon system ───────────────────────────────────────────────── */
.ico {
  width: 1.1em;
  height: 1.1em;
  display: inline-block;
  vertical-align: -0.15em;
  flex: 0 0 auto;
  stroke: currentColor;
  fill: none;
}

/* ── Top bar ──────────────────────────────────────────────────────────────── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(10, 11, 16, 0.78);
  backdrop-filter: saturate(150%) blur(18px);
  border-bottom: 1px solid var(--border);
  padding-top: var(--safe-top);
}
.topbar-inner {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 22px;
  padding-left: calc(22px + var(--safe-left));
  padding-right: calc(22px + var(--safe-right));
  height: 62px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

/* The nav is the only flexible child: brand + avatar keep their intrinsic
   size, so the scrollable rail can never push the profile pic off-screen. */
.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  color: var(--text);
  text-decoration: none;
  font-weight: 700;
}
.brand:hover { text-decoration: none; color: var(--text); }
.brand-mark {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: linear-gradient(140deg, var(--accent), #4a55d8);
  color: #fff;
  box-shadow: 0 4px 14px var(--accent-glow), inset 0 1px 0 rgba(255, 255, 255, 0.28);
}
.brand-mark .ico { width: 18px; height: 18px; }
.brand-name {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text);
}
.brand-sub {
  color: var(--text-faint);
  font-weight: 500;
  font-size: 12.5px;
  letter-spacing: 0.01em;
  padding-left: 11px;
  margin-left: 2px;
  border-left: 1px solid var(--border);
}

/* min-width:0 lets the nav shrink so its horizontal scroll kicks in instead of
   pushing the pinned profile avatar off the right edge of the bar. */
.topnav { display: flex; align-items: center; gap: 4px; min-width: 0; flex: 1 1 auto; overflow-x: auto; scrollbar-width: none; -ms-overflow-style: none; }
.topnav::-webkit-scrollbar { display: none; }
.topnav a {
  color: var(--text-dim);
  font-weight: 500;
  font-size: 14px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.topnav a:hover { color: var(--text); text-decoration: none; }
.topnav a.active { color: var(--blurple); }
.nav-icon {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}
.topnav a:hover .nav-icon { stroke: var(--text); }
.topnav a.active .nav-icon { stroke: var(--blurple); }
  padding: 8px 13px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  flex: 0 0 auto;
  transition: background var(--transition), color var(--transition);
}
.topnav a:hover { color: var(--text); text-decoration: none; background: rgba(255, 255, 255, 0.045); }
.topnav a.active { color: #fff; background: var(--accent-soft); }

.user-menu {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
  padding-left: 14px;
  border-left: 1px solid var(--border);
  /* The avatar and the mobile logout dropdown are the same square, so they are
     driven from one variable — change this and both stay in lockstep. */
  --profile-size: 30px;
}
.user-avatar {
  width: var(--profile-size);
  height: var(--profile-size);
  border-radius: 50%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  object-fit: cover;
}

/* Avatar acts as the dropdown toggle. It is a plain button so it is keyboard
   reachable, but visually it is just the avatar (no chrome). */
.user-menu-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  background: none;
  border-radius: 50%;
  cursor: pointer;
  line-height: 0;
  transition: transform var(--transition);
}
.user-menu-toggle:hover { transform: translateY(-1px); }
.user-menu-toggle:focus-visible { outline: 2px solid var(--blurple); outline-offset: 2px; }
.user-avatar-fallback {
  display: inline-grid;
  place-items: center;
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}
.user-name { font-size: 14px; font-weight: 500; color: var(--text); }

/* Transparent, mobile-only account dropdown. It is exactly the size of the
   profile pic above it (same --profile-size square, same circular radius) so it
   reads as the avatar opening rather than a separate panel. It stays
   display:none on desktop, where the inline Log out button is the affordance;
   the 760px media query reveals it and hides that button + the name. */
.user-menu-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  width: var(--profile-size);
  height: var(--profile-size);
  padding: 0;
  border-radius: 50%;
  background: rgba(12, 13, 20, 0.55);
  backdrop-filter: saturate(160%) blur(14px);
  border: 1px solid var(--border-soft, var(--border));
  box-shadow: var(--shadow-lg, 0 18px 40px rgba(0, 0, 0, 0.45));
  z-index: 60;
}
.user-menu-dropdown.open { display: block; }
.user-menu-logout {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  padding: 0;
  border-radius: 50%;
  color: var(--text);
  text-decoration: none;
  transition: background var(--transition), color var(--transition);
}
.user-menu-logout:hover,
.user-menu-logout:focus-visible {
  background: var(--danger-soft, rgba(244, 88, 95, 0.14));
  color: var(--danger, #f4585f);
  text-decoration: none;
}
.user-menu-logout .ico { width: 15px; height: 15px; }
.logout-btn {
  color: var(--text-dim);
  font-size: 13px;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: transparent;
  cursor: pointer;
  transition: all var(--transition);
  font-weight: 500;
}
.logout-btn:hover { color: var(--danger); border-color: rgba(244, 88, 95, 0.5); background: var(--danger-soft); }

/* ── Layout ──────────────────────────────────────────────────────────────── */
.container {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 30px 22px 80px;
  min-height: calc(100vh - 62px - 48px);
}

/* Dense editing workspaces keep the same wide rail as the rest of the site —
 * the builder + live preview share a balanced two-column layout on desktop and
 * the shared --maxw cap keeps ultra-wide monitors readable instead of
 * stretching controls end to end. Kept as a semantic alias. */
.container--editor {
  max-width: var(--maxw);
}

.splash {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 90px 0;
  color: var(--text-dim);
}
.spinner {
  width: 34px;
  height: 34px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  box-shadow: 0 0 14px var(--accent-glow);
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Page headers ────────────────────────────────────────────────────────── */
.page-head { margin-bottom: 26px; }
.page-head h1 {
  margin: 0 0 8px;
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.12;
}
.page-head p {
  margin: 0;
  color: var(--text-dim);
  font-size: 15px;
  line-height: 1.55;
  max-width: 72ch;
}
.page-head code { color: var(--on); background: var(--surface-2); padding: 1px 6px; border-radius: 6px; border: 1px solid var(--border-soft); }

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--text-faint);
  margin-bottom: 16px;
  font-weight: 500;
}
.breadcrumb a { color: var(--text-dim); font-weight: 500; }
.breadcrumb a:hover { color: var(--accent); }

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-size: 14px;
  font-family: var(--font-body);
  font-weight: 600;
  cursor: pointer;
  transition: transform 60ms ease, background var(--transition), border-color var(--transition), opacity var(--transition), box-shadow var(--transition);
  text-decoration: none;
  letter-spacing: 0.01em;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn .ico { width: 17px; height: 17px; }
.btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.12) inset, 0 6px 18px var(--accent-glow);
}
.btn-primary:hover { background: var(--accent-strong); text-decoration: none; color: #fff; box-shadow: 0 8px 22px var(--accent-glow); }
.btn-secondary {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--border);
}
.btn-secondary:hover { background: var(--surface-hover); border-color: var(--border-strong); text-decoration: none; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #e0474e; text-decoration: none; color: #fff; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }
.btn:focus-visible { outline: none; box-shadow: var(--ring); }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-sm .ico { width: 15px; height: 15px; }

.btn-discord {
  background: linear-gradient(135deg, var(--accent), #4a55d8);
  color: #fff;
  padding: 13px 26px;
  font-size: 16px;
  font-weight: 700;
  box-shadow: 0 10px 28px var(--accent-glow), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}
.btn-discord:hover { background: linear-gradient(135deg, var(--accent-strong), #5560e0); text-decoration: none; color: #fff; box-shadow: 0 12px 32px var(--accent-glow); }

/* ── Cards ───────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255, 255, 255, 0.03);
  transition: border-color var(--transition), box-shadow var(--transition), transform var(--transition);
}
.card + .card { margin-top: 18px; }
.card-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 6px;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.01em;
  font-family: var(--font-display);
}
.card-title .icon {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  margin-right: 12px;
  border-radius: 9px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  flex: 0 0 auto;
}
.card-title .icon .ico { width: 19px; height: 19px; }
.card-desc {
  margin: 0 0 18px;
  color: var(--text-dim);
  font-size: 13.5px;
  line-height: 1.5;
  max-width: 78ch;
}

/* ── Login screen ────────────────────────────────────────────────────────── */
.login-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 56px 20px 44px;
}
.login-hero {
  display: grid;
  place-items: center;
  width: 92px;
  height: 92px;
  margin-bottom: 18px;
  border-radius: 24px;
  background: linear-gradient(145deg, var(--accent), #4a55d8);
  color: #fff;
  box-shadow: 0 18px 50px var(--accent-glow), inset 0 1px 0 rgba(255, 255, 255, 0.3);
}
.login-hero .ico { width: 50px; height: 50px; }
.login-title {
  font-size: 38px;
  font-weight: 700;
  margin: 0 0 6px;
  letter-spacing: -0.035em;
  line-height: 1.08;
  color: #fff;
}
.login-tagline {
  margin: 0 0 22px;
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.login-sub {
  color: var(--text-dim);
  max-width: 540px;
  margin: 0 auto 28px;
  line-height: 1.55;
  font-size: 15px;
}
.login-sub code { color: var(--on); background: var(--surface-2); padding: 1px 6px; border-radius: 6px; }

.feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 14px;
  max-width: 820px;
  margin: 34px auto 0;
  text-align: left;
}
.feature {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255, 255, 255, 0.03);
  transition: transform var(--transition), border-color var(--transition), box-shadow var(--transition);
}
.feature:hover { border-color: var(--border-strong); transform: translateY(-2px); box-shadow: var(--shadow); }
.feature .fi {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  margin-bottom: 12px;
  border-radius: 11px;
  background: var(--accent-soft);
  color: var(--accent-strong);
}
.feature .fi .ico { width: 22px; height: 22px; }
.feature .ft { font-family: var(--font-display); font-weight: 600; margin-bottom: 4px; letter-spacing: -0.01em; font-size: 15px; }
.feature .fd { color: var(--text-dim); font-size: 13px; line-height: 1.45; }

/* ── Login stats band ────────────────────────────────────────────────────── */
.stats-band {
  width: 100%;
  max-width: 880px;
  margin: 44px auto 0;
  background: linear-gradient(180deg, var(--surface-1) 0%, var(--surface-2) 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  text-align: left;
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, 0.03);
}
.stats-band-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.stats-band-title { font-size: 12px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-dim); }
.stats-band-sub { font-size: 12.5px; color: var(--text-faint); font-weight: 500; }

.stats-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
.stat-card {
  background: var(--bg);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: relative;
  overflow: hidden;
}
.stat-card.stat-primary {
  border-color: var(--accent);
  background: linear-gradient(180deg, var(--accent-soft) 0%, var(--bg) 100%);
}
.stat-icon { color: var(--accent-strong); display: flex; }
.stat-icon .ico { width: 20px; height: 20px; }
.stat-card:not(.stat-primary) .stat-icon { color: var(--text-dim); }
.stat-value { font-size: 28px; font-weight: 700; letter-spacing: -0.03em; line-height: 1.1; font-family: var(--font-display); }
.stat-label { font-size: 12px; color: var(--text-dim); font-weight: 500; }

.stats-chart-wrap {
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid var(--border-soft);
}
.stats-chart-head { font-size: 13px; font-weight: 600; color: var(--text-dim); margin-bottom: 14px; }
.donut-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}
.donut-item { text-align: center; }
.donut {
  width: 84px; height: 84px;
  border-radius: 50%;
  margin: 0 auto 8px;
  display: grid;
  place-items: center;
  position: relative;
  transition: background 0.6s ease;
}
.donut::after {
  content: '';
  position: absolute;
  inset: 11px;
  background: var(--surface-1);
  border-radius: 50%;
  z-index: 0;
}
.donut-pct {
  position: relative;
  z-index: 1;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.02em;
  font-family: var(--font-display);
}
.donut-label { font-size: 12px; color: var(--text-dim); display: inline-flex; align-items: center; gap: 5px; justify-content: center; }
.donut-label .ico { width: 13px; height: 13px; color: var(--text-faint); }

/* ── Overview stats + guild grid ─────────────────────────────────────────── */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
  margin-bottom: 26px;
}
.stat {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255, 255, 255, 0.03);
}
.stat .sv { font-size: 26px; font-weight: 700; letter-spacing: -0.03em; font-family: var(--font-display); }
.stat .sl { color: var(--text-dim); font-size: 12px; margin-top: 3px; font-weight: 500; }

.guild-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(264px, 1fr));
  gap: 16px;
}
.guild-card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  cursor: pointer;
  transition: transform var(--transition), border-color var(--transition), background var(--transition), box-shadow var(--transition);
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255, 255, 255, 0.03);
}
.guild-card:hover {
  border-color: var(--accent);
  background: var(--surface-2);
  transform: translateY(-3px);
  box-shadow: var(--shadow), 0 0 0 1px var(--accent-soft);
}
.guild-head { display: flex; align-items: center; gap: 12px; }
.guild-icon {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: var(--accent-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  overflow: hidden;
  flex-shrink: 0;
  border: 1px solid rgba(88,101,242, 0.25);
}
.guild-icon img { width: 100%; height: 100%; object-fit: cover; }
.guild-name { font-weight: 600; font-size: 15px; word-break: break-word; letter-spacing: -0.01em; font-family: var(--font-display); }
.guild-meta { font-size: 12px; color: var(--text-faint); font-weight: 500; }
.guild-tags { display: flex; flex-wrap: wrap; gap: 6px; }

.tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  padding: 3px 9px;
  border-radius: 999px;
  font-weight: 600;
  border: 1px solid var(--border);
  white-space: nowrap;
}
.tag .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: 0 0 auto; }
.tag.on { background: var(--on-soft); color: var(--on); border-color: rgba(62, 207, 142, 0.3); }
.tag.off { background: rgba(154, 163, 178, 0.08); color: var(--text-dim); }
.tag.off .dot { background: var(--text-faint); }
.tag.prefix { background: var(--accent-soft); color: #aab2ff; border-color: rgba(88,101,242, 0.3); }
.tag.absent { background: var(--danger-soft); color: var(--danger); border-color: rgba(244, 88, 95, 0.3); }

.guild-empty { text-align: center; padding: 60px 20px; color: var(--text-dim); }
.empty-ico { color: var(--text-faint); display: flex; justify-content: center; margin-bottom: 10px; }
.empty-ico .ico { width: 42px; height: 42px; }

/* ── Guild settings header ───────────────────────────────────────────────── */
.guild-header-card {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 22px;
}
.guild-header-card .guild-icon { width: 58px; height: 58px; font-size: 22px; border-width: 1px; }
.guild-header-card h1 { margin: 0; font-size: 23px; font-weight: 700; letter-spacing: -0.02em; }
.guild-header-card .meta { color: var(--text-dim); font-size: 13px; font-weight: 500; }

/* ── Form controls ───────────────────────────────────────────────────────── */
.field { margin-bottom: 16px; }
.field:last-child { margin-bottom: 0; }
label.field-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text);
  letter-spacing: 0.01em;
}
.field-hint { color: var(--text-faint); font-size: 12px; margin-top: 6px; line-height: 1.45; }
.field-hint code, .card-desc code { color: var(--on); background: var(--surface-2); padding: 1px 6px; border-radius: 6px; border: 1px solid var(--border-soft); font-size: 0.95em; }

input[type="text"],
input[type="number"],
input[type="url"],
textarea,
select {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
  transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
}
input::placeholder, textarea::placeholder { color: var(--text-faint); }
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--ring);
  background: var(--surface-3);
}
textarea { resize: vertical; min-height: 82px; line-height: 1.5; }
input[type="color"] {
  width: 54px;
  height: 42px;
  padding: 3px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  cursor: pointer;
}
input[type="color"]:focus { border-color: var(--accent); box-shadow: var(--ring); }

select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-dim) 50%), linear-gradient(135deg, var(--text-dim) 50%, transparent 50%);
  background-position: calc(100% - 18px) calc(50% + 1px), calc(100% - 13px) calc(50% + 1px);
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 34px;
}
select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--ring);
  background-image: linear-gradient(45deg, transparent 50%, var(--accent) 50%), linear-gradient(135deg, var(--accent) 50%, transparent 50%);
}

/* Toggle switch */
.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border-soft);
}
.switch-row:last-child { border-bottom: none; }
.switch-label { flex: 1; }
.switch-label .sl-title { font-weight: 600; font-size: 14px; letter-spacing: 0.01em; }
.switch-label .sl-desc { color: var(--text-dim); font-size: 12.5px; margin-top: 2px; line-height: 1.4; }

.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: var(--border-strong);
  border-radius: 999px;
  transition: background var(--transition), box-shadow var(--transition);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.2);
}
.slider::before {
  content: "";
  position: absolute;
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform var(--transition), box-shadow var(--transition);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
}
.switch input:checked + .slider { background: var(--on); box-shadow: inset 0 0 0 1px rgba(62, 207, 142, 0.3); }
.switch input:checked + .slider::before { transform: translateX(20px); }
.switch input:disabled + .slider { opacity: 0.4; cursor: not-allowed; }

/* Form actions */
.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid var(--border-soft);
}

/* Reactions list */
.reactions-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.reaction-row {
  display: grid;
  grid-template-columns: 1fr 90px auto;
  gap: 8px;
  align-items: center;
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  padding: 10px;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.reaction-row:focus-within { border-color: rgba(88,101,242, 0.4); box-shadow: var(--ring); }
.reaction-row input { padding: 9px 10px; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; color: var(--text); transition: border-color var(--transition), box-shadow var(--transition); }
.reaction-row input:focus { outline: none; border-color: var(--accent); box-shadow: var(--ring); }
.reaction-remove {
  display: grid;
  place-items: center;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  border-radius: 8px;
  padding: 8px;
  cursor: pointer;
  font-weight: 700;
  transition: all var(--transition);
}
.reaction-remove .ico { width: 16px; height: 16px; }
.reaction-remove:hover { color: var(--danger); border-color: rgba(244, 88, 95, 0.5); background: var(--danger-soft); }

/* Automod multi-action rule rows + groups */
.am-rule-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  padding: 12px 10px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}
.am-rule-row .am-rule-label { min-width: 150px; font-weight: 600; letter-spacing: 0.01em; display: inline-flex; align-items: center; gap: 8px; }
.am-rule-row .am-rule-label .ico { width: 17px; height: 17px; color: var(--accent-strong); }
.am-rule-row input[type="text"],
.am-rule-row input[type="number"] { padding: 9px 10px; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; color: var(--text); transition: border-color var(--transition), box-shadow var(--transition); }
.am-rule-row input:focus { outline: none; border-color: var(--accent); box-shadow: var(--ring); }
.am-actions-group { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.am-action-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  background: var(--surface-1);
  transition: border-color var(--transition), background var(--transition), box-shadow var(--transition);
}
.am-action-label:hover { border-color: var(--border-strong); background: var(--surface-hover); }
.am-action-label input:checked + .switch-text { color: var(--accent-strong); font-weight: 600; }
.am-action-label:has(input:checked) { border-color: rgba(88,101,242, 0.4); background: var(--accent-soft); }
.am-action-label .switch-text { white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; }
.am-action-label .switch-text .ico { width: 15px; height: 15px; }
.am-action-label input { margin: 0; }
.field-row { display: flex; gap: 10px; align-items: center; margin-bottom: 10px; flex-wrap: wrap; }
.field-rows { display: flex; flex-direction: column; gap: 6px; }

/* Inline color + text field */
.color-field { display: flex; align-items: center; gap: 12px; }
.color-field input[type="color"] { flex-shrink: 0; }

/* Logging event toggle grid */
.event-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}
.event-group { display: flex; flex-direction: column; gap: 10px; }
.event-group-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-faint);
}
.switch.mini {
  display: flex;
  align-items: center;
  gap: 10px;
  width: auto;
  height: auto;
  padding: 10px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition), box-shadow var(--transition);
}
.switch.mini:hover { border-color: var(--border-strong); background: var(--surface-hover); }
.switch.mini input { width: 34px; height: 20px; opacity: 0; position: absolute; margin: 0; }
.switch.mini .slider { position: relative; width: 34px; height: 20px; flex-shrink: 0; }
.switch.mini .slider::before { height: 14px; width: 14px; left: 3px; bottom: 3px; }
.switch.mini input:checked + .slider { background: var(--on); }
.switch.mini input:checked + .slider::before { transform: translateX(14px); }
.switch-text { font-size: 13px; color: var(--text); font-weight: 500; display: inline-flex; align-items: center; gap: 7px; }
.switch-text .ico { width: 15px; height: 15px; color: var(--text-dim); }
.switch.mini input:checked ~ .switch-text .ico { color: var(--on); }

/* ── Settings layout (sidebar nav) ───────────────────────────────────────── */
.settings-layout {
  display: grid;
  grid-template-columns: 234px 1fr;
  gap: 26px;
  align-items: start;
}
.settings-nav { position: sticky; top: 86px; }
.tabs {
  display: flex;
  flex-direction: column;
  gap: 4px;
  border-bottom: none;
  margin-bottom: 0;
  overflow-x: visible;
}
.tab {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 13px;
  font-size: 14px;
  font-weight: 500;
  font-family: var(--font-body);
  color: var(--text-dim);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  white-space: nowrap;
  text-align: left;
  transition: color var(--transition), background var(--transition), border-color var(--transition);
}
.tab-ico { display: grid; place-items: center; color: var(--text-faint); flex: 0 0 auto; }
.tab-ico .ico { width: 18px; height: 18px; }
.tab:hover { color: var(--text); background: rgba(255, 255, 255, 0.04); }
.tab.active {
  color: #fff;
  background: var(--accent-soft);
  border-color: rgba(88,101,242, 0.35);
}
.tab.active .tab-ico { color: var(--accent-strong); }

.tab-panel { display: none; }
.tab-panel.active { display: block; animation: fadeIn 200ms ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }

/* ── Alert / banner ──────────────────────────────────────────────────────── */
.alert {
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  font-size: 13.5px;
  margin-bottom: 16px;
  border: 1px solid;
  line-height: 1.45;
}
.alert-error { background: var(--danger-soft); color: #ffb6b9; border-color: rgba(244, 88, 95, 0.4); }
.alert-warn { background: var(--warn-soft); color: #fbd79a; border-color: rgba(245, 177, 76, 0.32); }
.alert-info { background: var(--accent-soft); color: #c5ccff; border-color: rgba(88,101,242, 0.4); }
.alert code { background: rgba(0, 0, 0, 0.25); padding: 1px 6px; border-radius: 5px; }

/* ── Toast ───────────────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface-3);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 14px 22px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  z-index: 100;
  transition: opacity 250ms ease, transform 250ms ease;
  letter-spacing: 0.01em;
}
.toast.hidden { opacity: 0; transform: translate(-50%, 12px); pointer-events: none; }
.toast.success { border-color: rgba(62, 207, 142, 0.55); box-shadow: 0 12px 34px rgba(62, 207, 142, 0.18); }
.toast.error { border-color: rgba(244, 88, 95, 0.55); box-shadow: 0 12px 34px rgba(244, 88, 95, 0.18); }

/* ── Back to top ──────────────────────────────────────────────────────────── */
.back-to-top {
  position: fixed;
  right: 22px;
  bottom:  26px;
  width:  44px;
  height:  44px;
  display: grid;
  place-items: center;
  border-radius:  50%;
  background: var(--surface-3);
  border:  1px solid var(--border-strong);
  color: var(--text-dim);
  box-shadow: var(--shadow-lg);
  cursor: pointer;
  opacity: 0;
  transform: translateY(10px) scale(0.92);
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease, color var(--transition), border-color var(--transition), box-shadow var(--transition);
  z-index: 80;
}
.back-to-top:hover {
  color: #fff;
  border-color: rgba(88,101,242,  0.65);
  box-shadow: 0 8px 26px rgba(88,101,242, 0.30);
}
.back-to-top:active { transform: translateY(2px) scale(0.96); }
.back-to-top .ico { width:  22px; height:  22px; }
.back-to-top.visible {
  opacity:  0.92;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* ── Footer ──────────────────────────────────────────────────────────────── */
.footer {
  border-top: 1px solid var(--border);
  padding: 14px 22px;
  padding-bottom: calc(14px + var(--safe-bottom));
  text-align: center;
  color: var(--text-faint);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.02em;
}
.footer-links { margin-left: 10px; }
.footer-links a { color: var(--text-dim); transition: color var(--transition); }
.footer-links a:hover { color: var(--accent); }

.login-legal { color: var(--text-faint); font-size: 12px; margin: 14px 0 0; }
.login-legal a { color: var(--text-dim); transition: color var(--transition); }
.login-legal a:hover { color: var(--accent); }
/* Invisible Turnstile: the widget renders no visible box. */
.cf-turnstile-hidden { display: none; }
.turnstile-error { color: var(--red); font-size: 13px; margin: 10px 0 0; }

.hidden { display: none !important; }

/* ── Documentation page ──────────────────────────────────────────────────── */
.docs { max-width: 900px; margin: 0 auto; padding: 8px 0 60px; }
.docs-hero { text-align: center; padding: 44px 16px 30px; position: relative; }
/* In-body back button rendered on public (logged-out) docs renders — the no-nav
   login shell hides the top nav's back button on those pages. */
.docs-hero .docs-back { position: absolute; left: 16px; top: 44px; }
.docs-hero-icon { color: var(--accent-strong); display: flex; justify-content: center; margin-bottom: 12px; }
.docs-hero-icon .ico { width: 52px; height: 52px; }
.docs-title { font-size: 36px; font-weight: 700; margin: 0 0 12px; letter-spacing: -0.03em; line-height: 1.1; }
.docs-lead { color: var(--text-dim); max-width: 640px; margin: 0 auto; font-size: 16px; line-height: 1.55; }

.docs-toc {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 22px;
  margin: 28px 0 36px;
  box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255, 255, 255, 0.03);
}
.docs-toc h3 { margin: 0 0 10px; font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-faint); font-weight: 700; }
.docs-toc ul { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 6px 18px; }
.docs-toc a { color: var(--text-dim); font-size: 14px; font-weight: 500; transition: color var(--transition); }
.docs-toc a:hover { color: var(--accent); }

.docs-section { scroll-margin-top: 84px; padding: 28px 0; border-top: 1px solid var(--border-soft); }
.docs-section:first-of-type { border-top: none; }
.docs-section h2 { font-size: 23px; font-weight: 600; margin: 0 0 14px; letter-spacing: -0.02em; line-height: 1.2; }
.docs-section p { color: var(--text); margin: 0 0 12px; line-height: 1.6; }
.docs-section code { background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px; padding: 2px 8px; font-size: 13px; color: var(--on); }

.docs-steps { margin: 14px 0; padding-left: 24px; }
.docs-steps li { margin-bottom: 16px; }
.docs-list { margin: 10px 0; padding-left: 24px; }
.docs-list li { margin-bottom: 7px; }

.docs-code-row { display: flex; align-items: center; gap: 10px; margin-top: 10px; flex-wrap: wrap; }
.docs-code {
  flex: 1 1 260px;
  display: block;
  padding: 10px 14px;
  font-family: 'SF Mono', 'Fira Code', Consolas, monospace;
  font-size: 12.5px;
  overflow-x: auto;
  color: var(--on);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
}

.docs-callout {
  background: var(--accent-soft);
  border: 1px solid rgba(88,101,242, 0.35);
  padding: 14px 18px;
  border-radius: var(--radius-sm);
  margin: 18px 0;
  font-size: 14px;
  line-height: 1.5;
}
.docs-callout code { background: rgba(0, 0, 0, 0.28); }

.docs-cmd-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; margin-top: 16px; }
.docs-cmd-card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255, 255, 255, 0.03);
  transition: border-color var(--transition), transform var(--transition), box-shadow var(--transition);
}
.docs-cmd-card:hover { border-color: var(--border-strong); transform: translateY(-1px); box-shadow: var(--shadow); }
.docs-cmd-card h4 { margin: 0 0 10px; font-size: 15px; font-weight: 600; display: inline-flex; align-items: center; gap: 8px; }
.docs-cmd-card h4 .ico { width: 17px; height: 17px; color: var(--accent-strong); }
.docs-cmd-card ul { list-style: none; padding: 0; margin: 0; }
.docs-cmd-card li { padding: 4px 0; font-size: 13.5px; color: var(--text-dim); border-top: 1px solid var(--border-soft); }
.docs-cmd-card li:first-child { border-top: none; }
.docs-cmd-card li code { color: var(--on); }

.docs-faq { margin-top: 14px; }
.docs-faq details {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 10px;
  overflow: hidden;
  transition: border-color var(--transition);
}
.docs-faq details[open] { border-color: var(--border-strong); }
.docs-faq summary {
  cursor: pointer;
  padding: 14px 18px;
  font-weight: 600;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: background var(--transition), color var(--transition);
}
.docs-faq summary:hover { background: rgba(255, 255, 255, 0.025); color: var(--accent); }
.docs-faq summary::-webkit-details-marker { display: none; }
.docs-faq summary::after { content: '+'; color: var(--text-faint); font-size: 20px; font-weight: 400; transition: transform 0.15s; }
.docs-faq details[open] summary::after { content: '−'; }
.docs-faq details p { margin: 0; padding: 0 18px 16px; color: var(--text-dim); font-size: 14px; }

.docs-cta {
  text-align: center;
  margin-top: 42px;
  padding: 38px 22px;
  background: linear-gradient(180deg, var(--surface-1), var(--surface-2));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255, 255, 255, 0.03);
}
.docs-cta h3 { margin: 0 0 6px; font-size: 20px; font-weight: 600; }
.docs-cta p { color: var(--text-dim); margin: 0 0 20px; line-height: 1.5; }
.docs-cta .btn { margin: 0 8px 10px; }

/* ── Reaction Roles / Tickets ────────────────────────────────────────────── */
.rr-list { display: flex; flex-direction: column; gap: 12px; margin-bottom: 10px; }
.rr-menu-card .card-title { justify-content: space-between; }
.rr-meta { display: flex; flex-wrap: wrap; gap: 8px 18px; font-size: 13px; color: var(--text-dim); margin: 8px 0 10px; font-weight: 500; }
.rr-meta strong { color: var(--text-faint); font-weight: 600; }
.rr-mappings {
  font-size: 14px;
  padding: 10px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  line-height: 1.5;
}
.reaction-row .r-role { max-width: 200px; }
.rr-menu-card .btn-sm { margin-left: 8px; }

.rr-menu-card, .ticket-panel-card {
  transition: border-color var(--transition), transform var(--transition), box-shadow var(--transition);
}
.rr-menu-card:hover, .ticket-panel-card:hover { border-color: var(--border-strong); transform: translateY(-1px); box-shadow: var(--shadow); }

.st-ok { color: var(--on); display: inline-flex; gap: 5px; align-items: center; }
.st-no { color: var(--text-faint); display: inline-flex; gap: 5px; align-items: center; }
.st-ok .ico, .st-no .ico { width: 14px; height: 14px; }

/* ── Live page + modal + Events ──────────────────────────────────────────── */
.live-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.live-panel h2 { margin: 0 0 12px; font-size: 18px; font-weight: 600; letter-spacing: -0.01em; display: flex; align-items: center; gap: 9px; }
.live-panel h2 .ico { width: 19px; height: 19px; color: var(--accent-strong); }
.live-section-head {
  font-size: 12px;
  font-weight: 700;
  margin: 20px 0 10px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  display: flex;
  align-items: center;
  gap: 8px;
}
.status-dot { width: 8px; height: 8px; border-radius: 50%; flex: 0 0 auto; }
.status-dot.live { background: var(--on); box-shadow: 0 0 8px var(--on); }
.status-dot.ended { background: var(--text-faint); }
.live-list { display: flex; flex-direction: column; gap: 10px; }
.live-empty { color: var(--text-dim); font-size: 13px; margin: 6px 0; font-weight: 500; }
.live-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  background: var(--surface-2);
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: var(--shadow-sm);
  transition: border-color var(--transition), transform var(--transition), box-shadow var(--transition);
}
.live-card:hover { border-color: var(--border-strong); transform: translateY(-1px); box-shadow: var(--shadow); }
.live-card-title { font-weight: 600; font-size: 15px; letter-spacing: -0.01em; font-family: var(--font-display); }
.live-card-meta { font-size: 12px; color: var(--text-dim); display: flex; gap: 10px; flex-wrap: wrap; font-weight: 500; align-items: center; }
.live-meta { display: inline-flex; align-items: center; gap: 5px; }
.live-meta .ico { width: 13px; height: 13px; }
.live-card-code { font-size: 12px; }
.live-card-code code, .live-card-opts code, .live-winners code { background: var(--surface-1); padding: 2px 8px; border-radius: 6px; border: 1px solid var(--border-soft); color: var(--on); }
.live-card-opts { font-size: 12px; color: var(--text-dim); line-height: 1.4; }
.live-winners { font-size: 13px; font-weight: 600; display: inline-flex; align-items: center; gap: 6px; }
.live-winners .ico { width: 15px; height: 15px; color: var(--warn); }
.live-ended { opacity: 0.85; }
.live-join-btn { align-self: flex-start; margin-top: 4px; }

/* Modal / floating window */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(6, 7, 11, 0.6);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(5px);
}
.modal-overlay.hidden { display: none !important; }
/* Ticket panel editor — wider modal, the whole create/edit form scrolls inside. */
.modal.tk-editor { width: min(720px, 95vw); }
.modal.tk-editor .modal-body { max-height: 70vh; overflow-y: auto; }
.modal.floating-window {
  background: var(--surface-1);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: 16px;
  width: min(520px, 92vw);
  max-height: 86vh;
  overflow: auto;
  box-shadow: var(--shadow-lg), inset 0 1px 0 rgba(255, 255, 255, 0.04);
  padding: 0;
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-head h3 { margin: 0; font-size: 17px; font-weight: 600; display: inline-flex; align-items: center; gap: 9px; }
.modal-head h3 .ico { width: 18px; height: 18px; color: var(--accent-strong); }
.modal-close {
  background: none; border: none; font-size: 22px; line-height: 1;
  cursor: pointer; color: var(--text-dim);
  transition: color var(--transition), transform var(--transition), background var(--transition);
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 8px;
}
.modal-close .ico { width: 18px; height: 18px; }
.modal-close:hover { color: var(--danger); background: var(--danger-soft); transform: scale(1.05); }
.modal-body { padding: 18px 20px; display: flex; flex-direction: column; gap: 12px; }
.command-box {
  display: flex; align-items: center; gap: 10px; justify-content: space-between;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
}
.command-box code { font-size: 14px; word-break: break-all; color: var(--on); }
.btn-copy { padding: 6px 12px; }
.live-modal-note { font-size: 13px; color: var(--text-dim); font-weight: 500; }
.live-join-actions { display: flex; gap: 10px; }

/* Events tab */
.ev-form { display: flex; flex-direction: column; gap: 12px; margin: 14px 0 8px; }
.ev-form label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 600; }
.ev-form input, .ev-form textarea, .ev-form select { font-weight: 400; }
.ev-form .form-row { display: flex; gap: 12px; flex-wrap: wrap; }
.ev-form .form-row label { flex: 1; min-width: 160px; }
.ev-tasks-head { margin: 6px 0 0; font-size: 14px; font-weight: 600; color: var(--text-dim); }
.ev-task-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: start;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  background: var(--surface-2);
  box-shadow: var(--shadow-sm);
}
.ev-task-row label { font-size: 12px; font-weight: 600; display: flex; flex-direction: column; gap: 4px; }
.ev-task-row .ev-action { font-weight: 400; }
.ev-task-row .ev-target { display: flex; flex-direction: column; gap: 8px; }
.ev-task-row select[multiple] { min-height: 76px; }
.ev-tg-embed { display: flex; flex-direction: column; gap: 6px; }
.ev-tg-embed label { font-size: 12px; }
.ev-remove-task {
  align-self: start;
  display: grid; place-items: center;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  border-radius: 8px;
  padding: 8px;
  cursor: pointer;
  font-weight: 700;
  transition: all var(--transition);
}
.ev-remove-task .ico { width: 16px; height: 16px; }
.ev-remove-task:hover { color: var(--danger); border-color: rgba(244, 88, 95, 0.5); background: var(--danger-soft); }
.ev-list-head { margin: 22px 0 10px; font-size: 16px; font-weight: 600; letter-spacing: -0.01em; }
.ev-card { gap: 10px; }
.ev-tasks ul { margin: 4px 0 0; padding-left: 20px; font-size: 13px; color: var(--text-dim); }
.ev-tasks ul li { display: flex; align-items: center; gap: 6px; }
.ev-tasks ul li .ico { width: 14px; height: 14px; color: var(--accent-strong); }
.ev-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.ev-actions .btn { padding: 5px 12px; font-size: 13px; }

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 960px) {
  .settings-layout { grid-template-columns: 1fr; gap: 18px; }
  .settings-nav { position: static; }
  .tabs {
    flex-direction: row;
    overflow-x: auto;
    border-bottom: 1px solid var(--border);
    padding-bottom: 4px;
  }
  .tab { border-radius: 10px 10px 0 0; border: 1px solid transparent; border-bottom: 2px solid transparent; white-space: nowrap; }
  .tab.active { border-bottom-color: var(--accent); }
}
@media (max-width: 900px) {
  .live-grid { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  /* Trim the chrome — keep the brand mark + name, drop the "Dashboard" sub
     so the scrollable topnav has room on phones. The profile pic stays pinned
     on the right and becomes the account dropdown toggle: the inline username
     and Log out button are hidden here and live in the dropdown instead. */
  .brand-sub { display: none; }
  .user-name { display: none; }
  .user-menu .logout-btn { display: none; }
  .user-menu { padding-left: 10px; }
  .user-menu-dropdown { left: auto; right: 0; }
  .topbar-inner { gap: 8px; }
  .topnav { gap: 2px; }
  .topnav a { padding: 8px 10px; }
}
@media (max-width: 640px) {
  /* The topnav now scrolls horizontally instead of vanishing, so all pages
     (Servers / Overview / Stats / Docs) stay reachable on mobile. */
  .reaction-row { grid-template-columns: 1fr; }
  .page-head h1 { font-size: 24px; }
  .docs-toc ul { grid-template-columns: 1fr; }
  .docs-code-row { flex-direction: column; align-items: stretch; }
  .docs-code { flex: none; }
  .stats-cards { grid-template-columns: 1fr; }
  .donut-grid { grid-template-columns: repeat(2, 1fr); }
  .login-title { font-size: 30px; }
  .container { padding: 18px 14px 72px; padding-left: calc(14px + var(--safe-left)); padding-right: calc(14px + var(--safe-right)); padding-bottom: calc(72px + var(--safe-bottom)); }
  .am-rule-row { gap: 8px; }
  .am-rule-row .am-rule-label { min-width: 0; width: 100%; }
  .am-rule-row .am-actions-group { width: 100%; }
  .field-row { flex-direction: column; align-items: stretch; }
  .field-row > input, .field-row > select { width: 100%; }
  .save-bar { width: calc(100% - 24px); flex-wrap: wrap; justify-content: center; text-align: center; }
}


/* ───────────────────────────────────────────────────────────────────────────
   Current MPA components — selectors used by the server-rendered pages
   (render/*.js) + per-page client scripts (public/js/*.js) that the SPA-era
   redesign above does not cover. Restyled here against the refined token set
   (via the legacy aliases in :root) so the whole dashboard is visually
   coherent: side-menu drawer, floating Save bar, beta / upcoming / 404
   overlays, shardnode stats, website-log table, badges, ticket close-flow
   buttons, auto-responder / reaction-role / event / automod editors, etc.
   ─────────────────────────────────────────────────────────────────────────── */

/* Back button (←) — sits in the topbar, present on every page. Clicking goes
   back to the previous page in browser history. */
.back-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text);
  font-size: 17px;
  line-height: 1;
  text-decoration: none;
  transition: background 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

.back-btn:hover {
  background: var(--blurple, #5865F2);
  color: #fff;
  transform: translateX(-2px);
}

.back-btn:active { transform: translateX(-2px) scale(0.96); }

.back-btn .back-symbol { font-weight: 700; }

.card-hint {
  margin: 0 0 14px;
  font-size: 13px;
  color: var(--text-dim);
}

.card-hint code { background: rgba(0,0,0,0.06); padding: 1px 6px; border-radius: 6px; }

.login-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
  margin-bottom: 12px;
}

/* ── Discord-style floating "Save changes" bar ─────────────────────────── */
/* Slides up from the bottom when the user edits a settings field. Mirrors
   Discord's settings footer: a label + a green "Save" box and a borderless
   red "Reset" text link. */
.save-bar {
  position: fixed;
  left: 50%;
  bottom: calc(24px + var(--safe-bottom));
  transform: translateX(-50%);
  z-index: 60;
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 12px 16px 12px 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 999px;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.5);
  max-width: calc(100vw - 24px);
  /* Slide-up-in / slide-down-out. visibility is delayed on hide so the
     slide-out finishes before the bar becomes invisible to assistive tech. */
  transition: transform 0.22s cubic-bezier(0.22, 1, 0.36, 1),
              opacity 0.22s ease,
              visibility 0s linear 0.22s;
  visibility: visible;
  opacity: 1;
}

/* Hidden state is transform+opacity (NOT display:none) so the slide-down-out
   animation actually plays. Using the global .hidden (display:none !important)
   here would cut the transition off instantly. */
.save-bar-hidden {
  transform: translate(-50%, 140%);
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
  transition: transform 0.22s cubic-bezier(0.22, 1, 0.36, 1),
              opacity 0.22s ease,
              visibility 0s linear 0.22s;
}

.save-bar-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
}

.save-bar-actions { display: flex; align-items: center; gap: 14px; }

.save-bar-save {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 20px;
  border-radius: var(--radius-sm);
  border: none;
  background: var(--green);
  color: #0b0d12;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: filter 0.15s, transform 0.05s;
}

.save-bar-save:hover { filter: brightness(0.95); }

.save-bar-save:active { transform: translateY(1px); }

.save-bar-save:disabled { opacity: 0.6; cursor: not-allowed; }

.save-bar-reset {
  background: none;
  border: none;
  padding: 8px 4px;
  color: var(--red);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.save-bar-reset:hover { text-decoration: underline; }

.ar-exact-wrap {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--text-dim);
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}

.ar-exact-wrap input { width: auto; }

/* Sidebar slide-in menu ("turn left" animation) */
.menu-bar {
  margin-bottom: 20px;
}

.menu-toggle {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 9px 16px 9px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.menu-toggle:hover { background: var(--bg-card-hover); border-color: var(--blurple); }

.menu-hamburger {
  display: inline-flex;
  flex-direction: column;
  gap: 4px;
  width: 18px;
}

.menu-hamburger span {
  display: block;
  height: 2px;
  width: 100%;
  background: var(--text);
  border-radius: 2px;
  transition: transform 0.2s, opacity 0.2s;
}

.menu-bar-label { color: var(--text-dim); }

.menu-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s, visibility 0.3s;
  z-index: 200;
}

.menu-backdrop.show { opacity: 1; visibility: visible; }

.side-menu {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: min(300px, 84vw);
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bottom);
  background: var(--bg-soft);
  border-right: 1px solid var(--border);
  box-shadow: var(--shadow);
  transform: translateX(-100%);
  transition: transform 0.32s cubic-bezier(0.22, 1, 0.36, 1);
  z-index: 210;
  display: flex;
  flex-direction: column;
}

.side-menu.open { transform: translateX(0); }

.side-menu-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
}

.side-menu-title { font-size: 14px; font-weight: 700; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.04em; }

.side-menu-close {
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 18px;
  cursor: pointer;
  line-height: 1;
  padding: 2px 6px;
  border-radius: 6px;
}

.side-menu-close:hover { color: var(--red); background: rgba(237, 66, 69, 0.1); }

.side-menu-nav {
  display: flex;
  flex-direction: column;
  padding: 10px 8px;
  gap: 2px;
  overflow-y: auto;
}

.menu-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  transition: background 0.12s, color 0.12s;
}

.menu-item:hover { background: var(--bg-card-hover); text-decoration: none; color: var(--text); }

.menu-item.active { background: var(--blurple-soft); color: #a9b1ff; }

/* BETA badge */
.beta-badge {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.05em;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(254, 231, 92, 0.15);
  color: var(--yellow);
  border: 1px solid rgba(254, 231, 92, 0.4);
  text-transform: uppercase;
}

.beta-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  margin-bottom: 14px;
  border-radius: var(--radius-sm);
  background: rgba(254, 231, 92, 0.1);
  border: 1px solid rgba(254, 231, 92, 0.3);
  color: var(--yellow);
  font-size: 13px;
  font-weight: 600;
}

/* ── Beta-locked panel (e.g. Events for non-beta servers) ────────────────── */
/* The feature content is blurred and an overlay with a "join support server"
   message covers it, so the tab is visible but unusable until beta is enabled. */
.beta-locked-card { position: relative; overflow: hidden; }

.beta-locked-wrap.locked {
  filter: blur(4px);
  opacity: 0.45;
  pointer-events: none;
  user-select: none;
}

.beta-locked-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 5;
  background: rgba(11, 13, 18, 0.35);
}

.beta-locked-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 28px 32px;
  max-width: 440px;
  text-align: center;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.beta-locked-icon { font-size: 34px; }

.beta-locked-text {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.5;
}

/* ── "Upcoming feature" (Coming Soon) overlay ────────────────────────────── */
/* Like the beta-locked panel, but for not-yet-released features. The body is
   blurred and a "Coming Soon……" overlay with a small animated graphic covers
   it. Upcoming takes priority over beta. */
.soon-badge {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.05em;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(88,101,242, 0.16);
  color: #a9b1ff;
  border: 1px solid rgba(88,101,242, 0.45);
  text-transform: uppercase;
}

.upcoming-locked-card { position: relative; overflow: hidden; }

.upcoming-locked-wrap.locked {
  filter: blur(5px);
  opacity: 0.4;
  pointer-events: none;
  user-select: none;
}

.upcoming-locked-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 6;
  background: rgba(11, 13, 18, 0.45);
}

.upcoming-locked-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 34px 38px;
  max-width: 480px;
  text-align: center;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.upcoming-graphic {
  position: relative;
  width: 96px;
  height: 96px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.upcoming-orb {
  position: absolute;
  inset: 18px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, rgba(169,177,255,0.95), rgba(88,101,242,0.35) 60%, transparent 72%);
  filter: blur(1px);
  animation: upcoming-pulse 2.4s ease-in-out infinite;
}

.upcoming-dots {
  position: absolute;
  bottom: 6px;
  display: flex;
  gap: 6px;
}

.upcoming-dots span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #a9b1ff;
  opacity: 0.4;
  animation: upcoming-bounce 1.2s ease-in-out infinite;
}

.upcoming-dots span:nth-child(2) { animation-delay: 0.18s; }

.upcoming-dots span:nth-child(3) { animation-delay: 0.36s; }

.upcoming-icon { font-size: 32px; }

.upcoming-title {
  font-size: 22px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: 0.01em;
}

.upcoming-text {
  font-size: 14px;
  color: var(--text-dim);
  line-height: 1.55;
}

/* ── Badges page ──────────────────────────────────────────────────────────── */
.badge-section-head { margin: 22px 0 4px; font-size: 16px; }

.badge-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
  margin: 10px 0 6px;
}

/* Birthdays page */
.bd-add-form {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 0 6px;
}
.bd-add-form input[type="text"] { flex: 1 1 200px; }
.bd-add-form select { flex: 0 0 auto; }
.bd-add-form input[type="number"] { width: 110px; }
.bd-image-preview-wrap {
  margin-top: 8px;
}
.bd-image-preview-wrap img {
  max-width: 100%;
  max-height: 220px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-soft, rgba(0,0,0,0.08));
  display: block;
}
.bd-table td { vertical-align: middle; }


.badge-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--border, #e3e3e8);
  border-radius: var(--radius-sm);
  background: rgba(0,0,0,0.02);
}

.badge-card .badge-emoji {
  font-size: 30px;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border-radius: 50%;
  background: var(--blurple-soft);
}

.badge-card.badge-type-level .badge-emoji { background: rgba(205,127,50,0.14); }

.badge-card.badge-type-achievement .badge-emoji { background: rgba(88,101,242,0.14); }

.badge-card.badge-type-special .badge-emoji { background: rgba(255,215,0,0.14); }

.badge-info { flex: 1; min-width: 0; }

.badge-name { font-weight: 700; font-size: 14px; }

.badge-desc { font-size: 12px; color: var(--text-dim); margin-top: 2px; }

.badge-meta { font-size: 11px; color: var(--text-faint); margin-top: 4px; text-transform: uppercase; letter-spacing: 0.04em; }

.badge-action { flex-shrink: 0; }

.badge-locked-tag {
  font-size: 11px;
  color: var(--text-faint);
  font-style: italic;
  white-space: nowrap;
}

.badge-table .bdg-emoji { font-size: 20px; width: 32px; text-align: center; }

.badge-table .bdg-name { font-weight: 600; }

.badge-table .bdg-user code { font-size: 12px; }

.badge-table .bdg-time { color: var(--text-dim); white-space: nowrap; font-variant-numeric: tabular-nums; }

.badge-table .tag.achievement { background: rgba(88,101,242,0.16); color: #a9b1ff; }

.badge-table .tag.special { background: rgba(255,215,0,0.16); color: #f7d774; }

.badge-table .tag.level { background: rgba(205,127,50,0.16); color: #e0a36a; }

/* Modal tweaks for the Badges award flow (reuses the shared .modal-overlay /
   .modal.floating-window / .modal-head / .modal-body from the live-join
   modal). The award modal adds a footer with action buttons. */
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 20px;
  border-top: 1px solid var(--border-soft, #eee);
}

.modal-emoji { margin-right: 6px; }

.modal-desc { font-size: 13px; color: var(--text-dim); margin: 0 0 12px; }

/* ── Session inactivity warning modal ──────────────────────────────────────
   Built entirely client-side by session-timeout.js. Matches the dashboard's
   visual language (surface-1 card, border-strong, accent buttons). */
.idle-warning-hidden { display: none !important; }

#idle-warning-modal {
  position: fixed; inset: 0;
  background: rgba(6, 7, 11, 0.62);
  display: flex; align-items: center; justify-content: center;
  z-index: 1200;
  backdrop-filter: blur(5px);
  padding: 16px;
}

.idle-warning-card {
  background: var(--surface-1);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: 16px;
  width: min(400px, 92vw);
  box-shadow: var(--shadow-lg), inset 0 1px 0 rgba(255, 255, 255, 0.04);
  text-align: center;
  padding: 28px 24px 24px;
  animation: idle-warning-pop 0.22s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes idle-warning-pop {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to   { opacity: 1; transform: none; }
}

.idle-warning-icon {
  width: 56px; height: 56px; margin: 0 auto 14px;
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent-soft, rgba(88, 101, 242, 0.14));
  color: var(--accent);
}
.idle-warning-icon .ico { width: 28px; height: 28px; }

#idle-warning-modal h3 {
  margin: 0 0 8px;
  font-size: 19px; font-weight: 600;
  display: flex; align-items: center; justify-content: center; gap: 8px;
}

.idle-warning-desc {
  margin: 0 0 14px;
  font-size: 13.5px; line-height: 1.5;
  color: var(--text-dim);
}

.idle-warning-label {
  margin: 0 0 4px;
  font-size: 12px; font-weight: 600;
  letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--text-faint, var(--text-dim));
}

.idle-warning-countdown {
  font-variant-numeric: tabular-nums;
  font-size: 40px; font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--on);
}
.idle-warning-countdown .idle-warning-countdown-label { display: none; }

.idle-warning-actions {
  display: flex; gap: 10px; justify-content: center;
  margin-top: 18px; flex-wrap: wrap;
}
.idle-warning-actions .btn { min-width: 150px; justify-content: center; }

.idle-warning-note {
  margin: 14px 0 0;
  font-size: 12px; color: var(--text-faint, var(--text-dim));
}

@media (max-width: 480px) {
  .idle-warning-actions .btn { min-width: 46%; }
}

/* Hidden state is opacity+transform (NOT display:none) so the slide/fade-out
   animation actually plays instead of being cut off by the global .hidden. */
.toast-hidden {
  opacity: 0;
  transform: translate(-50%, 12px);
  pointer-events: none;
  visibility: hidden;
  transition: opacity 0.25s ease, transform 0.25s cubic-bezier(0.22, 1, 0.36, 1),
              visibility 0s linear 0.25s;
}

.docs-callout-info { border-left-color: var(--blurple); }

/* ── Stats page: shardnode node list ──────────────────────────────────────── */

.node-summary {
  display: flex; flex-wrap: wrap; gap: 18px;
  font-size: 13px; color: var(--text-dim);
  margin-bottom: 14px;
}

.node-summary strong { color: var(--text); }

.node-list { display: flex; flex-direction: column; gap: 10px; }

.node-row {
  display: flex; align-items: center; gap: 12px;
  background: var(--bg); border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm); padding: 12px 14px;
}

.node-row.node-online { border-left: 3px solid var(--green); }

.node-row.node-offline { border-left: 3px solid var(--red); }

.node-row.node-never { border-left: 3px solid var(--border); }

.node-icon { font-size: 18px; }

.node-main { flex: 1; min-width: 0; }

.node-name { font-weight: 700; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.node-meta { font-size: 12px; color: var(--text-dim); margin-top: 2px; }

.node-meta code { background: rgba(0,0,0,0.06); padding: 1px 6px; border-radius: 6px; }

.node-status-label { font-size: 12px; font-weight: 700; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.04em; }

.node-badge { font-size: 10px; font-weight: 800; padding: 2px 7px; border-radius: 999px; letter-spacing: 0.04em; text-transform: uppercase; }

.node-badge.node-active { background: rgba(67,181,129,0.16); color: var(--green); }

.node-badge.node-standby { background: rgba(0,0,0,0.08); color: var(--text-dim); }

.node-lease {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 10px;
  margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--border-soft);
  font-size: 13px;
}

.node-lease-label { font-weight: 700; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.04em; font-size: 12px; }

.node-lease-owner code { background: rgba(0,0,0,0.06); padding: 1px 6px; border-radius: 6px; }

.node-lease-meta { color: var(--text-dim); }

.node-lease-meta.node-lease-stale { color: var(--red); font-weight: 700; }

.node-note { font-size: 12px; color: var(--text-faint); margin-top: 12px; }

/* General page — prefix editor + website log side by side */
.general-grid {
  display: grid;
  grid-template-columns: minmax(280px, 0.9fr) minmax(0, 1.6fr);
  gap: 16px;
  align-items: start;
}

/* Website log table */
.wlog-wrap {
  overflow-x: auto;
  border: 1px solid var(--border, #e3e3e8);
  border-radius: 10px;
}

.wlog-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.wlog-table thead th {
  text-align: left;
  padding: 10px 12px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-faint);
  border-bottom: 1px solid var(--border, #e3e3e8);
  background: rgba(0,0,0,0.02);
  white-space: nowrap;
}

.wlog-table tbody td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--border-soft, #eee);
  vertical-align: top;
}

.wlog-table tbody tr:last-child td { border-bottom: none; }

.wlog-table tbody tr:hover td { background: rgba(0,0,0,0.03); }

.wlog-sl { color: var(--text-faint); font-variant-numeric: tabular-nums; white-space: nowrap; width: 40px; }

.wlog-admin { font-weight: 600; white-space: nowrap; }

.wlog-content { color: var(--text); word-break: break-word; min-width: 200px; }

.wlog-time { color: var(--text-dim); white-space: nowrap; font-variant-numeric: tabular-nums; }

.wlog-empty {
  text-align: center;
  color: var(--text-faint);
  padding: 18px 12px !important;
  font-style: italic;
}

/* Website log pagination (10 rows per page) */
.wlog-pagination {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  padding-top: 10px;
  flex-wrap: wrap;
}

.wlog-page-btn {
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  padding: 4px 10px;
  font-size: 12px;
  color: var(--text-dim);
  cursor: pointer;
  min-width: 30px;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
}

.wlog-page-btn:hover:enabled { background: var(--surface-3); color: var(--text); }

.wlog-page-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}

.wlog-page-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.wlog-ellipsis { color: var(--text-faint); padding: 0 2px; }

/* ── 404 page ──────────────────────────────────────────────────────────────── */
.notfound-card {
  max-width: 560px;
  margin: 48px auto;
  padding: 40px 32px;
  text-align: center;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.notfound-graphic {
  position: relative;
  height: 150px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 8px;
}

.notfound-404 {
  font-size: 120px;
  font-weight: 900;
  line-height: 1;
  letter-spacing: -0.04em;
  display: flex;
  gap: 2px;
  z-index: 1;
  background: linear-gradient(180deg, var(--text), var(--text-dim));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.notfound-zero {
  position: relative;
  display: inline-block;
}

.notfound-zero::after {
  content: '';
  position: absolute;
  inset: 38% 28%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(88,101,242,0.9), rgba(88,101,242,0) 70%);
  z-index: -1;
  animation: notfound-pulse 2.6s ease-in-out infinite;
}

.notfound-orb {
  position: absolute;
  width: 220px;
  height: 220px;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 50%, rgba(88,101,242,0.18), transparent 65%);
  filter: blur(8px);
  z-index: 0;
}

.notfound-title {
  font-size: 26px;
  font-weight: 800;
  margin: 8px 0 6px;
  color: var(--text);
}

.notfound-text {
  font-size: 15px;
  color: var(--text-dim);
  line-height: 1.55;
  margin: 0 0 24px;
  max-width: 420px;
  margin-left: auto;
  margin-right: auto;
}

.notfound-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.notfound-hint {
  font-size: 13px;
  color: var(--text-faint);
}

.notfound-http {
  background: linear-gradient(180deg, var(--text), var(--text-dim));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.notfound-http span { display: block; }

@media (max-width: 600px) {
  .save-bar { gap: 12px; padding: 10px 12px; bottom: 12px; max-width: calc(100vw - 24px); }
  .save-bar-label { font-size: 13px; }
}

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

@media (max-width: 520px) {
  .notfound-404 { font-size: 84px; }
  .notfound-graphic { height: 110px; }
}

/* SVG icon wiring for the tab nav + side menu (current MPA markup). */
.menu-item { display: flex; align-items: center; gap: 10px; }
.menu-item-label { flex: 1; min-width: 0; }
.tab-ico { display: grid; place-items: center; color: var(--text-faint); flex: 0 0 auto; }
.tab-ico .ico { width: 17px; height: 17px; }
.menu-item.active .tab-ico { color: var(--accent-strong); }
.menu-bar-label { display: inline-flex; align-items: center; gap: 7px; }
.menu-bar-label .ico { width: 16px; height: 16px; color: var(--text-dim); }
.side-menu-close .ico { width: 16px; height: 16px; }
.back-btn .ico { width: 18px; height: 18px; }
.card-title .icon .ico,
.badge-section-head .ico,
.live-refresh-btn .ico { width: 17px; height: 17px; }

/* Auto-responder rows have a 4th element (Exact checkbox) — widen the grid. */
.reaction-row.ar-row {
  grid-template-columns: 1fr 1.4fr auto auto;
}
@media (max-width: 720px) {
  .reaction-row.ar-row { grid-template-columns: 1fr; }
}

/* ── Command documentation page ─────────────────────────────────────────── */
.docs-commands-layout { max-width: 1080px; }

.docs-search-wrap {
  position: relative;
  margin: 0 0 10px;
}
.docs-search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-faint);
  display: grid;
  place-items: center;
  pointer-events: none;
}
.docs-search-icon .ico { width: 17px; height: 17px; }
.docs-search {
  width: 100%;
  background: var(--surface-1);
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  padding: 13px 16px 13px 42px;
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.docs-search:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.docs-search::-webkit-search-cancel-button { cursor: pointer; }

.docs-meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 0 0 22px;
  color: var(--text-faint);
  font-size: 12.5px;
}
.docs-meta-hint kbd {
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
  border-radius: 5px;
  padding: 1px 7px;
  font-family: inherit;
  font-size: 11.5px;
}

.doc-cat { margin-bottom: 34px; }
.doc-cat-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-bottom: 10px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border-soft);
}
.doc-cat-head h2 { font-size: 19px; font-weight: 600; margin: 0; letter-spacing: -0.01em; }
.doc-cat-icon { color: var(--accent-strong); display: grid; place-items: center; }
.doc-cat-icon .ico { width: 19px; height: 19px; }
.doc-cat-count { margin-left: auto; color: var(--text-faint); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; }

.doc-cmd-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 14px;
}
.doc-cmd {
  background: var(--surface-1);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  transition: border-color var(--transition), transform var(--transition), box-shadow var(--transition);
}
.doc-cmd:hover { border-color: var(--border-strong); transform: translateY(-1px); box-shadow: var(--shadow-sm); }

.doc-cmd-head {
  display: flex;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 8px;
}
.doc-cmd-icon { color: var(--accent-strong); display: grid; place-items: center; margin-top: 3px; flex: 0 0 auto; }
.doc-cmd-icon .ico { width: 16px; height: 16px; }
.doc-cmd-name { margin:  0; font-size:  15.5px; font-weight:  600; flex:  1 1 auto; min-width:  0; }
.doc-cmd-name code {
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
  border-radius: 6px;
  padding: 2px 9px;
  color: var(--on);
  overflow-wrap: anywhere;
}
.doc-cmd-chips { margin-left: auto; display: flex; flex-wrap: wrap; gap:  6px; justify-content: flex-end; max-width:  100%; min-width:  0; }
.doc-chip {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 3px 9px;
  border-radius: 999px;
  white-space: nowrap;
}
.doc-chip-perm { background: var(--accent-soft); color: var(--accent-strong); }
.doc-chip-note { background: rgba(254, 231, 92, 0.14); color: var(--yellow); }

.doc-cmd-desc { color: var(--text-dim); font-size: 13.5px; line-height: 1.55; margin: 0 0 10px; }

.doc-cmd-aliases { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; color: var(--text-faint); font-size: 12px; margin-bottom: 8px; }
.doc-cmd-aliases code {
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
  border-radius: 5px;
  padding: 1px 7px;
  font-size: 11.5px;
  color: var(--text-dim);
}

.doc-cmd-usage { display: flex; flex-direction: column; gap: 5px; }
.doc-cmd-usage code {
  display: block;
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
  border-radius: 7px;
  padding: 6px 10px;
  font-size: 12px;
  color: var(--on);
  white-space: nowrap;
  overflow-x: auto;
}

.docs-empty {
  text-align: center;
  color: var(--text-faint);
  border: 1px dashed var(--border-soft);
  border-radius: var(--radius-lg);
  padding: 40px 16px;
}
.doc-hidden { display: none !important; }
/* === Mobile polish === */
/* Hide the PrimeBot brand (logo + "PrimeBot" wordmark + "Dashboard" sub)
   from the sticky header on phones so the scrollable top nav gets the whole row. */
@media (max-width: 760px) {
  .brand { display: none; }
}

/* Compact the login screen + tighten common page chrome on small screens. */
@media (max-width: 640px) {
  .container { padding-top: 20px; }
  .login-wrap { padding: 26px 14px 30px; }
  .login-hero { width: 64px; height: 64px; border-radius: 17px; margin-bottom: 12px; }
  .login-hero .ico { width: 34px; height: 34px; }
  .login-title { font-size: 25px; margin-bottom: 4px; letter-spacing: -0.02em; }
  .login-sub { font-size: 13.5px; margin-bottom: 18px; max-width: 100%; }
  .login-actions { flex-direction: column; align-items: stretch; margin-bottom: 14px; }
  .login-actions .btn, .login-actions + .btn { width: 100%; justify-content: center; }
  .feature-grid { grid-template-columns: 1fr; margin: 20px auto 0; }
  .stats-band { padding: 16px 14px; margin: 26px auto 0; }
  .stats-band-head { flex-direction: column; align-items: flex-start; gap: 5px; margin-bottom: 12px; }
  .stats-cards { gap: 9px; }
  .stat-value { font-size: 22px; }
  .donut-grid { gap: 9px; }
  .donut { width: 68px; height: 68px; }
  .page-head { margin-bottom: 16px; }
  .card { padding: 16px 14px; }
  .card-title { font-size: 15.5px; }
  .guild-header-card { padding: 16px 14px; }
  .guild-header-card .guild-icon { width: 46px; height: 46px; }
  .settings-nav { top: 0; }
  .settings-nav .menu-item { padding: 8px 10px; }
  .wlog-wrap, .badge-table-wrap { border-radius: 8px; }
  .footer { padding: 16px 14px; flex-direction: column; gap: 6px; }
  .footer-links { margin-left: 0; }
}

/* Ticket panel editor: horizontal tabs (green active glow / blue idle).
 * Wide screens: tabs wrap naturally into 1–2 tidy rows. Narrow screens: the row
 * itself scrolls horizontally (overflow contained in the tab bar) so the page
 * never overflows — tabs keep a comfortable ~44px touch height. */
.tk-editor-tabs {
  display: flex; flex-wrap: wrap; gap: 6px;
  margin-bottom: 16px;
  max-width: 100%;
}
.ticket-editor-top {
  display: flex; align-items: center; justify-content: space-between; gap:  10px;
  flex-wrap: wrap;
  margin-bottom:  14px;
  max-width: 100%;
}
.ticket-editor-actions {
  display: flex; flex-wrap: wrap; gap:  8px;
  max-width: 100%;
}
.tk-editor-tab {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 14px;
  min-height: 40px;
  font-size: 13px; font-weight: 600;
  font-family: var(--font-body);
  color: var(--text-dim);
  background: var(--surface-2);
  border: 1px solid rgba(88,101,242, 0.35);
  border-radius: var(--radius-sm);
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 0 14px rgba(88,101,242, 0.22);
  transition: color var(--transition), background var(--transition), border-color var(--transition), box-shadow var(--transition), transform var(--transition);
}
.tk-editor-tab .ico { width: 17px; height: 17px; color: var(--accent-strong); flex: 0 0 auto; }
.tk-editor-tab:hover { color: var(--text); border-color: rgba(88,101,242, 0.55); box-shadow: 0 0 18px rgba(88,101,242, 0.32); }
.tk-editor-tab.active {
  color: #fff;
  background: linear-gradient(135deg, #27b97c, #3ecf8e);
  border-color: rgba(62, 207, 142, 0.6);
  box-shadow:  0 0 20px rgba(62, 207, 142, 0.45), inset  0 1px 0 rgba(255, 255, 255, 0.25);
}
.tk-editor-tab.active .ico { color: #fff; }
.tk-editor-panels .tab-panel { padding-top: 2px; min-width: 0; }
.tk-editor-panels { min-width: 0; }

/* Ticket editor: embed-builder (Ticket Tool "Panel Embed Settings" style).
 * The panel embed's editing fields live ON the embed — each embed region's field
 * controls sit above a tiny Discord-styled live render of that region, so editing
 * "shows as the embed" instead of a detached live-preview pane.
 */
.tk-live-preview-card { background: var(--surface-2); }
.tk-live-preview-card .card-title { font-size: 15px; }

/* Embed-builder regions (fields attached to embed sections). */
.tk-embed-builder {
  display: flex; flex-direction: column; gap:  clamp(8px, 1.2vw, 12px);
  background: #313338;
  border-radius:  10px;
  padding:  clamp(10px, 1.6vw, 16px);
  box-shadow: inset  0 1px 0 rgba(255, 255, 255,  0.04);
  min-width:  0;
  max-width:  100%;
  box-sizing: border-box;
}
.edb-region {
  display: flex; flex-direction: column; gap:  8px;
  background: rgba(0, 0, 0,  0.18);
  border:  1px solid rgba(255, 255, 255,  0.06);
  border-radius:  8px;
  padding: 10px 12px;
  min-width:  0;
  max-width:  100%;
  box-sizing: border-box;
}
.edb-field-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.edb-label {
  font-size:  10.5px; font-weight:  600; letter-spacing:  0.07em;
  text-transform: uppercase; color: #949ba4;
  padding-top: 1px;
}
.edb-region input[type="text"],
.edb-region textarea,
.edb-region select {
  font-size:  13px; color: #e9ecf3;
  background: rgba(0, 0, 0,  0.25);
  border:  1px solid rgba(255, 255, 255,  0.10);
  border-radius:  6px;
  padding:  7px 9px;
  outline: none;
  width:  100%;
  max-width:  100%;
  box-sizing: border-box;
  overflow-wrap: break-word;
}
.edb-region textarea { resize: vertical; min-height: 44px; line-height: 1.45; }
.edb-region input:focus,
.edb-region textarea:focus,
.edb-region select:focus { border-color: rgba(88,101,242,  0.7); }
.edb-duo { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap:  10px; }
.edb-triple { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(130px, 0.75fr); gap:  10px; }

/* Live Discord-styled output of each embed region (inside the builder).) */
.edb-live {
  min-height:  18px;
  font-size:  12.5px; line-height:  1.4;
  color: #c7cbcf;
  border-radius:  6px;
  padding:  3px 2px;
  overflow-wrap: anywhere;
  word-break: break-word;
  min-width:  0;
  max-width:  100%;
}
.edb-live.empty,
.edb-live.edb-empty { color: #6a7078; font-style: italic; font-size: 11.5px; }
.edb-live.edb-empty::after { content: 'Not configured'; }
.edb-live-content,
.edb-live-title { color: #e9ecf3; font-weight:  600; font-size:  13.5px; }
.edb-live-desc { white-space: pre-wrap; }
.edb-live-author { display: flex; align-items: center; gap:  6px; font-size:  12.5px; font-weight:  600; color: #e9ecf3; }
.edb-author-icon { width:  18px; height:  18px; border-radius:  50%; object-fit: cover; flex:   0 0 auto; }
/* The .edb-thumb/.edb-image class collision: these classes are ALSO applied
 * to the live <img> elements (renamed .edb-thumb-img/.edb-image-img). The old
 * rules collapsed the region wrappers (64px float / display:block), spilling
 * their label+input payload onto neighboring sections. Region wrappers are now
 * plain block-flow cards; ONLY the img elements get sizing. */
.edb-region.edb-thumb,
.edb-region.edb-image {
  display: flex; flex-direction: column; width: auto; max-width: 100%;
  height: auto; min-height: 0; float: none;
}
.edb-thumb-img { width:  64px; height:  64px; max-width: 100%; border-radius:  8px; object-fit: cover; display: block; margin-top: 2px; }
.edb-image-img { width:  100%; max-width:  100%; max-height:  200px; height: auto; border-radius:  8px; object-fit: cover; display: block; margin-top: 2px; }
/* In the detached live preview (right column) the thumbnail hugs the right
 * edge like Discord (float among the body rows); in the in-region builder
 * previews it stays as a plain block so it can never overlap the next row. */
.edb-preview-embed-body .edb-live-thumb { float: right; margin:  2px 0 6px 12px; }
.edb-preview-embed-body .edb-live-thumb.edb-empty,
.edb-preview-embed-body .edb-live-thumb .hidden { display: none; }
.edb-preview-embed-body .edb-live-image { clear: both; }
.edb-live-footer { display: flex; gap:  6px; align-items: center; color: #8f949e; font-size:  11.5px; min-height: 18px; }
.edb-live-footer .tk-preview-embed-time::before { content: ' • '; }

/* The embed region wrapper: keep the Discord embed look (bar + body).). */
.edb-preview-embed { margin-top: 4px; }
.edb-region-color {
  display: flex; flex-direction: column; gap:  6px;
}
.edb-color-fields { display: flex; gap:  8px; align-items: center; flex-wrap: wrap; }
.edb-color-fields input[type="color"] { width:  38px; height:  34px; padding:  2px; border-radius:  6px; background: rgba(0, 0, 0,  0.2); border:  1px solid rgba(255, 255, 255,  0.1); flex:  0 0 auto; cursor: pointer; }
.edb-color-fields input[type="text"] { font-size:  12.5px; color: #e9ecf3; background: rgba(0, 0, 0,  0.25); border:  1px solid rgba(255, 255, 255,  0.10); border-radius:  6px; padding:  6px 9px; min-width:  0; flex:  1 1 140px; }
/* Premium Message tab — two-column builder + live Discord preview. The preview
 * is a detached Discord-style card; its rows share node names but live under
 * edb-pv-* ids so the in-region live rows (edb-title etc.) and the preview
 * (edb-pv-title etc.) both update from the same normalized editor state.
 *
 * Desktop: a balanced `minmax(0,1fr) / minmax(360px,.8fr)` grid so the builder
 * gets comfortable input widths and the preview stays Discord-readable; neither
 * column can push the page wider (minmax(0,…) forbids min-content blowout).
 * Below ~1024px content width there is no longer enough room for both, so the
 * grid drops to a single column in the natural order builder → preview (the
 * preview can never be squeezed into a tiny sidebar). */
.edb-builder-cols {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(340px, 0.8fr); gap:  clamp(18px, 2.4vw, 28px); align-items: start;
  min-width:  0;
  width:  100%;
  max-width:  100%;
}
.edb-builder-left { min-width: 0; display: flex; flex-direction: column; gap:  12px; max-width: 100%; }
.edb-builder-right { min-width:  0; position: sticky; top:  18px; align-self: start; max-width: 100%; }
.edb-preview-embed-wrap { background: var(--surface-2); border:  1px solid var(--border-soft); border-radius:  12px; padding:  clamp(12px, 1.6vw, 18px); max-width:  100%; box-sizing: border-box; }
.edb-preview-embed-wrap .edb-preview-head {
  display: flex; align-items: center; justify-content: space-between; gap:  8px;
  margin-bottom:  10px; font-size:  12px; font-weight:  700; letter-spacing:  0.05em;
  text-transform: uppercase; color: #949ba4;
  min-width:  0;
}
.edb-preview-embed-wrap .edb-preview-head .ico { width:  15px; height:  15px; color: var(--accent-strong); }
.edb-preview-embed-wrap .edb-preview-head > span:first-child { display: inline-flex; align-items: center; gap:  7px; }
.edb-preview-live-dot { width:  8px; height:  8px; border-radius:  50%; background: #3ba55d; box-shadow:  0 0 8px rgba(59, 165, 93, 0.7); animation: edb-pulse 2s ease-in-out infinite; }
.edb-preview-embed-wrap .tk-preview-embed { background: #2b2d31; }

/* Region sections — clear titles, hints, vertical rhythm. Never their
 * children float or overlap: every region is block-flow(auto height. */
.edb-section-head { display: flex; align-items: baseline; justify-content: space-between; margin:  2px 0 1px; }
.edb-section-title {
  font-size:  11px; font-weight:  700; letter-spacing:  0.08em;
  text-transform: uppercase; color: #cfd3da; margin:  0;
}
.edb-section-hint { font-size:  11.5px; line-height:  1.4; color: #8f949e; margin:  0 0 2px; }
.edb-field { display: flex; flex-direction: column; gap:  5px; min-width:  0; max-width:  100%; position: relative; }
.edb-field .edb-label { font-size:  10.5px; letter-spacing:  0.06em; text-transform: uppercase; color: #949ba4; }
.edb-field input,
.edb-field textarea,
.edb-field select { width:  100%; max-width:  100%; box-sizing: border-box; }
.edb-note { margin:  0; font-size:  11px; line-height:  1.35; min-height:  0; color: transparent; overflow-wrap: anywhere; }
.edb-note.edb-url-error { color: #f23f43; }
.edb-note.edb-char-limit { color: #f0b232; }
.edb-note:empty { display: none; }
.edb-counter {
  display: block; text-align: right; font-size:  10px; color: #7d848c;
  margin-top:  1px; line-height:  1; user-select: none;
}
.edb-counter.edb-over { color: #f23f43; font-weight:  600; }

/* Live preview links (title/author URLs are invisible but clickable,. */
.edb-live a { color: inherit; text-decoration: none; }
.edb-live a:hover { text-decoration: underline; }
.edb-live .hidden { display: none; }
.edb-footer-icon { width:  16px; height:  16px; max-width:  100%; border-radius:  50%; object-fit: cover; flex:   0 0 auto; }

/* Save-state pill(Message tab) — no-op until the client marks dirty. */
.edb-save-state {
  display: inline-flex; align-items: center; gap:  7px;
  font-size:  12px; color: #9aa4b0; background: rgba(255, 255, 255,  0.04);
  border:  1px solid rgba(255, 255, 255,  0.08); border-radius:  999px;
  padding:  5px 12px; margin-top:  8px; transition: color var(--transition), border-color var(--transition), background var(--transition);
}
.edb-save-state .edb-save-dot { width:  8px; height:  8px; border-radius:  50%; background: #3ba55d; box-shadow:  0 0 8px rgba(59, 165, 93, 0.7); transition: background var(--transition), box-shadow var(--transition);
}
.edb-save-state.dirty { color: #f0b232; border-color: rgba(240, 178, 50, 0.45); }
.edb-save-state.dirty .edb-save-dot { background: #f0b232; box-shadow:  0 0 8px rgba(240, 178, 50, 0.6); }
.edb-save-state.saving { color: #9aa4b0; }
.edb-save-state.saving .edb-save-dot { background: #5865F2; box-shadow:  0 0 8px rgba(88, 101, 242, 0.7); animation: edb-pulse 1s ease-in-out infinite; }
.edb-save-state.saved { color: #3ba55d; }
.edb-save-state.saved .edb-save-dot { background: #3ba55d; box-shadow:  0 0 8px rgba(59, 165, 93, 0.7); }
@keyframes edb-pulse { 0%,100% { opacity:  1; } 50% { opacity:  0.45; } }

/* Reset-embed button. */
.edb-reset {
  background: transparent; border:  1px solid rgba(255, 255, 255,  0.12);
  color: #c7cbcf; border-radius:  6px; padding:  2px 8px;
  font-size:  14px; line-height:  1.4; cursor: pointer;
}
.edb-reset:hover { border-color: #f23f43; color: #f23f43; }

/* ── Embed Fields (Message → Fields) ───────────────────────────────────────
 * Field editor cards + live preview rows. Cards grow with their content
 * (normal flow; no fixed heights) so adding fields never overlaps the footer /
 * buttons, and everything stays usable from 320px up to ultra-wide. */
.edb-fields-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.edb-fields-head .edb-section-hint { margin: 0; flex: 1 1 220px; }
.edb-fields-empty { font-size: 12px; color: #6a7078; font-style: italic; padding: 6px 2px; }
.edb-fields-list { display: flex; flex-direction: column; gap: 12px; margin-top: 10px; max-width: 100%; }
.edb-field-card {
  background: var(--surface-2, #232428);
  border: 1px solid var(--border-soft, rgba(255,255,255,0.08));
  border-radius: 10px;
  padding: 12px;
  display: flex; flex-direction: column; gap: 12px;
  max-width: 100%; box-sizing: border-box;
}
.edb-field-card-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.edb-grip { cursor: grab; color: #6a7078; display: inline-flex; }
.edb-field-num { font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: #949ba4; flex: 1 1 auto; }
.edb-field-actions { display: inline-flex; gap: 8px; }
.edb-field-card .edb-duo.edb-field-name-row { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; }
.edb-field-card .edb-field { display: flex; flex-direction: column; gap: 5px; min-width: 0; max-width: 100%; }
.edb-field-card textarea { min-height: 64px; resize: vertical; }
.edb-field-inline { display: flex; align-items: center; gap: 8px; }
.edb-field-inline .edb-label-inline { font-size: 12px; color: #c7cbcf; }

/* Field rows inside the Discord preview (placed between image and footer). */
.edb-preview-embed-body .edb-live-fields { clear: both; display: flex; flex-direction: column; gap: 8px; margin: 2px 0 6px; }
.tk-preview-embed-field { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.tk-preview-embed-field.inline { flex: 1 1 30%; min-width: 0; }
.edb-preview-embed-body .edb-live-fields { flex-flow: row wrap; align-items: flex-start; }
.tk-preview-embed-field-name { font-size: 12.5px; font-weight: 700; color: #e9ecf3; overflow-wrap: anywhere; }
.tk-preview-embed-field-value { font-size: 12.5px; color: #dcddde; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.4; }
.edb-region.edb-fields .edb-live-fields { margin-top: 6px; }
.edb-region.edb-fields .tk-preview-embed-field { border-left: 2px solid rgba(88,101,242,0.4); padding-left: 8px; margin-bottom: 4px; }

/* Mobile: field cards widen, no side-by-side squeeze. */
@media (max-width: 720px) {
  .edb-fields-head { flex-direction: column; align-items: flex-start; }
  .edb-field-card-head { flex-wrap: wrap; }
  .edb-field-actions { margin-left: auto; }
  .edb-preview-embed-body .edb-live-fields { flex-direction: column; }
  .tk-preview-embed-field.inline { flex: 1 1 100%; }
}
@media (max-width: 420px) {
  .edb-field-card { padding: 10px; }
  .edb-field-actions .btn { font-size: 11px; padding: 4px 8px; }
}

/* Open-ticket button region (live output beneath its fields).). */
.edb-live-button { display: flex; }
.edb-btn-emoji { display: inline-flex; }
.edb-live-button .tk-preview-button { font-size:  12.5px; padding:  6px 12px; }

/* Discord-style live preview (kept for backward-compat/output helpers). */
.tk-preview-discord {
  display: flex; flex-direction: column; gap:  8px;
  background: #313338;
  border-radius:  10px;
  padding:  16px;
  box-shadow: inset  0 1px 0 rgba(255, 255, 255,  0.04);
}
.tk-preview-content-line {
  background: #2b2d31;
  color: #dcddde;
  font-size:  13px;
  line-height:  1.45;
  border-radius:  8px;
  padding:  8px 12px;
  white-space: pre-wrap;
  word-break: break-word;
}
.tk-preview-plain {
  background: #2b2d31;
  color: #dcddde;
  font-size:  13.5px;
  line-height:  1.5;
  border-radius:  8px;
  padding:  10px 12px;
  white-space: pre-wrap;
}
.tk-preview-embed {
  display: flex;
  gap:  12px;
  align-items: stretch;
  background: #2b2d31;
  border-radius:  4px;
  padding:  12px 16px;
  min-width:  0;
  width:  100%;
  max-width:  100%;
  box-sizing: border-box;
  overflow-wrap: break-word;
}
.tk-preview-embed-bar { width:  4px; border-radius: 2px; background: #5865F2; flex:  0 0 auto; }
.tk-preview-embed-body { min-width: 0; flex:  1 1 auto; max-width: 100%; }
.tk-preview-embed-title { color: #e9ecf3; font-size:  15px; font-weight:  700; line-height:  1.3; margin-bottom:  4px; overflow-wrap: anywhere; }
.tk-preview-embed-desc { color: #c7cbcf; font-size:  13px; line-height:  1.45; margin-bottom:  8px; white-space: pre-wrap; overflow-wrap: anywhere; word-break: break-word; min-width: 0; }
.tk-preview-embed-thumb-wrap { float: right; margin:  2px 0 8px 12px; max-width: 40%; }
.tk-preview-embed-thumb { width:  80px; height:  80px; max-width:  100%; border-radius:  8px; object-fit: cover; }
.tk-preview-embed-img-wrap { margin:  4px 0; width:  100%; }
.tk-preview-embed-img { width:  100%; max-width:  100%; max-height:  260px; height:  auto; border-radius:  8px; object-fit: cover; display: block; }
.tk-preview-embed-footer { color: #8f949e; font-size:  11.5px; line-height:  1.4; margin-top:  8px; display: flex; gap:  6px; align-items: center; min-width: 0; overflow-wrap: anywhere; }
.tk-preview-embed-footer-text + .tk-preview-embed-time::before { content: ' • '; }

/* Discord button (open) in the preview */
.tk-preview-button {
  display: inline-flex; align-items: center; justify-content: center; gap:  7px;
  font-size:  13px; font-weight:  600;
  padding:  9px 15px;
  border-radius:  4px;
  align-self: flex-start;
  max-width:  100%;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.tk-preview-button-primary { background: #5865F2; color: #fff; }
.tk-preview-button-secondary { background: #4E5058; color: #fff; }
.tk-preview-button-success { background: #248046; color: #fff; }
.tk-preview-button-danger { background: #DA373C; color: #fff; }
.tk-preview-button-link { background: transparent; color: #00A8FC; text-decoration: underline; }

/* Ticket editor responsive behavior.
 *
 * The layout is built fluid-first (grid/flex with minmax(0,…), clamp() padding
 * and 100%-width controls), so these breakpoints only handle where the
 * multi-column arrangements genuinely stop fitting — they are not "mobile
 * patches" bolted onto a fixed desktop layout.
 *
 * 1000px:  the builder (Message tab) no longer has room for side-by-side
 *          regions → single column builder → preview; sticky preview disabled.
 * 1180px:  the editor's quick-actions toolbar + ticket tabs become compact and
 *          the tabs scroll horizontally instead of stacking rows.
 * 920px:   wide edit regions (duo/triple field groups) collapse to one column.
 * 720px:   any remaining multi-column editor rows collapse; preview turns into
 *          the vertical Discord-embed layout (color bar on top).
 * 480px:   tightest phones — compact card padding and touch-friendly rows. */
@media (max-width:  1000px) {
  .edb-builder-cols { grid-template-columns:  1fr; gap:  18px; }
  .edb-builder-right { position: static; }
  .edb-builder-left { order:  1; }
  .edb-builder-right { order:  2; }
}

@media (max-width:  1180px) {
  .tk-editor-tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: rgba(88,101,242,0.5) transparent;
    padding-bottom: 4px;
  }
  .tk-editor-tabs::-webkit-scrollbar { height: 6px; }
  .tk-editor-tabs::-webkit-scrollbar-thumb { background: rgba(88,101,242,0.4); border-radius: 999px; }
  .tk-editor-tabs::-webkit-scrollbar-track { background: transparent; }
  .tk-editor-tab { flex: 0 0 auto; }
}

@media (max-width:  920px) {
  .edb-duo,
  .edb-triple { grid-template-columns: 1fr; }
  .edb-triple { display: flex; flex-direction: column; align-items: stretch; }
  .edb-duo { display: flex; flex-direction: column; align-items: stretch; gap: 8px; }
}

@media (max-width:  720px) {
  .tk-embed-builder { padding:  8px; gap:  8px; }
  .edb-region { padding:  8px 10px; }
  .edb-preview-embed-wrap { padding:  12px; }
  .tk-preview-embed {
    flex-direction: column;
    gap:  8px;
    padding:  10px 12px;
  }
  .tk-preview-embed-bar { width:  100%; height:  4px; flex:  0 0 auto; border-radius:  2px; }
  .edb-thumb-img { float: none; width:  56px; height:  56px; margin-bottom:  4px; }
  .edb-image-img { max-height:  160px; }
  .ticket-editor-actions {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 2px;
  }
  .ticket-editor-actions::-webkit-scrollbar { display: none; }
  .ticket-editor-actions .btn { flex: 0 0 auto; }
}

@media (max-width:  480px) {
  .edb-region { padding:  8px; }
  .edb-builder-cols { gap:  14px; }
  .tk-btn-chip-head { padding:  10px; gap:  7px; }
  .tk-btn-chip-name { min-width:  76px; }
  /* Field label + control always stack; the color picker keeps its swatch row
     but the HEX input may wrap to its own line — never out of the card. */
  .edb-color-fields input[type="text"] { flex:  1 1 100%; }
}

/* Ticket Buttons tab — configurable button chips withd slide open / slide shut
   dropdowns (Ticket Tool style). A chip header shows the button name + a live
   label/emoji preview + a chevron; tapping it slides its builder panel open
   (grid-template-rows height transition) and again closes it. */
.tk-buttons-builder {
  display: flex; flex-direction: column; gap:  8px; margin-top:  6px;
}
.tk-btn-chip {
  border:  1px solid rgba(255, 255, 255, 0.10);
  border-radius:  8px;
  background: rgba(255, 255, 255, 0.025);
  overflow: hidden;
  transition: border-color  0.15s ease, background  0.15s ease;
}
.tk-btn-chip:hover { border-color: rgba(88,101,242, 0.45); }
.tk-btn-chip.open { border-color: rgba(88,101,242,  0.55); background: rgba(88,101,242, 0.06); }
.tk-btn-chip-head {
  display: flex; align-items: center; gap:  10px;
  width:  100%;
  background: none;
  border: none;
  padding:  10px 12px;
  color: #e9ecf3;
  font: inherit;
  font-weight:  600;
  font-size:  13.5px;
  text-align: left;
  cursor: pointer;
}
.tk-btn-chip-name {
  min-width:  92px;
  color: #c7cbcf;
  font-size:  12.5px;
  text-transform: capitalize;
  letter-spacing:  0.4px;
}
.tk-btn-chip-live {
  display: flex; align-items: center; gap:  6px;
  flex:   1;
  font-weight:  600;
  color: #e9ecf3;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.tk-btn-chip-emoji { font-size:  15px; }
.tk-btn-chip-label { overflow: hidden; text-overflow: ellipsis; }
.tk-btn-chip-label.empty { color: #6a7078; font-style: italic; font-weight:  500; }
.tk-btn-chip-chev {
  color: #6a7078;
  transition: transform  0.22s ease, color  0.15s ease;
}
.tk-btn-chip.open .tk-btn-chip-chev { transform: rotate(180deg); color: #e9ecf3; }
.tk-btn-chip-head:focus-visible {
  outline: none;
  box-shadow:  0 0 0  2px rgba(88,101,242,  0.35);
  border-radius:  8px;
}
.tk-btn-dropdown {
  height:  0;
  overflow: hidden;
  transition: height  0.28s cubic-bezier(0.22,  1,  0.36,  1);
}
.tk-btn-dropdown > .tk-btn-fields { padding:  2px 12px 12px; }
.tk-btn-dropdown > .field-hint { padding:  0 12px 12px; }
.tk-btn-fields .field { margin-bottom:  10px; min-width: 0; }
.tk-btn-fields .field:last-child { margin-bottom: 0; }
.tk-btn-fields { min-width: 0; max-width: 100%; }
.tk-btn-fields .edb-duo { gap: 8px; }


/* ── Ticket editor: Panel components.builder (Panel tab) ──────────────
 * Ticket Tool-style reusable multi-input builder: buttons + dropdowns, each
 * with per-input ticket configuration and (for dropdowns) labeled/described
 * options. Rows are reorderable; selects capped at 25 options. Explicit
 * `position` values are stored (never insertion order) so synchronization and
 * re-ordering survive reloads. The builder toggle falls the panel back to its
 * legacy single Open Ticket button. */

.pcomp-list {
  display: flex; flex-direction: column; gap:  10px;
  margin-top:  12px;
}
.pcomp-row {
  display: flex; flex-wrap: wrap; align-items: center; gap:  8px;
  background: var(--surface-2);
  border:  1px solid var(--border-soft);
  border-radius:  10px;
  padding:  10px 12px;
}
.pcomp-row.pcomp-select-row { background: rgba(88,101,242,  0.06); }
.pcomp-grip {
  display: inline-flex; align-items: center; color: #6a7078;
  cursor: grab; flex:  0 0 auto;
}
.pcomp-grip:active { cursor: grabbing; }
.pcomp-grip .ico { width:  16px; height:  16px; }
.pcomp-type {
  font-size:  12px; font-weight:  700; letter-spacing:  0.05em;
  text-transform: uppercase; color: var(--accent-strong);
  white-space: nowrap;
}
.pcomp-row input[type="text"],
.pcomp-row input[type="number"],
.pcomp-row select {
  padding:  8px 10px; background: var(--bg); border:  1px solid var(--border);
  border-radius:  8px; color: var(--text); font-size:  12.5px; min-width:  0;
}
.pcomp-row input.pcomp-label { flex:  1 1 180px; }
.pcomp-row input.pcomp-emoji { flex:  0 1 90px; }
.pcomp-row select.pcomp-style { flex:  0 1 110px; }
.pcomp-range { display: flex; gap:  8px; align-items: center; flex:  0 1 auto; }
.pcomp-range label { display: flex; align-items: center; gap:  4px; font-size:  11.5px; color: var(--text-dim); }
.pcomp-range input { width:  56px; }
.pcomp-summary {
  display: flex; flex-wrap: wrap; align-items: center; gap:  6px;
  font-size:  11.5px; color: var(--text-dim); flex:  1 1 140px; min-width:  0;
}
.pcomp-type-tag {
  font-size:  10px; font-weight:  700; text-transform: uppercase;
  letter-spacing:  0.06em; color: var(--accent-strong);
  border:  1px solid rgba(88,101,242,  0.35); border-radius:  999px;
  padding:  2px 8px; white-space: nowrap;
}
.pcomp-options {
  display: flex; flex-direction: column; gap:  6px;
  margin-top:  4px;
}
.pcomp-opt-row {
  display: flex; flex-wrap: wrap; align-items: center; gap:  6px;
  background: rgba(0, 0, 0,  0.16); border-radius:  8px; padding:  6px 8px;
}
.pcomp-opt-row .pcomp-opt-label { flex:  1 1 170px; }
.pcomp-opt-row .pcomp-opt-emoji { flex:  0 1 80px; }
.pcomp-opt-row .pcomp-opt-desc { flex:  2 1 220px; }
.pcomp-opt-row .pcomp-opt-value { flex:  0 1 100px; }
.pcomp-cfg-hint { margin:  2px 0 0; font-size:  11px; }
.pcomp-cfg-summary { font-size:  11px; color: var(--text-dim); flex:  1 1 100%; }
.pcomp-addbar { display: flex; gap:  8px; margin-top:  4px; }
.pcomp-addbar .btn .ico , .pcomp-cfg .ico { width:  14px; height:  14px; }

/* Reorder drag affordance fallback. */
.pcomp-row.dragging { opacity:  0.55; border-style: dashed; }

/* Per-input ticket configuration modal (slides atop the editor.). */
.pcfg-modal { display: none; }
.pcfg-modal.open { display: flex; }
.pcfg-modal .modal-card {
  max-width:  520px; width:  100%;
}
.pcfg-modal .field { margin-bottom:  10px; }
.pcfg-modal input[type="text"] {
  width:  100%; box-sizing: border-box; padding:  9px 10px;
  background: var(--bg); border:  1px solid var(--border); border-radius:  8px; color: var(--text);
}
.pcfg-modal .modal-actions { display: flex; justify-content: flex-end; gap:  8px; margin-top:  14px; flex-wrap: wrap; }

@media (max-width:  920px) {
  .pcomp-opt-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    align-items: center;
  }
  .pcomp-opt-row .pcomp-opt-desc { flex: none; grid-column: 1 / -1; }
  .pcomp-opt-row .pcomp-opt-label,
  .pcomp-opt-row .pcomp-opt-emoji,
  .pcomp-opt-row .pcomp-opt-value,
  .pcomp-opt-row .pcomp-opt-del { width: 100%; min-width: 0; }
  .pcomp-opt-row .pcomp-opt-cfg { justify-self: start; }
}

@media (max-width:  720px) {
  .pcomp-row { align-items: stretch; }
  .pcomp-row input.pcomp-label { flex-basis: 100%; }
  .pcomp-opt-row {
    display: flex;
    flex-direction: column;
    align-items: stretch;
  }
  .pcomp-opt-row .pcomp-opt-desc { grid-column: auto; }
  .pcomp-opt-row .btn,
  .pcomp-opt-row .reaction-remove { align-self: flex-start; }
}

/* Touch controls inside the ticket editor — comfortable tap targets on
 * phones without inflating the desktop chrome. */
@media (max-width: 720px) {
  .tk-editor-tabs .tk-editor-tab,
  .ticket-editor-actions .btn,
  .pcomp-addbar .btn,
  .tk-btn-chip-head,
  .edb-reset,
  .pcomp-opt-row .btn,
  .pcomp-opt-row .reaction-remove { min-height: 40px; }
  .pcomp-opt-row .reaction-remove,
  .pcomp-row .reaction-remove { width: 36px; height: 36px; display: inline-flex; align-items: center; justify-content: center; }
  .edb-reset { min-width: 40px; }
}

/* Ticket editor: Permission tab role rows (2-item: role select + remove) and
 * the Ticket tab's per-state role add/remove groups. These sit inside the
 * editor's own panel, so they are scoped there and never affect the normal
 * reaction-role menu builders. */
.tk-editor-panels .reactions-list .reaction-row {
  grid-template-columns: minmax(0, 1fr) auto;
}
.tk-editor-panels .reactions-list .reaction-row select {
  width: 100%;
  min-width: 0;
  padding: 9px 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
}
.tk-editor-panels .reactions-list .reaction-row input:focus,
.tk-editor-panels .reactions-list .reaction-row select:focus { outline: none; border-color: var(--accent); box-shadow: var(--ring); }

.trole-group {
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  padding: 14px;
  margin-bottom: 14px;
}
.trole-header { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.trole-title { font-weight: 700; font-size: 14.5px; letter-spacing: 0.01em; }
.trole-attrs { display: flex; flex-wrap: wrap; gap: 10px 18px; margin: 2px 0 12px; }
.trole-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; }
.trole-col { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.trole-col select { width: 100%; }

@media (max-width: 720px) {
  .trole-row { grid-template-columns: 1fr; }
}

/* Reduced-motion: disable the pulse + builder buffer animations for users who
 * ask for less motion. Strictly additive; layout is never animation-dependent. */
@media (prefers-reduced-motion: reduce) {
  .edb-preview-live-dot,
  .edb-save-state .edb-save-dot,
  .edb-save-state.saving .edb-save-dot { animation: none !important; }
  .edb-region { transition: none !important; }
}

/* ── Embed Builder (Features → Embed) ───────────────────────────────────────
 * A premium Discord embed builder: builder (left) + sticky live preview
 * (right) on desktop, single-column stacked on mobile. All controls reuse the
 * existing edb-* design system from the ticket editor for visual consistency.
 * The builder is fluid-first (minmax(0,…), clamp()) so it never overflows. */
.embed-builder-card .card-title { align-items: center; gap: 12px; }
.embed-builder-badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 10.5px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase;
  color: #f8c97a;
  background: rgba(240, 178, 50, 0.12);
  border: 1px solid rgba(240, 178, 50, 0.35);
  border-radius: 999px;
  padding: 4px 12px;
  white-space: nowrap;
}
@media (max-width: 640px) {
  .embed-builder-card .card-title { flex-wrap: wrap; }
}

/* Grouped title-right cluster (badge + optional action button, e.g. Refresh). */
.card-title-actions {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

/* "How to send this embed" callout on the Embed Builder page. */
.embed-send-hint {
  display: block;
  padding: 12px 14px;
  margin: 0 0 16px;
  border-radius: var(--radius-sm);
  background: var(--surface-1);
  border: 1px solid var(--border-soft);
}
.embed-send-hint .esh-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  font-weight: 700;
  color: var(--text);
}
.embed-send-hint .esh-title .ico { width: 16px; height: 16px; color: var(--accent-strong); }
.embed-send-hint ul { margin: 8px 0; padding-left: 20px; }
.embed-send-hint li { margin: 4px 0; }
.embed-send-hint .esh-note { margin: 8px 0 0; opacity: 0.85; }

.embed-builder-toolbar {
  display: flex; align-items: center; flex-wrap: wrap; gap: 8px;
  margin: 14px 0 4px;
}
.embed-builder-toolbar .btn { white-space: nowrap; }

.embed-templates {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin: 10px 0 2px;
}
.embed-templates-label {
  font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: #949ba4;
  flex: 0 0 auto;
}
.embed-templates-list { display: flex; flex-wrap: wrap; gap: 6px; }
.embed-template-chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 600; color: #c7cbcf;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 999px;
  padding: 5px 12px;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
  white-space: nowrap;
}
.embed-template-chip .ico { width: 13px; height: 13px; }
.embed-template-chip:hover {
  border-color: rgba(88, 101, 242, 0.55);
  background: rgba(88, 101, 242, 0.1);
  color: #fff;
}

.embed-builder-grid { margin-top: 12px; }

/* Disabled region style (section greyed when its enable-switch is off). */
.edb-region.embed-region-disabled { opacity: 0.55; }
.edb-region.embed-region-disabled input,
.edb-region.embed-region-disabled textarea { color: #6a7078; }

.edb-region .edb-section-title { display: inline-flex; align-items: center; gap: 7px; }
.edb-region .edb-section-title .ico { width: 14px; height: 14px; color: var(--accent-strong); }
.embed-fields-count {
  font-size: 10px; font-weight: 600; color: #8f949e;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 999px;
  padding: 2px 8px;
  margin-left: 4px;
  vertical-align: 1px;
}
.edb-field .edb-counter { margin-top: 3px; }

/* Validation strip under the preview. */
.edb-validation-strip {
  margin-top: 10px;
  display: flex; flex-direction: column; gap: 4px;
  min-height: 0;
}
.edb-validation-strip p { margin: 0; font-size: 11.5px; line-height: 1.4; overflow-wrap: anywhere; }
.edb-validation-strip .edb-validation-error { color: #f23f43; }
.edb-validation-strip .edb-validation-warn { color: #f0b232; }
.edb-validation-strip .edb-validation-ok { color: #3ba55d; }
.edb-validation-strip.has-error { padding: 8px 10px; background: rgba(242, 63, 67, 0.08); border: 1px solid rgba(242, 63, 67, 0.3); border-radius: 8px; }
.edb-validation-strip.has-warn { padding: 8px 10px; background: rgba(240, 178, 50, 0.08); border: 1px solid rgba(240, 178, 50, 0.3); border-radius: 8px; }

.edb-input-over { border-color: #f23f43 !important; }

/* Drag + drop reordering visual. */
.edb-field-card.dragging { opacity: 0.5; border-color: rgba(88, 101, 242, 0.7); }
.edb-grip { cursor: grab; }
.edb-grip:active { cursor: grabbing; }

/* Saved embeds list. */
.embed-builder-saved {
  margin-top: 22px;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
  padding-top: 16px;
}
.embed-saved-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.embed-saved-search {
  font-size: 13px; color: #e9ecf3;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  padding: 7px 10px;
  width: min(220px, 100%);
  box-sizing: border-box;
  outline: none;
}
.embed-saved-search:focus { border-color: rgba(88, 101, 242, 0.7); }
#eb-saved-list { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.embed-saved-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--surface-2, #232428);
  border: 1px solid var(--border-soft, rgba(255, 255, 255, 0.08));
  border-radius: 10px;
  padding: 10px 12px;
  flex-wrap: wrap;
}
.embed-saved-name { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.embed-saved-name > span {
  font-size: 13.5px; font-weight: 600; color: #e9ecf3;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%;
}
.embed-saved-meta { font-size: 11px; color: #7d848c; }
.embed-saved-actions-group { display: inline-flex; gap: 6px; flex-wrap: wrap; }

/* Save / rename modal (reuses the shared floating-window modal). */
.eb-modal { width: min(480px, 95vw); }
.eb-modal .modal-actions { display: flex; justify-content: flex-end; gap: 8px; }
.eb-modal .edb-validation-strip { margin-top: 4px; }

/* Field inline switch inside the builder. */
.edb-field-inline { display: flex; align-items: center; gap: 8px; }

/* Responsive: single-column builder → preview on smaller content widths; the
 * sticky preview is disabled and the builder comes first in the flow. */
@media (max-width: 1000px) {
  .embed-builder-grid .edb-builder-cols { grid-template-columns: 1fr; gap: 18px; }
  .embed-builder-grid .edb-builder-right { position: static; order: 2; }
  .embed-builder-grid .edb-builder-left { order: 1; }
}
@media (max-width: 480px) {
  .embed-saved-row { align-items: flex-start; }
  .embed-saved-actions-group { width: 100%; }
  .embed-builder-toolbar .btn,
  .embed-saved-actions .btn { flex: 1 1 auto; }
  .embed-template-chip { flex: 0 0 auto; }
}
/* ══════════════════════════════════════════════════════════════════════════
   AutoMod — premium moderation control panel
   ══════════════════════════════════════════════════════════════════════════
   Sectioned layout: hero → stat strip → section nav → one visible section.
   Responsive down to ~360px: no horizontal overflow, tables reflow into
   stacked cards, the section nav becomes a horizontal scroll rail.
   Token-based so it tracks the theme.
   ------------------------------------------------------------------------ */

.am-page { display: flex; flex-direction: column; gap: 16px; }

.am-hero {
  display: flex; flex-wrap: wrap; gap: 18px; align-items: center; justify-content: space-between;
  padding: 22px 24px;
  background:
    radial-gradient(120% 140% at 0% 0%, var(--accent-soft), transparent 58%),
    var(--surface-2);
}
.am-hero-main { display: flex; gap: 16px; align-items: center; min-width: 0; flex: 1 1 320px; }
.am-hero-icon {
  flex: 0 0 auto; width: 54px; height: 54px; border-radius: 15px;
  display: grid; place-items: center;
  color: var(--accent-strong); background: var(--accent-soft);
  border: 1px solid rgba(88,101,242, 0.28);
}
.am-hero-icon .ico { width: 27px; height: 27px; }
.am-hero-title { margin: 0; font-size: 24px; font-weight: 700; letter-spacing: -0.015em; }
.am-hero-sub { margin: 4px 0 10px; color: var(--text-dim); font-size: 13.5px; line-height: 1.5; max-width: 62ch; }
.am-hero-pills { display: flex; flex-wrap: wrap; gap: 8px; }
.am-hero-switch {
  flex: 0 1 300px; display: flex; gap: 16px; align-items: center; justify-content: space-between;
  padding: 14px 16px; border: 1px solid var(--border); border-radius: var(--radius-md);
  background: var(--surface-1);
}
.am-hero-switch-label { min-width: 0; }

.am-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 11px; border-radius: 999px;
  font-size: 12px; font-weight: 600; letter-spacing: 0.01em;
  border: 1px solid var(--border); background: var(--surface-1); color: var(--text-dim);
}
.am-pill .ico { width: 13px; height: 13px; }
.am-pill-on { color: var(--on); border-color: rgba(62,207,142, 0.4); background: var(--on-soft); }
.am-pill-off { color: var(--danger); border-color: rgba(244,88,95, 0.36); background: var(--danger-soft); }
.am-pill-warn { color: var(--warn); border-color: rgba(245,177,76, 0.4); background: var(--warn-soft); }

.am-sev {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 999px;
  font-size: 11px; font-weight: 600; letter-spacing: 0.02em; text-transform: uppercase;
  border: 1px solid var(--border); background: var(--surface-1); color: var(--text-dim);
}
.am-sev .ico { width: 12px; height: 12px; }
.am-sev-low      { color: var(--on);     border-color: rgba(62,207,142, 0.34);  background: var(--on-soft); }
.am-sev-medium   { color: var(--warn);   border-color: rgba(245,177,76, 0.34);  background: var(--warn-soft); }
.am-sev-high     { color: #ed8a5c;       border-color: rgba(237,138,92, 0.34);  background: rgba(237,138,92, 0.12); }
.am-sev-critical { color: var(--danger); border-color: rgba(244,88,95, 0.38);   background: var(--danger-soft); }

.am-stats, .am-analytics-stats {
  display: grid; gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
}
.am-stat {
  display: flex; gap: 13px; align-items: center;
  padding: 16px 17px;
  border: 1px solid var(--border); border-radius: var(--radius-md);
  background: var(--surface-2);
  transition: border-color var(--transition), transform var(--transition);
}
.am-stat:hover { border-color: var(--border-strong); }
.am-stat-accent { border-color: rgba(88,101,242, 0.32); background: linear-gradient(180deg, var(--accent-soft), var(--surface-2)); }
.am-stat-icon {
  flex: 0 0 auto; width: 40px; height: 40px; border-radius: 11px;
  display: grid; place-items: center;
  color: var(--accent-strong); background: var(--accent-soft);
}
.am-stat-icon .ico { width: 19px; height: 19px; }
.am-stat-body { min-width: 0; }
.am-stat-label { font-size: 12.5px; font-weight: 600; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.04em; }
.am-stat-value { font-size: 21px; font-weight: 700; margin-top: 2px; letter-spacing: -0.01em; }
.am-stat-hint { font-size: 12px; color: var(--text-dim); margin-top: 2px; }

.am-sections {
  display: flex; gap: 6px; flex-wrap: wrap;
  padding: 7px; border: 1px solid var(--border); border-radius: var(--radius-md);
  background: var(--surface-1);
}
.am-section-btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 13px; border-radius: 9px;
  border: 1px solid transparent; background: transparent;
  color: var(--text-dim); font-size: 13px; font-weight: 600; font-family: inherit;
  cursor: pointer; white-space: nowrap;
  transition: color var(--transition), background var(--transition), border-color var(--transition);
}
.am-section-btn .ico { width: 15px; height: 15px; }
.am-section-btn:hover { color: var(--text); background: var(--surface-hover); }
.am-section-btn:focus-visible { outline: none; box-shadow: var(--ring); border-color: var(--accent); }
.am-section-btn.active { color: var(--text); background: var(--accent-soft); border-color: rgba(88,101,242, 0.34); }

.am-section { display: flex; flex-direction: column; gap: 16px; }
.am-section[hidden] { display: none; }

.am-rule-list { display: flex; flex-direction: column; gap: 12px; }
.am-rule-card {
  padding: 15px 16px;
  border: 1px solid var(--border); border-radius: var(--radius-md);
  background: var(--surface-2);
  transition: border-color var(--transition);
}
.am-rule-card:hover { border-color: var(--border-strong); }
.am-rule-head { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.am-rule-toggle { flex: 0 0 auto; }
.am-rule-icon {
  flex: 0 0 auto; width: 34px; height: 34px; border-radius: 10px;
  display: grid; place-items: center;
  color: var(--accent-strong); background: var(--accent-soft);
}
.am-rule-icon .ico { width: 17px; height: 17px; }
.am-rule-title { min-width: 0; flex: 1 1 150px; }
.am-rule-name { font-weight: 650; font-size: 14.5px; }
.am-rule-cat { font-size: 12px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.05em; margin-top: 1px; }
.am-rule-head-actions { display: flex; gap: 6px; align-items: center; margin-left: auto; flex-wrap: wrap; }
.am-rule-desc { margin: 10px 0 12px; font-size: 12.5px; color: var(--text-dim); line-height: 1.55; }

.am-rule-params { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 12px; }
.am-field { display: flex; flex-direction: column; gap: 5px; min-width: 0; flex: 1 1 150px; }
.am-field-num { flex: 0 0 auto; max-width: 190px; }
.am-field-label { font-size: 12px; font-weight: 600; color: var(--text-dim); letter-spacing: 0.03em; }
.am-field input, .am-field select, .am-field textarea {
  padding: 8px 10px; background: var(--bg); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text); font-size: 13px; font-family: inherit; width: 100%;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.am-field input:focus, .am-field select:focus, .am-field textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: var(--ring);
}
.am-inline-switch {
  align-self: flex-end; display: inline-flex; align-items: center; gap: 7px;
  padding: 7px 11px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface-1); font-size: 12.5px; cursor: pointer; flex: 0 1 auto;
}
.am-rule-actions-label { font-size: 12px; font-weight: 600; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 7px; }
.am-rule-perrule { margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--border); }
.am-rule-exempt { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 10px; }

.am-link-btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: none; border: none; padding: 0; cursor: pointer;
  color: var(--accent-strong); font-size: 12.5px; font-weight: 600; font-family: inherit;
}
.am-link-btn:hover { text-decoration: underline; }
.am-link-btn .ico { width: 14px; height: 14px; }

.am-icon-btn {
  display: grid; place-items: center; width: 30px; height: 30px;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface-1); color: var(--text-dim); cursor: pointer;
  transition: color var(--transition), border-color var(--transition), background var(--transition);
}
.am-icon-btn .ico { width: 15px; height: 15px; }
.am-icon-btn:hover { color: var(--text); border-color: var(--border-strong); background: var(--surface-hover); }
.am-icon-btn:focus-visible { outline: none; box-shadow: var(--ring); }

.am-add-row { display: flex; gap: 9px; align-items: center; flex-wrap: wrap; margin-top: 12px; }
.am-add-row select { flex: 1 1 210px; min-width: 0; }

.am-presets { display: grid; gap: 11px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.am-preset {
  display: flex; flex-direction: column; gap: 7px;
  padding: 14px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface-1); transition: border-color var(--transition);
}
.am-preset:hover { border-color: var(--border-strong); }
.am-preset-head { display: flex; align-items: center; gap: 9px; }
.am-preset-icon { color: var(--accent-strong); display: grid; place-items: center; }
.am-preset-icon .ico { width: 17px; height: 17px; }
.am-preset-name { font-weight: 650; font-size: 14px; }
.am-preset-desc { margin: 0; font-size: 12.5px; color: var(--text-dim); line-height: 1.5; flex: 1; }
.am-preset-meta { font-size: 12px; color: var(--text-dim); }
.am-preset-apply { justify-content: center; }

.am-overview-rules { display: flex; flex-wrap: wrap; gap: 7px; }
.am-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 11px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface-1);
  font-size: 12.5px; color: var(--text);
}
.am-chip .ico { width: 14px; height: 14px; color: var(--accent-strong); }
.am-chip-off { opacity: 0.48; }
.am-chip-sm { font-size: 11.5px; padding: 2px 8px; }
.am-chip-warn { color: var(--warn); border-color: rgba(245,177,76, 0.36); background: var(--warn-soft); }

.am-grid-2 { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.am-grid-3 { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }

.am-test-input { width: 100%; resize: vertical; min-height: 74px; margin-bottom: 11px; }
.am-test-result { margin-top: 14px; display: flex; flex-direction: column; gap: 10px; }
.am-test-summary { display: flex; flex-wrap: wrap; gap: 8px; }
.am-test-match { padding: 12px 13px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-1); }
.am-test-match-head { display: flex; align-items: center; gap: 9px; }
.am-test-match-name { font-weight: 650; font-size: 13.5px; flex: 1; min-width: 0; }
.am-test-reason { margin-top: 7px; font-size: 12.5px; color: var(--text-dim); }
.am-test-actions { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 12px; color: var(--text-dim); }
.am-test-note { display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--text-dim); }
.am-test-note .ico { width: 15px; height: 15px; flex: 0 0 auto; }
.am-test-note-warn { color: var(--warn); }

.am-ladder { display: flex; flex-direction: column; gap: 9px; margin-bottom: 12px; }
.am-ladder-row {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 11px 13px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface-1);
}
.am-ladder-at, .am-ladder-warn { font-size: 12.5px; color: var(--text-dim); }
.am-ladder-count, .am-ladder-action { padding: 7px 10px; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; color: var(--text); font-family: inherit; font-size: 13px; }
.am-ladder-count { width: 76px; }
.am-ladder-action { flex: 1 1 150px; min-width: 0; }
.am-ladder-remove { margin-left: auto; }

.am-dm-list { display: flex; flex-direction: column; gap: 9px; margin-top: 12px; }
.am-dm-row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.am-dm-label { flex: 0 0 130px; font-size: 12.5px; font-weight: 600; color: var(--text-dim); }
.am-dm-row input { flex: 1 1 220px; min-width: 0; padding: 9px 11px; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; color: var(--text); font-size: 13px; font-family: inherit; }
.am-dm-row input:focus { outline: none; border-color: var(--accent); box-shadow: var(--ring); }

.am-exempt-user {
  display: inline-flex; align-items: center; gap: 9px;
  padding: 6px 8px 6px 12px; margin: 0 6px 6px 0;
  border: 1px solid var(--border); border-radius: 8px; background: var(--surface-1);
}
.am-exempt-user code { font-size: 12.5px; color: var(--text-dim); }
.am-exempt-user .am-icon-btn { width: 24px; height: 24px; }
.am-exempt-user .am-icon-btn .ico { width: 13px; height: 13px; }

.am-filters { display: flex; flex-wrap: wrap; gap: 9px; margin-bottom: 15px; }
.am-filters select, .am-filter-search {
  padding: 9px 11px; background: var(--bg); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text); font-size: 13px; font-family: inherit;
}
.am-filter-search { flex: 1 1 200px; min-width: 0; }
.am-filters select:focus, .am-filter-search:focus { outline: none; border-color: var(--accent); box-shadow: var(--ring); }

.am-table-wrap { overflow-x: auto; }
.am-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.am-table th {
  text-align: left; padding: 10px 12px;
  font-size: 11.5px; font-weight: 600; color: var(--text-dim);
  text-transform: uppercase; letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
.am-table td { padding: 11px 12px; border-bottom: 1px solid var(--border-soft); vertical-align: middle; }
.am-table tbody tr:hover { background: var(--surface-hover); }
.am-table code { font-size: 12px; color: var(--text-dim); }

.am-pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 14px; }
.am-pager-info { font-size: 12.5px; color: var(--text-dim); }
.am-pager-btns { display: flex; gap: 8px; }
.am-pager-btns .btn[disabled] { opacity: 0.45; cursor: not-allowed; }

.am-analytics { display: flex; flex-direction: column; gap: 16px; }
.am-title-actions { display: flex; gap: 9px; align-items: center; margin-left: auto; flex-wrap: wrap; }
.am-chart-card { padding: 16px; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface-2); }
.am-bars { display: flex; align-items: flex-end; gap: 3px; height: 150px; margin-top: 14px; }
.am-bar { flex: 1 1 0; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; height: 100%; min-width: 0; }
.am-bar-fill { width: 100%; max-width: 34px; border-radius: 4px 4px 0 0; background: linear-gradient(180deg, var(--accent-strong), var(--accent)); min-height: 2px; transition: height var(--transition); }
.am-bar-label { font-size: 9.5px; color: var(--text-dim); margin-top: 5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.am-donut-wrap { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; margin-top: 14px; }
.am-donut { width: 132px; height: 132px; flex: 0 0 auto; }
.am-donut-legend { display: flex; flex-direction: column; gap: 8px; min-width: 0; flex: 1 1 140px; }
.am-legend-row { display: flex; align-items: center; gap: 8px; font-size: 12.5px; }
.am-legend-dot { width: 10px; height: 10px; border-radius: 3px; flex: 0 0 auto; }
.am-legend-pct { margin-left: auto; color: var(--text-dim); }
.am-breakdown { padding: 15px 16px; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface-2); }
.am-breakdown-title { font-size: 12px; font-weight: 600; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 12px; }
.am-breakdown-row { display: flex; align-items: center; gap: 10px; margin-bottom: 9px; }
.am-breakdown-label { flex: 0 1 120px; font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.am-breakdown-track { flex: 1 1 auto; height: 7px; border-radius: 999px; background: var(--surface-3); overflow: hidden; min-width: 40px; }
.am-breakdown-fill { display: block; height: 100%; border-radius: 999px; background: var(--accent); }
.am-breakdown-value { flex: 0 0 auto; font-size: 12.5px; font-weight: 650; min-width: 28px; text-align: right; }

.am-loading { display: flex; align-items: center; gap: 8px; padding: 18px 4px; color: var(--text-dim); font-size: 13px; }
.am-skeleton { display: flex; flex-direction: column; gap: 9px; padding: 4px 0; }
.am-skel-row { height: 40px; border-radius: 9px; background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 50%, var(--surface-2) 75%); background-size: 200% 100%; animation: am-shimmer 1.4s ease-in-out infinite; }
@keyframes am-shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

.am-empty, .am-error { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px; padding: 34px 20px; }
.am-empty-icon, .am-error-icon {
  width: 46px; height: 46px; border-radius: 13px; display: grid; place-items: center;
  color: var(--text-dim); background: var(--surface-1); border: 1px solid var(--border);
}
.am-empty-icon .ico, .am-error-icon .ico { width: 21px; height: 21px; }
.am-error-icon { color: var(--danger); background: var(--danger-soft); border-color: rgba(244,88,95, 0.3); }
.am-empty-title { font-weight: 650; font-size: 14.5px; }
.am-empty-text, .am-error-text { font-size: 12.5px; color: var(--text-dim); max-width: 44ch; line-height: 1.55; }

.am-subhead { display: flex; align-items: center; gap: 8px; margin: 20px 0 10px; font-size: 12px; font-weight: 600; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.05em; }
.am-subhead .ico { width: 15px; height: 15px; }

.am-appeal-decide { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 9px; }
.am-appeal-decide input { flex: 1 1 170px; min-width: 0; padding: 8px 10px; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; color: var(--text); font-size: 13px; font-family: inherit; }

.am-confirm { width: min(430px, 94vw); }

/* ── Anti-Nuke (upcoming) ────────────────────────────────────────────────── */
.an-page { display: flex; flex-direction: column; gap: 16px; }
.an-watch-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.an-watch-card { padding: 14px 15px; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface-2); }
.an-watch-head { display: flex; gap: 11px; align-items: center; flex-wrap: wrap; }
.an-watch-icon { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; color: var(--accent-strong); background: var(--accent-soft); flex: 0 0 auto; }
.an-watch-icon .ico { width: 16px; height: 16px; }
.an-watch-title { flex: 1 1 150px; min-width: 0; }
.an-watch-name { font-weight: 650; font-size: 14px; }
.an-watch-desc { font-size: 12px; color: var(--text-dim); margin-top: 2px; line-height: 1.5; }
.an-watch-params { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 12px; }

.an-responses { display: flex; flex-direction: column; gap: 9px; }
.an-response {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface-1); cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
}
.an-response:hover { border-color: var(--border-strong); background: var(--surface-hover); }
.an-response:has(input:checked) { border-color: rgba(88,101,242, 0.38); background: var(--accent-soft); }
.an-response-body { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.an-response-name { display: inline-flex; align-items: center; gap: 7px; font-weight: 620; font-size: 13.5px; }
.an-response-name .ico { width: 15px; height: 15px; color: var(--accent-strong); }
.an-response-desc { font-size: 12.5px; color: var(--text-dim); line-height: 1.5; }

@media (max-width: 760px) {
  .am-hero { padding: 18px 16px; }
  .am-hero-switch { flex: 1 1 100%; }
  .am-title-actions { margin-left: 0; width: 100%; }
  .am-sections {
    flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch;
    scrollbar-width: thin; scroll-snap-type: x proximity;
  }
  .am-section-btn { scroll-snap-align: start; }
  .am-dm-label { flex: 0 0 100%; }
  .am-field-num { max-width: none; flex: 1 1 120px; }
  .am-ladder-count { width: 64px; }
  .am-ladder-remove { margin-left: 0; }
  .am-filter-search, .am-filters select { flex: 1 1 100%; }

  /* Tables collapse into labelled rows — no horizontal scrolling on phones. */
  .am-table-wrap { overflow-x: visible; }
  .am-table thead { display: none; }
  .am-table, .am-table tbody, .am-table tr, .am-table td { display: block; width: 100%; }
  .am-table tr {
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    margin-bottom: 10px; padding: 6px 4px; background: var(--surface-1);
  }
  .am-table td {
    display: flex; justify-content: space-between; gap: 14px; align-items: baseline;
    border: none; padding: 6px 11px; text-align: right;
  }
  .am-table td::before {
    content: attr(data-label); flex: 0 0 auto; text-align: left;
    font-size: 12px; font-weight: 600; color: var(--text-dim);
    text-transform: uppercase; letter-spacing: 0.05em;
  }
}

@media (max-width: 520px) {
  .am-grid-2, .am-grid-3, .am-presets, .am-analytics-stats { grid-template-columns: 1fr; }
  .am-bars { height: 118px; }
  .am-donut { width: 112px; height: 112px; }
  .am-hero-title { font-size: 21px; }
  .am-stat-value { font-size: 19px; }
  .am-rule-head-actions { margin-left: 0; width: 100%; }
  .am-confirm { width: calc(100vw - 24px); }
}

@media (prefers-reduced-motion: reduce) {
  .am-skel-row { animation: none; }
  .am-section-btn, .am-stat, .am-bar-fill, .am-breakdown-fill, .am-rule-card { transition: none; }
}