/* Admin Bot dashboard.
   Rebrand by changing --accent (and --accent-ink for text on it). Everything else derives from these tokens. */

@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("/static/fonts/inter-latin-wght-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("/static/fonts/inter-latin-ext-wght-normal.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  --accent: #6366f1;
  --accent-hover: #5458e8;
  --accent-ink: #ffffff;
  --accent-soft: rgba(99, 102, 241, .14);
  --accent-ring: rgba(99, 102, 241, .45);

  --bg: #0b0c10;
  --surface: #121318;
  --surface-2: #181a20;
  --surface-3: #20232b;
  --input: #0f1014;
  --border: rgba(255, 255, 255, .07);
  --border-strong: rgba(255, 255, 255, .13);
  --text: #ecedf1;
  --muted: #a1a4ae;
  --faint: #6c707c;

  --success: #22c55e;
  --success-soft: rgba(34, 197, 94, .14);
  --warning: #f59e0b;
  --warning-soft: rgba(245, 158, 11, .12);
  --danger: #ef4444;
  --danger-soft: rgba(239, 68, 68, .13);

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, .45);
  --sidebar: 268px;
  color-scheme: dark;
}

/* Light theme: chosen in the user menu, or follows the system when nothing is saved. */
:root[data-theme="light"] {
  --accent-soft: rgba(99, 102, 241, .10);
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f3f4f6;
  --surface-3: #e9ebef;
  --input: #ffffff;
  --border: rgba(15, 23, 42, .08);
  --border-strong: rgba(15, 23, 42, .16);
  --text: #111318;
  --muted: #5b606b;
  --faint: #8b909a;
  --success-soft: rgba(34, 197, 94, .12);
  --warning-soft: rgba(245, 158, 11, .12);
  --danger-soft: rgba(239, 68, 68, .10);
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 6px 20px rgba(15, 23, 42, .06);
  --shadow-lg: 0 16px 40px rgba(15, 23, 42, .14);
  color-scheme: light;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme]) {
    --accent-soft: rgba(99, 102, 241, .10);
    --bg: #f6f7f9;
    --surface: #ffffff;
    --surface-2: #f3f4f6;
    --surface-3: #e9ebef;
    --input: #ffffff;
    --border: rgba(15, 23, 42, .08);
    --border-strong: rgba(15, 23, 42, .16);
    --text: #111318;
    --muted: #5b606b;
    --faint: #8b909a;
    --success-soft: rgba(34, 197, 94, .12);
    --warning-soft: rgba(245, 158, 11, .12);
    --danger-soft: rgba(239, 68, 68, .10);
    --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 6px 20px rgba(15, 23, 42, .06);
    --shadow-lg: 0 16px 40px rgba(15, 23, 42, .14);
    color-scheme: light;
  }
}

/* ------------------------------------------------------------ base */

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 14.5px/1.55 "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-feature-settings: "cv11", "ss01";
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 6px; letter-spacing: -.015em; }
h1 { font-size: 24px; font-weight: 700; }
h2 { font-size: 16px; font-weight: 650; }
h3 { font-size: 15px; font-weight: 650; }
p { margin: 0 0 12px; }
code { background: var(--surface-3); padding: 2px 6px; border-radius: 6px; font-size: 12.5px; font-family: ui-monospace, "SF Mono", Menlo, monospace; }
ul { margin: 0; padding-left: 18px; }
::selection { background: var(--accent-soft); }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 12.5px; }
.center { display: grid; place-items: center; min-height: 70vh; padding: 16px; text-align: center; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 0 16px; }
.icon { width: 18px; height: 18px; flex: none; }
[hidden] { display: none !important; }

/* ------------------------------------------------------------ buttons & inputs */

button, .btn {
  font: inherit; font-weight: 550; font-size: 14px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 36px; padding: 0 14px; border-radius: var(--radius-sm); border: 1px solid transparent;
  background: var(--accent); color: var(--accent-ink); cursor: pointer; white-space: nowrap;
  text-decoration: none; transition: background .15s, border-color .15s, color .15s, transform .05s;
}
button:hover, .btn:hover { background: var(--accent-hover); text-decoration: none; }
button:active, .btn:active { transform: translateY(1px); }
button:disabled { opacity: .5; cursor: not-allowed; transform: none; }
button .icon, .btn .icon { width: 16px; height: 16px; }
button.secondary { background: var(--surface-3); color: var(--text); border-color: var(--border); }
button.secondary:hover { background: var(--surface-2); border-color: var(--border-strong); }
button.ghost { background: transparent; color: var(--muted); }
button.ghost:hover { background: var(--surface-3); color: var(--text); }
button.danger { background: var(--danger); }
.btn-lg { height: 44px; padding: 0 20px; font-size: 15px; }
.btn-block { width: 100%; }
.icon-btn {
  width: 34px; height: 34px; padding: 0; background: transparent; color: var(--muted); border-radius: var(--radius-sm);
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }

