:root {
  color-scheme: dark;
  --bg: #111318;
  --panel: #191b20;
  --panel-2: #22252c;
  --line: #2b2e36;
  --text: #f0f1f3;
  --muted: #a0a3ab;
  --accent: #5865f2;
  --accent-hover: #707bf5;
  --accent-soft: rgba(88, 101, 242, 0.12);
  --ok: #3ba55d;
  --bad: #ed4245;
  --radius: 16px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  font: 15px/1.55 system-ui, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}

a { color: inherit; }
h1 { font-size: 24px; margin: 0; }
h3 { margin: 0 0 14px; font-size: 16px; }
small, .muted { color: var(--muted); }
.small { font-size: 13px; }
.loading { text-align: center; color: var(--muted); margin-top: 20vh; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px max(28px, calc((100vw - 1440px) / 2));
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; gap: 10px; align-items: center; font-weight: 750; letter-spacing: -0.02em; text-decoration: none; }
.topbar-mark {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  color: #fff;
  background: var(--accent);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: -0.04em;
  box-shadow: 0 4px 14px rgba(88, 101, 242, 0.3);
}
.brand-caption { margin-left: 2px; color: var(--muted); font-size: 10px; font-weight: 650; letter-spacing: 0.12em; }
.user { display: flex; gap: 14px; align-items: center; color: var(--muted); }

main { max-width: 1440px; margin: 28px auto 60px; padding: 0 28px; }

.btn, button, select, input, textarea {
  font: inherit;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 12px;
}
select, input, textarea { min-width: 0; }
textarea { width: 100%; resize: vertical; }
input[type="color"] { padding: 2px; width: 56px; height: 38px; cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.btn, button { cursor: pointer; text-decoration: none; display: inline-block; transition: background 0.15s, border-color 0.15s; }
.btn:hover, button:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-hover); }
.btn.danger { background: transparent; color: var(--bad); border-color: var(--bad); }
.btn.small { padding: 4px 10px; font-size: 13px; }
button:disabled { opacity: 0.55; cursor: progress; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 16px; }
.page-head { margin-bottom: 22px; }
.page-head p { margin: 4px 0 0; }