input[type=text], select, textarea {
  width: 100%; background: var(--input); color: var(--text);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  padding: 8px 11px; font: inherit; font-size: 14px; transition: border-color .15s, box-shadow .15s;
}
input[type=text], select { height: 38px; }
select {
  appearance: none; padding-right: 32px; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--faint) 50%), linear-gradient(135deg, var(--faint) 50%, transparent 50%);
  background-position: calc(100% - 16px) 16px, calc(100% - 11px) 16px;
  background-size: 5px 5px; background-repeat: no-repeat;
}
textarea { resize: vertical; min-height: 76px; line-height: 1.5; }
input::placeholder, textarea::placeholder { color: var(--faint); }
input[type=text]:hover, select:hover, textarea:hover { border-color: var(--faint); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
button:focus-visible, .btn:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
input[type=color] {
  width: 44px; height: 38px; padding: 3px; border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); background: var(--input); cursor: pointer;
}
input[type=checkbox]:not([role=switch]) { accent-color: var(--accent); width: 15px; height: 15px; }
option:disabled { color: var(--faint); }

.field { margin-bottom: 18px; }
.field > .label { display: block; font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 7px; }
.hint { font-size: 12.5px; color: var(--faint); margin-top: 6px; }
.warn { font-size: 12.5px; color: var(--warning); margin-top: 6px; }

/* Toggle switch */
.toggle { display: flex; gap: 16px; align-items: center; justify-content: space-between; padding: 12px 0; cursor: pointer; border-top: 1px solid var(--border); }
.card-body > .toggle:first-child { border-top: 0; padding-top: 0; }
.toggle .text { min-width: 0; }
.toggle .title { font-weight: 550; }
.toggle .hint { margin-top: 2px; }
.switch { display: inline-block; position: relative; width: 40px; height: 22px; flex: none; }
.switch input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; z-index: 1; }
.switch .track { position: absolute; inset: 0; background: var(--surface-3); border: 1px solid var(--border-strong); border-radius: 999px; transition: background .2s, border-color .2s; }
.switch .track::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .3); transition: transform .2s cubic-bezier(.3, .7, .4, 1);
}
.switch input:checked + .track { background: var(--accent); border-color: var(--accent); }
.switch input:checked + .track::after { transform: translateX(18px); }
.switch input:focus-visible + .track { box-shadow: 0 0 0 3px var(--accent-ring); }

/* ------------------------------------------------------------ cards, notices, badges */

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 22px 24px; margin-bottom: 16px; box-shadow: var(--shadow);
}
.card.flush { padding: 6px 0; }
.card.off .card-body { opacity: .62; transition: opacity .2s; }
.card.off:focus-within .card-body, .card.off:hover .card-body { opacity: .8; }
.card-head { display: flex; gap: 16px; align-items: flex-start; justify-content: space-between; margin-bottom: 18px; }
.card-head h2 { margin-bottom: 2px; }
.card-head p { margin: 0; font-size: 13.5px; }

.notice {
  display: flex; gap: 10px; align-items: flex-start; background: var(--warning-soft); color: var(--text);
  border: 1px solid rgba(245, 158, 11, .3); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 16px; font-size: 13.5px;
}
.notice .icon { color: var(--warning); margin-top: 1px; }
.notice ul { padding-left: 16px; }
.notice.error { background: var(--danger-soft); border-color: rgba(239, 68, 68, .35); }
.notice.error .icon { color: var(--danger); }

.badge { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 999px; font-size: 11.5px; font-weight: 650; text-transform: capitalize; background: var(--surface-3); color: var(--muted); }
.badge.warn { background: var(--warning-soft); color: var(--warning); }
.badge.timeout, .badge.kick { background: rgba(249, 115, 22, .14); color: #f97316; }
.badge.ban { background: var(--danger-soft); color: var(--danger); }
.badge.unban, .badge.untimeout { background: var(--success-soft); color: var(--success); }

.status { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; color: var(--muted); white-space: nowrap; }
.status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--faint); }
.status-on { color: var(--success); }
.status-on::before { background: var(--success); box-shadow: 0 0 0 3px var(--success-soft); }
.status-setup { color: var(--warning); }
.status-setup::before { background: var(--warning); }

.empty { display: grid; justify-items: center; gap: 4px; text-align: center; padding: 36px 16px; color: var(--muted); border: 1px dashed var(--border-strong); border-radius: var(--radius-lg); }
.empty > .icon { width: 28px; height: 28px; color: var(--faint); margin-bottom: 6px; }
.empty strong { color: var(--text); }
.empty p { margin: 0; font-size: 13.5px; }

/* ------------------------------------------------------------ app shell */

.layout { display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 14px;
  padding: 16px 12px; background: var(--surface); border-right: 1px solid var(--border); overflow-y: auto;
}
.sidebar-top { display: flex; align-items: center; justify-content: space-between; padding: 2px 6px; }
.nav-close { display: none; }

.brand { display: flex; align-items: center; gap: 10px; color: var(--text); min-width: 0; }
.brand:hover { text-decoration: none; }
.brand img, .brand-mark { width: 32px; height: 32px; border-radius: 10px; flex: none; }
.brand-mark { display: grid; place-items: center; background: var(--accent); color: var(--accent-ink); }
.brand-text { display: grid; line-height: 1.2; min-width: 0; }
.brand-text strong { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-text span { font-size: 12px; color: var(--faint); }

.server-icon {
  width: 36px; height: 36px; border-radius: 10px; background: var(--surface-3); color: var(--muted);
  display: grid; place-items: center; font-weight: 700; font-size: 12px; overflow: hidden; flex: none;
}
.server-icon img { width: 100%; height: 100%; object-fit: cover; }

.server-switch {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; color: var(--text);
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius);
  transition: border-color .15s, background .15s;
}
.server-switch:hover { text-decoration: none; border-color: var(--border-strong); background: var(--surface-3); }
.server-switch > .icon { color: var(--faint); width: 16px; height: 16px; }
.server-switch-text { display: grid; min-width: 0; flex: 1; line-height: 1.3; }
.server-switch-text strong { font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.server-switch-text span { font-size: 12px; color: var(--faint); }

.nav { display: grid; gap: 14px; flex: 1; align-content: start; }
.nav-group { display: grid; gap: 1px; }
.nav-label { font-size: 11px; font-weight: 600; letter-spacing: .02em; color: var(--faint); padding: 0 10px 6px; }
.nav-item {
  display: flex; align-items: center; gap: 11px; height: 34px; padding: 0 10px; border-radius: var(--radius-sm);
  color: var(--muted); font-weight: 520; transition: background .12s, color .12s;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav-item.active { background: var(--accent-soft); color: var(--text); }
.nav-item.active .icon { color: var(--accent); }
.nav-item span:first-of-type { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dirty-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--warning); flex: none; }

.user-card { display: flex; align-items: center; gap: 4px; padding: 12px 4px 0 6px; border-top: 1px solid var(--border); }
.user-card .avatar { margin-right: 6px; }
.user-name { flex: 1; min-width: 0; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.avatar { width: 32px; height: 32px; border-radius: 50%; flex: none; background: var(--surface-3); }
.user-text { display: grid; line-height: 1.25; min-width: 0; flex: 1; }
.user-text strong { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-text span { font-size: 11.5px; color: var(--faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.topbar {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 12px; height: 64px; padding: 0 24px;
  background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: blur(12px); border-bottom: 1px solid var(--border);
}
.topbar .user-card { border: 0; padding: 0; }
.mobile-bar, .scrim { display: none; }

.content { min-width: 0; padding: 36px 40px 140px; }
.content-inner { max-width: 960px; margin: 0 auto; }
.page { max-width: 1040px; margin: 0 auto; padding: 40px 24px 96px; }
.page-head { display: flex; gap: 16px; align-items: center; margin-bottom: 28px; }
.page-head h1 { margin: 0 0 2px; }
.page-head p { margin: 0; }
.page-icon {
  width: 44px; height: 44px; border-radius: var(--radius); display: grid; place-items: center; flex: none;
  background: var(--accent-soft); color: var(--accent); border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent);
}
.page-icon .icon { width: 22px; height: 22px; }
.page-icon.small { width: 34px; height: 34px; border-radius: 10px; }
.page-icon.small .icon { width: 18px; height: 18px; }
.section-title { font-size: 13px; font-weight: 650; text-transform: uppercase; letter-spacing: .06em; color: var(--faint); margin: 28px 0 12px; }
.section-row { margin: 28px 0 14px; }
.section-row p { margin: 0; }

/* Skeleton while loading */
.skeleton { display: grid; gap: 16px; }
.sk { border-radius: var(--radius-lg); background: linear-gradient(90deg, var(--surface) 0%, var(--surface-2) 50%, var(--surface) 100%); background-size: 200% 100%; animation: shimmer 1.2s infinite; }
.sk-title { height: 44px; width: 40%; }
.sk-card { height: 160px; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ------------------------------------------------------------ login */

.login-page {
  min-height: 100vh; display: grid; place-items: center; padding: 24px; position: relative; overflow: hidden;
  background:
    radial-gradient(600px 400px at 50% -10%, color-mix(in srgb, var(--accent) 30%, transparent), transparent 70%),
    radial-gradient(500px 300px at 90% 110%, color-mix(in srgb, var(--accent) 14%, transparent), transparent 70%),
    var(--bg);
}
.login-theme { position: absolute; top: 16px; right: 16px; }
.login-card {
  width: min(420px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: 20px;
  padding: 36px 32px 28px; text-align: center; box-shadow: var(--shadow-lg);
}
.login-avatar { width: 72px; height: 72px; border-radius: 20px; margin: 0 auto 16px; display: grid; place-items: center; box-shadow: var(--shadow); }
.login-avatar.brand-mark .icon { width: 34px; height: 34px; }
.login-card h1 { font-size: 26px; }
.login-card > p.muted { margin-bottom: 24px; }
.login-card .notice { text-align: left; }
.feature-list { list-style: none; padding: 0; margin: 24px 0 18px; display: grid; gap: 10px; text-align: left; font-size: 13.5px; color: var(--muted); }
.feature-list li { display: flex; gap: 10px; align-items: center; }
.feature-icon { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; background: var(--surface-2); color: var(--accent); flex: none; }
.feature-icon .icon { width: 15px; height: 15px; }
.login-card .hint { margin: 0; }

/* ------------------------------------------------------------ server picker */

.servers { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; }
.server {
  position: relative; overflow: hidden; display: grid; justify-items: center; gap: 4px; padding: 0 20px 18px; text-align: center;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); color: var(--text);
  box-shadow: var(--shadow); transition: border-color .15s, transform .15s;
}
.server:hover { text-decoration: none; border-color: color-mix(in srgb, var(--accent) 60%, transparent); transform: translateY(-2px); }
.server-banner { width: calc(100% + 40px); height: 64px; margin-bottom: -32px; background: linear-gradient(135deg, var(--accent-soft), color-mix(in srgb, var(--accent) 35%, transparent)); }
.server .server-icon { width: 64px; height: 64px; border-radius: 18px; border: 4px solid var(--surface); font-size: 18px; margin-bottom: 6px; }
.server-cta { display: inline-flex; align-items: center; gap: 4px; margin-top: 10px; font-size: 13px; font-weight: 600; color: var(--accent); }
.server-cta .icon { width: 15px; height: 15px; }

/* ------------------------------------------------------------ overview */

.hero { display: flex; align-items: center; gap: 16px; margin-bottom: 24px; }
.hero .server-icon { width: 60px; height: 60px; border-radius: 18px; font-size: 18px; box-shadow: var(--shadow); }
.hero p { margin: 0 0 2px; }
.hero h1 { margin: 0; font-size: 28px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { display: flex; gap: 12px; align-items: center; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 16px; box-shadow: var(--shadow); }
.stat-icon { width: 40px; height: 40px; border-radius: var(--radius); display: grid; place-items: center; background: var(--surface-2); color: var(--accent); flex: none; }
.stat-value { font-size: 20px; font-weight: 700; letter-spacing: -.02em; line-height: 1.2; }
.stat-label { font-size: 12.5px; color: var(--faint); }
.module-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.module-card {
  display: grid; gap: 12px; align-content: start; padding: 18px; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow);
  transition: border-color .15s, transform .15s;
}
.module-card:hover { text-decoration: none; border-color: color-mix(in srgb, var(--accent) 55%, transparent); transform: translateY(-2px); }
.module-head { display: flex; align-items: center; gap: 10px; }
.module-head strong { flex: 1; }
.module-facts { list-style: none; padding: 0; display: grid; gap: 3px; font-size: 13px; color: var(--muted); }
.module-cta { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; font-weight: 600; color: var(--accent); }
.module-cta .icon { width: 15px; height: 15px; transition: transform .15s; }
.module-card:hover .module-cta .icon { transform: translateX(3px); }
.activity { list-style: none; padding: 0; }
.activity li { display: flex; align-items: center; gap: 12px; padding: 12px 20px; border-top: 1px solid var(--border); font-size: 13.5px; }
.activity li:first-child { border-top: 0; }
.activity-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ------------------------------------------------------------ pickers, editors, tables */

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 28px; background: var(--surface-2); border: 1px solid var(--border-strong); border-radius: 999px; padding: 0 4px 0 10px; font-size: 13px; }
.chip button { height: 22px; width: 22px; padding: 0; border-radius: 50%; background: none; color: var(--faint); font-size: 15px; }
.chip button:hover { background: var(--surface-3); color: var(--text); }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--faint); flex: none; }

.tokens { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 8px; }
.tokens button { height: 24px; padding: 0 8px; background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); font: 500 12px ui-monospace, "SF Mono", Menlo, monospace; border-radius: 6px; }
.tokens button:hover { background: var(--accent-soft); color: var(--text); border-color: color-mix(in srgb, var(--accent) 40%, transparent); }
.tokens .token-select { width: auto; max-width: 220px; height: 26px; padding: 0 28px 0 8px; font-size: 12px; background-position: calc(100% - 14px) 11px, calc(100% - 9px) 11px; }
.preview { margin-top: 10px; background: var(--surface-2); border-radius: var(--radius-sm); padding: 10px 12px; font-size: 14px; white-space: pre-wrap; overflow-wrap: anywhere; }
.preview .label { font-size: 11px; text-transform: uppercase; color: var(--faint); margin-bottom: 4px; white-space: normal; }

.table-wrap { overflow-x: auto; margin: 0 -4px; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { text-align: left; padding: 11px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
th { color: var(--faint); font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; font-weight: 650; }
tbody tr:hover td { background: color-mix(in srgb, var(--surface-2) 60%, transparent); }

/* Role panels */
.panel-buttons { display: grid; gap: 8px; margin-bottom: 10px; }
.panel-button { display: grid; grid-template-columns: minmax(140px, 2fr) minmax(100px, 1.5fr) 84px 120px auto; gap: 8px; align-items: center; }
.discord-preview { background: #313338; color: #dbdee1; border-radius: var(--radius); padding: 14px; margin: 14px 0; }
.discord-preview .embed { border-left: 4px solid #5865f2; background: #2b2d31; padding: 10px 14px; border-radius: 4px; margin: 6px 0 10px; }
.discord-preview .embed .title { font-weight: 700; color: #f2f3f5; }
.discord-preview .embed .desc { white-space: pre-wrap; font-size: 14px; overflow-wrap: anywhere; }
.discord-preview .buttons { display: flex; flex-wrap: wrap; gap: 8px; }
.discord-preview .buttons span { padding: 5px 14px; border-radius: 4px; font-size: 14px; font-weight: 500; color: white; background: #4e5058; }
.discord-preview .buttons .primary { background: #5865f2; }
.discord-preview .buttons .success { background: #248046; }
.discord-preview .buttons .danger { background: #da373c; }

/* Number inputs, rule rows and leaderboards */
input[type=number] {
  width: 100%; height: 38px; background: var(--input); color: var(--text); border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); padding: 0 10px; font: inherit; font-size: 14px; transition: border-color .15s, box-shadow .15s;
}
input[type=number]:hover { border-color: var(--faint); }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 0 16px; }
.input-suffix { display: flex; align-items: center; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--input); overflow: hidden; }
.input-suffix:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input-suffix input { border: 0; box-shadow: none !important; min-width: 0; }
.input-suffix span { padding: 0 12px; color: var(--faint); font-size: 13px; white-space: nowrap; }
.rule-list { display: grid; gap: 8px; margin-bottom: 10px; }
.rule-row { display: flex; gap: 8px; align-items: center; }
.rule-row > select { flex: 1; min-width: 0; }
.rule-row > input[type=number] { width: 90px; flex: none; }
.rule-row > .input-suffix { width: 150px; flex: none; }
.rule-prefix { color: var(--muted); font-size: 13.5px; white-space: nowrap; }
button.danger-text { color: var(--danger); }
button.danger-text:hover { background: var(--danger-soft); color: var(--danger); }
.card-body > p a .icon, .card-body > p a { vertical-align: middle; }

.lb { display: grid; }
.lb-row { display: flex; align-items: center; gap: 12px; padding: 10px 4px; border-top: 1px solid var(--border); }
.lb-row:first-child { border-top: 0; }
.lb-rank { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 13px; color: var(--muted); background: var(--surface-2); flex: none; }
.lb-rank.medal-1 { background: #f5c542; color: #3d2c00; }
.lb-rank.medal-2 { background: #c7ccd6; color: #2b2f36; }
.lb-rank.medal-3 { background: #d4915a; color: #3b1f08; }
.lb .avatar { width: 36px; height: 36px; }
.lb-main { flex: 1; min-width: 0; display: grid; gap: 6px; }
.lb-name { display: flex; gap: 8px; align-items: baseline; min-width: 0; }
.lb-name strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lb-bar { height: 6px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.lb-bar span { display: block; height: 100%; border-radius: inherit; background: var(--accent); }
.lb-level { display: grid; justify-items: end; line-height: 1.3; text-align: right; flex: none; }
.public-board { max-width: 760px; }
@media (max-width: 600px) {
  .lb-name span, .rule-prefix { display: none; }
  .rule-row > .input-suffix { width: 120px; }
}

/* ------------------------------------------------------------ message & embed builder */

.builder { display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; margin: 4px 0 18px; }
@media (min-width: 1280px) {
  .content-inner:has(.builder) { max-width: 1320px; }
  .builder { grid-template-columns: minmax(0, 1fr) minmax(0, 470px); align-items: start; }
  .builder-side { position: sticky; top: 24px; }
}
.builder-side > .label { font-size: 11px; font-weight: 650; text-transform: uppercase; letter-spacing: .06em; margin-bottom: 8px; }
.builder-preview { background: #313338; color: #dbdee1; border-radius: var(--radius); padding: 16px; border: 1px solid var(--border); }
select.preset { margin-bottom: 18px; border-style: dashed; color: var(--muted); }
.embed-editor { border-left: 3px solid var(--accent); padding-left: 14px; margin: 6px 0 10px; }
.group { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 8px; }
.group summary { cursor: pointer; padding: 11px 14px; font-weight: 600; font-size: 13.5px; list-style: none; display: flex; align-items: center; gap: 8px; border-radius: var(--radius); }
.group summary:hover { background: var(--surface-3); }
.group summary::-webkit-details-marker { display: none; }
.group summary::before { content: ""; width: 6px; height: 6px; border-right: 2px solid var(--faint); border-bottom: 2px solid var(--faint); transform: rotate(-45deg); transition: transform .15s; margin-right: 2px; }
.group[open] summary::before { transform: rotate(45deg); }
.group-body { padding: 4px 14px 14px; }
.group-body .field:last-child { margin-bottom: 0; }
.embed-field-edit { display: grid; gap: 6px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px; margin-bottom: 8px; }
.embed-field-edit button.ghost { height: 28px; padding: 0 8px; }
.inline-check { display: inline-flex; gap: 6px; align-items: center; color: var(--muted); cursor: pointer; }
.swatch { width: 24px; height: 24px; padding: 0; border-radius: 50%; border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--border-strong); }
.swatch:hover { box-shadow: 0 0 0 2px var(--text); }
.role-note { display: grid; grid-template-columns: minmax(140px, 1fr) minmax(0, 2fr) auto; gap: 8px; margin-bottom: 8px; }

/* Discord-style preview: always Discord's own colours, whatever the dashboard theme. */
.discord-message { display: flex; gap: 14px; align-items: flex-start; }
.msg-avatar { width: 40px; height: 40px; border-radius: 50%; flex: none; background: #1e1f22; }
.msg-body { min-width: 0; flex: 1; display: grid; gap: 4px; }
.msg-head { display: flex; gap: 6px; align-items: center; color: #f2f3f5; }
.msg-head .faint { color: #949ba4; }
.app-tag { background: #5865f2; color: white; font-size: 10px; font-weight: 700; padding: 1px 5px; border-radius: 4px; }
.msg-content, .embed-desc, .embed-field-value { font-size: 15px; overflow-wrap: anywhere; color: #dbdee1; }
.builder-preview a, .discord-embed a { color: #00a8fc; }
.mention { background: rgba(88, 101, 242, .3); color: #c9cdfb; border-radius: 3px; padding: 0 2px; font-weight: 500; }
.md-quote { border-left: 4px solid #4e5058; padding-left: 10px; }
.md-heading { margin: 4px 0; font-size: 18px; color: #f2f3f5; }
h4.md-heading { font-size: 16px; }
h5.md-heading { font-size: 15px; }
.builder-preview code { background: #1e1f22; color: #dbdee1; }
.discord-embed { display: flex; gap: 16px; max-width: 520px; background: #2b2d31; border-left: 4px solid #5865f2; border-radius: 4px; padding: 10px 16px 14px 12px; margin-top: 2px; }
.embed-main { flex: 1; min-width: 0; display: grid; gap: 8px; }
.embed-author, .embed-footer { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; color: #f2f3f5; }
.embed-footer { font-size: 12px; font-weight: 500; color: #b5bac1; }
.embed-author img { width: 24px; height: 24px; border-radius: 50%; }
.embed-footer img { width: 20px; height: 20px; border-radius: 50%; }
.embed-title { font-weight: 700; font-size: 16px; color: #f2f3f5; }
a.embed-title { color: #00a8fc; }
.embed-fields { display: grid; gap: 8px; }
.embed-row { display: grid; gap: 8px; }
.embed-row.cols-2 { grid-template-columns: 1fr 1fr; }
.embed-row.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
.embed-field-name { font-weight: 700; font-size: 14px; margin-bottom: 2px; color: #f2f3f5; }
.embed-field-value { font-size: 14px; }
.embed-thumb { width: 80px; height: 80px; border-radius: 4px; object-fit: cover; flex: none; }
.embed-image { max-width: 100%; border-radius: 4px; }

/* ------------------------------------------------------------ save bar & toasts */

.savebar {
  position: fixed; left: calc(50% + var(--sidebar) / 2); bottom: 24px; transform: translateX(-50%); z-index: 20;
  width: min(640px, calc(100% - var(--sidebar) - 48px)); display: flex; gap: 10px; align-items: center;
  padding: 10px 10px 10px 18px; border-radius: 14px; border: 1px solid var(--border-strong);
  background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: blur(14px);
  box-shadow: var(--shadow-lg); animation: rise .25s cubic-bezier(.3, .7, .4, 1);
}
.savebar .msg { flex: 1; min-width: 0; font-weight: 550; }
.savebar-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--warning); box-shadow: 0 0 0 4px var(--warning-soft); flex: none; }
@keyframes rise { from { opacity: 0; transform: translate(-50%, 12px); } }

#toast { position: fixed; right: 20px; bottom: 20px; z-index: 30; display: grid; gap: 8px; justify-items: end; pointer-events: none; }
.toast {
  display: flex; align-items: center; gap: 10px; max-width: min(420px, calc(100vw - 40px)); padding: 11px 14px;
  background: var(--surface); color: var(--text); border: 1px solid var(--border-strong); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); font-size: 13.5px; font-weight: 500; animation: toast-in .25s cubic-bezier(.3, .7, .4, 1);
}
.toast .icon { color: var(--success); }
.toast-error .icon { color: var(--danger); }
.toast.leaving { opacity: 0; transform: translateY(6px); transition: opacity .2s, transform .2s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } }

/* ------------------------------------------------------------ small screens */

@media (max-width: 900px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .mobile-bar {
    display: flex; align-items: center; gap: 10px; position: sticky; top: 0; z-index: 10; height: 56px; padding: 0 12px;
    background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: blur(12px); border-bottom: 1px solid var(--border);
  }
  .mobile-bar .server-icon { width: 30px; height: 30px; border-radius: 8px; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; z-index: 40; width: min(300px, 86vw); transform: translateX(-100%);
    transition: transform .25s cubic-bezier(.3, .7, .4, 1); box-shadow: var(--shadow-lg);
  }
  .nav-open .sidebar { transform: none; }
  .nav-close { display: inline-flex; }
  .scrim { display: block; position: fixed; inset: 0; z-index: 35; background: rgba(0, 0, 0, .5); opacity: 0; pointer-events: none; transition: opacity .2s; }
  .nav-open .scrim { opacity: 1; pointer-events: auto; }
  .content { padding: 22px 16px 130px; }
  .page { padding: 28px 16px 96px; }
  .topbar { padding: 0 16px; }
  .topbar .user-text { display: none; }
  .card { padding: 18px 16px; border-radius: var(--radius); }
  .page-head { margin-bottom: 20px; }
  .page-icon { width: 40px; height: 40px; }
  h1, .hero h1 { font-size: 22px; }
  .savebar { left: 50%; width: calc(100% - 24px); bottom: 12px; padding-left: 14px; }
  .savebar .msg { font-size: 13px; }
  .panel-button { grid-template-columns: 1fr 1fr; }
  .role-note { grid-template-columns: 1fr auto; }
  .role-note > input { grid-column: 1 / -1; grid-row: 2; }
  .activity li { flex-wrap: wrap; padding: 12px 16px; }
  .activity-text { white-space: normal; flex-basis: 100%; order: 3; }
  #toast { right: 12px; left: 12px; bottom: 80px; justify-items: stretch; }
}

/* ------------------------------------------------------------ motion
   Kept short and soft: content eases in when you change page, redraws cross-fade, nothing bounces. */

:root { --ease-out: cubic-bezier(.2, .8, .3, 1); }
@keyframes fade-up { from { opacity: 0; transform: translateY(8px); } }
@keyframes fade-in { from { opacity: 0; } }

/* New page: header first, then each block follows a beat later. */
.content-inner.enter > *,
.content-inner.enter .overview > *,
.content-inner.enter .module-grid > *,
.content-inner.enter .stats > * { animation: fade-up .38s var(--ease-out) both; }
.content-inner.enter > :nth-child(2), .content-inner.enter .overview > :nth-child(2) { animation-delay: .04s; }
.content-inner.enter > :nth-child(3), .content-inner.enter .overview > :nth-child(3) { animation-delay: .08s; }
.content-inner.enter > :nth-child(n+4), .content-inner.enter .overview > :nth-child(n+4) { animation-delay: .12s; }
.content-inner.enter > div > .card:nth-child(2) { animation: fade-up .38s var(--ease-out) .08s both; }
.content-inner.enter > div > .card:nth-child(n+3) { animation: fade-up .38s var(--ease-out) .14s both; }
.content-inner.enter .stats > :nth-child(2) { animation-delay: .05s; }
.content-inner.enter .stats > :nth-child(3) { animation-delay: .1s; }
.content-inner.enter .stats > :nth-child(4) { animation-delay: .15s; }
.content-inner.enter .module-grid > :nth-child(2) { animation-delay: .14s; }
.content-inner.enter .module-grid > :nth-child(3) { animation-delay: .18s; }
.content-inner.enter .module-grid > :nth-child(4) { animation-delay: .22s; }
.content-inner.enter .module-grid > :nth-child(n+5) { animation-delay: .26s; }

.login-card { animation: fade-up .5s var(--ease-out) both; }
.servers > * { animation: fade-up .4s var(--ease-out) both; }
.servers > :nth-child(2) { animation-delay: .05s; }
.servers > :nth-child(n+3) { animation-delay: .1s; }
.skeleton { animation: fade-in .3s ease both; }

/* Redraws after a click cross-fade quickly instead of snapping. */
::view-transition-old(root), ::view-transition-new(root) { animation-duration: .18s; animation-timing-function: ease; }
.sidebar { view-transition-name: sidebar; }
.savebar-host { view-transition-name: savebar; }

/* Collapsible builder sections open with a short reveal. */
@keyframes reveal { from { opacity: 0; transform: translateY(-4px); } }
.group.just-opened .group-body { animation: reveal .22s var(--ease-out); }

/* Save bar slides away after saving or discarding. */
@keyframes sink { to { opacity: 0; transform: translate(-50%, 14px); } }
.savebar.leaving { animation: sink .2s ease forwards; pointer-events: none; }

/* Softer hover feedback. */
.nav-item .icon { width: 17px; height: 17px; color: var(--faint); transition: color .15s, transform .15s; }
.nav-item:hover .icon { color: var(--text); }
.nav-item:hover .icon { transform: translateX(1px); }
.card { transition: border-color .2s, box-shadow .2s; }
.dirty-dot { animation: fade-in .2s ease; }
.chip { animation: fade-in .18s ease; }

/* Theme switch: colours fade rather than flash. */
.theme-fade, .theme-fade *, .theme-fade *::before, .theme-fade *::after {
  transition: background-color .3s ease, border-color .3s ease, color .3s ease, box-shadow .3s ease !important;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