.login-card { max-width: 460px; margin: 12vh auto 0; text-align: center; padding: 42px 34px; }
.login-card p { color: var(--muted); }
.login-card .btn { margin-top: 12px; }
.login-mark {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  margin: 0 auto 18px;
  border: 1px solid var(--line);
  border-radius: 16px;
  color: #fff;
  background: var(--accent);
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.06em;
}
.eyebrow { color: #a4acff !important; font-size: 10px; font-weight: 700; letter-spacing: 0.14em; }
.login-card h1 { font-size: 26px; letter-spacing: -0.035em; }
.alert { padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; background: #3d1f22; border: 1px solid var(--bad); }

.landing-page {
  position: relative;
  min-height: 100vh;
  overflow: hidden;
  isolation: isolate;
  background: #101117;
}
.landing-stars {
  position: absolute;
  z-index: -1;
  inset: -30%;
  opacity: 0.6;
  pointer-events: none;
  background-image:
    radial-gradient(1px 1px at 35px 48px, rgba(255,255,255,.82) 99%, transparent),
    radial-gradient(1px 1px at 112px 173px, rgba(194,201,255,.66) 99%, transparent),
    radial-gradient(2px 2px at 248px 92px, rgba(255,255,255,.68) 99%, transparent),
    radial-gradient(1px 1px at 318px 226px, rgba(173,184,255,.62) 99%, transparent);
  background-size: 370px 290px, 430px 350px, 510px 430px, 610px 510px;
  animation: star-drift 100s linear infinite;
}
.landing-stars::after {
  position: absolute;
  inset: 0;
  content: "";
  opacity: 0.32;
  background-image:
    radial-gradient(1px 1px at 90px 70px, white 99%, transparent),
    radial-gradient(1px 1px at 230px 180px, #b7c0ff 99%, transparent);
  background-size: 280px 220px, 390px 320px;
  animation: star-drift 150s linear infinite reverse;
}
@keyframes star-drift {
  from { transform: translate3d(0, 0, 0); }
  to { transform: translate3d(90px, 180px, 0); }
}
.landing-header {
  position: relative;
  z-index: 1;
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 76px;
  padding: 0 clamp(20px, 5vw, 76px);
  border-bottom: 1px solid rgba(255,255,255,.07);
  background: rgba(15, 16, 23, .62);
}
.landing-brand { display: flex; align-items: center; gap: 11px; font-size: 16px; font-weight: 750; text-decoration: none; }
.landing-brand-mark {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 1px solid rgba(255,255,255,.15);
  border-radius: 11px;
  background: #5865f2;
  color: white;
  font-size: 12px;
  font-weight: 800;
}
.landing-actions { display: flex; align-items: center; gap: 24px; }
.landing-support { color: #c3c5ce; font-size: 14px; text-decoration: none; }
.landing-support:hover { color: white; }
.panel-button { min-width: 104px; text-align: center; background: rgba(255,255,255,.07); }
.landing-main {
  position: relative;
  z-index: 1;
  display: flex;
  width: 100%;
  max-width: none;
  margin: 0;
  min-height: calc(100vh - 76px);
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 50px 20px 34px;
}
.landing-alert { width: min(100%, 560px); }
.invite-frame {
  position: relative;
  width: min(100%, 600px);
  overflow: hidden;
  padding: 44px 36px 36px;
  border: 1px solid rgba(255,255,255,.13);
  border-radius: 20px;
  background: rgba(22, 23, 31, .88);
  box-shadow: 0 24px 80px rgba(0,0,0,.35);
  text-align: center;
}
.invite-frame-glow {
  position: absolute;
  top: -110px;
  left: 50%;
  width: 280px;
  height: 170px;
  transform: translateX(-50%);
  border-radius: 50%;
  background: rgba(88,101,242,.12);
  filter: blur(55px);
  pointer-events: none;
}
.invite-logo {
  position: relative;
  display: block;
  width: 92px;
  height: 92px;
  margin: 0 auto 23px;
  border: 3px solid rgba(255,255,255,.12);
  border-radius: 28px;
  background: #242733;
  object-fit: cover;
  box-shadow: 0 10px 32px rgba(0,0,0,.32);
}
.invite-logo-fallback { display: grid; place-items: center; color: white; background: #5865f2; font-size: 24px; font-weight: 800; }
.invite-frame .eyebrow { margin: 0 0 8px; }
.invite-frame h1 { font-size: clamp(32px, 5vw, 46px); letter-spacing: -.045em; }
.landing-description { max-width: 410px; margin: 12px auto 24px; color: #aeb1bd; font-size: 15px; }
.invite-button { min-height: 48px; padding: 11px 22px; border-radius: 10px; font-weight: 700; }
.invite-button span { margin-right: 7px; font-size: 20px; vertical-align: -1px; }
.invite-note { margin: 15px 0 0; color: #818592; font-size: 11px; }
.landing-footnote { display: flex; align-items: center; gap: 8px; margin-top: 23px; color: #9699a6; font-size: 12px; }

.avatar { width: 46px; height: 46px; border-radius: 50%; background: var(--line); display: grid; place-items: center; font-weight: 700; flex: none; }
.guild-card { display: flex; gap: 14px; align-items: center; text-decoration: none; }
a.guild-card:hover { border-color: var(--accent); }
.guild-card.disabled { opacity: 0.5; }
.guild-card small { display: block; }

.layout { display: grid; grid-template-columns: 270px minmax(0, 1fr); gap: 26px; align-items: start; }
.sidebar {
  position: sticky;
  top: 82px;
  min-height: min(760px, calc(100vh - 110px));
  padding: 18px 13px 12px;
  display: flex;
  flex-direction: column;
  background: var(--panel);
}
.sidebar-brand { display: flex; gap: 11px; align-items: center; padding: 3px 9px 18px; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: #fff;
  font-size: 21px;
  background: var(--accent);
}
.sidebar-brand strong { display: block; letter-spacing: -0.015em; font-size: 14px; }
.sidebar-brand small { display: block; font-size: 9px; letter-spacing: 0.14em; color: var(--muted); }
.guild-head {
  display: flex;
  gap: 11px;
  align-items: center;
  min-width: 0;
  margin: 0 3px 18px;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.025);
  text-decoration: none;
  transition: border-color 0.15s, background 0.15s;
}
.guild-head:hover { border-color: #454957; background: var(--panel-2); }
.guild-head .avatar { width: 39px; height: 39px; border-radius: 12px; }
.guild-copy { flex: 1; min-width: 0; }
.guild-copy small { display: block; color: var(--muted); font-size: 9px; letter-spacing: 0.1em; }
.guild-copy strong { display: block; line-height: 1.25; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.guild-chevron { color: var(--muted); font-size: 20px; }
.side-nav { display: flex; flex-direction: column; gap: 18px; }
.nav-group { display: flex; flex-direction: column; gap: 4px; }
.nav-label { padding: 0 12px 5px; color: #70788f; font-size: 10px; font-weight: 700; letter-spacing: 0.13em; text-transform: uppercase; }
.nav-item {
  position: relative;
  display: flex;
  gap: 12px;
  align-items: center;
  min-height: 42px;
  padding: 8px 11px;
  border: 1px solid transparent;
  border-radius: 10px;
  text-decoration: none;
  color: var(--muted);
  transition: color 0.15s, background 0.15s, border-color 0.15s, transform 0.15s;
}
.nav-item:hover { background: var(--panel-2); color: var(--text); }
.nav-item.active {
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
}
.nav-icon { display: grid; place-items: center; width: 22px; color: #9da4ba; font-size: 19px; line-height: 1; }
.nav-item.active .nav-icon { color: #c4beff; }
.nav-text { flex: 1; font-size: 13px; font-weight: 550; }
.nav-item .lock { margin-left: auto; color: #7d8499; font-size: 17px; }
.sidebar-footer {
  display: flex;
  gap: 8px;
  align-items: center;
  margin: auto 5px 0;
  padding: 16px 8px 2px;
  border-top: 1px solid var(--line);
  color: #a4abc0;
  font-size: 12px;
}
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: #49d18a; box-shadow: 0 0 10px rgba(73, 209, 138, 0.55); }
.footer-version { margin-left: auto; color: #687087; font-size: 11px; }

.page-head { padding: 5px 2px 0; margin-bottom: 24px; }
.page-head h1 { font-size: clamp(24px, 3vw, 31px); letter-spacing: -0.035em; }
.page-head p { margin-top: 7px; color: #9ba2b7; }
.stats .card { min-height: 112px; justify-content: center; }
.stat-value { letter-spacing: -0.04em; }
.row { border-color: rgba(255, 255, 255, 0.07); }
.card h3 { letter-spacing: -0.01em; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat { display: flex; flex-direction: column; }
.stat-value { font-size: 28px; font-weight: 700; }

.row { display: flex; gap: 14px; justify-content: space-between; align-items: center; flex-wrap: wrap; padding: 14px 0; border-bottom: 1px solid var(--line); }
.row:last-child { border-bottom: 0; padding-bottom: 0; }
.row:first-child { padding-top: 0; }
.row-info { display: flex; flex-direction: column; gap: 4px; min-width: 200px; }
.row-controls { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
a.row { text-decoration: none; }
a.row:hover strong { color: var(--accent-hover); }

.badge { display: inline-block; width: fit-content; padding: 1px 9px; border-radius: 999px; font-size: 12px; border: 1px solid var(--line); color: var(--muted); }
.badge.on { color: #7ee2a0; border-color: var(--ok); background: rgba(59, 165, 93, 0.12); }
.badge.live { color: #fff; background: var(--bad); border-color: var(--bad); }

.switch { position: relative; width: 52px; height: 30px; padding: 0; border-radius: 999px; background: var(--panel-2); border: 1px solid var(--line); }
.switch.on { background: var(--ok); border-color: var(--ok); }
.switch-knob { position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: transform 0.15s; }
.switch.on .switch-knob { transform: translateX(22px); }

.form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: 13px; color: var(--muted); }
.inline-form { display: flex; gap: 8px; flex-wrap: wrap; }
.inline-form input { flex: 1; min-width: 160px; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
.stack { display: flex; flex-direction: column; gap: 18px; }
.help-list { margin: 0; padding-left: 18px; color: var(--muted); }
.help-list code { color: var(--text); background: var(--panel-2); padding: 1px 6px; border-radius: 6px; }

.embed { background: #2b2d31; border-left: 4px solid var(--accent); border-radius: 6px; padding: 12px 14px; }
.embed-title { font-weight: 700; margin-bottom: 6px; overflow-wrap: anywhere; }
.embed-body { white-space: pre-wrap; overflow-wrap: anywhere; }
.embed-footer { margin-top: 10px; font-size: 12px; color: var(--muted); }

#toasts { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 20; }
.toast { padding: 10px 16px; border-radius: 8px; background: var(--panel-2); border: 1px solid var(--ok); box-shadow: 0 6px 24px rgba(0, 0, 0, 0.4); max-width: 340px; }
.toast.error { border-color: var(--bad); }

@media (max-width: 860px) {
  .layout, .two-col { grid-template-columns: 1fr; }
  .sidebar { position: static; min-height: 0; }
  .side-nav {
    flex-direction: row;
    gap: 0;
    overflow-x: auto;
    padding-bottom: 4px;
    scrollbar-width: thin;
    scrollbar-color: var(--line) transparent;
  }
  .nav-group { display: contents; }
  .nav-label { display: none; }
  .nav-item { flex: 0 0 auto; min-height: 40px; }
  .sidebar-footer { display: none; }
  .topbar { padding: 12px 16px; }
  main { padding: 0 16px; }
}

@media (max-width: 520px) {
  .topbar { padding: 11px 14px; }
  main { margin-top: 16px; padding: 0 12px; }
  .sidebar { padding: 13px 10px 10px; }
  .sidebar-brand { padding-bottom: 13px; }
  .guild-head { margin-bottom: 13px; }
  .nav-item { padding: 8px 10px; gap: 8px; }
  .nav-text { font-size: 12px; }
  .user { gap: 8px; font-size: 13px; }
  .landing-header { min-height: 66px; padding: 0 16px; }
  .landing-brand { font-size: 14px; }
  .landing-actions { gap: 14px; }
  .landing-support { font-size: 13px; }
  .panel-button { min-width: 76px; padding: 7px 10px; }
  .landing-main { min-height: calc(100vh - 66px); padding: 28px 14px; }
  .invite-frame { padding: 34px 20px 28px; border-radius: 16px; }
  .invite-logo { width: 78px; height: 78px; border-radius: 23px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; }
}
