:root {
  --bg: #16181d;
  --side: #1f232a;
  --card: #22262e;
  --card-2: #2a2f38;
  --line: rgba(255, 255, 255, .07);
  --line-strong: rgba(255, 255, 255, .14);
  --text: #e6e8eb;
  --muted: #9aa1ab;
  --soft: #6f7782;
  --accent: #5865f2;
  --accent-hover: #4752c4;
  --sparkle: #3b82f6;
  --ok: #3ba55c;
  --bad: #ed4245;
  --radius: 10px;
  --sans: 'gg sans', 'Segoe UI', Inter, system-ui, -apple-system, sans-serif;
  --mono: 'Cascadia Code', 'SFMono-Regular', Consolas, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { background: var(--bg); color: var(--text); font: 15px/1.5 var(--sans); }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
svg { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
[hidden] { display: none !important; }

/* Top bar */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px; height: 60px; padding: 0 20px; background: var(--bg); border-bottom: 1px solid var(--line); }
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; font-weight: 600; }
.brand img { width: 28px; height: 28px; }
.server-switch { display: flex; align-items: center; gap: 8px; margin-left: 12px; min-width: 0; }
.server-switch button { display: inline-flex; align-items: center; gap: 8px; max-width: 280px; padding: 6px 12px; border: 1px solid var(--line-strong); border-radius: 999px; background: var(--card); cursor: pointer; }
.server-switch button span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.server-switch img, .server-switch .guild-initials { width: 22px; height: 22px; border-radius: 50%; font-size: 10px; }
.account { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.account img { width: 32px; height: 32px; border-radius: 50%; }
.account .name { color: var(--muted); max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.icon-button { display: inline-grid; place-items: center; width: 36px; height: 36px; padding: 0; border: 0; border-radius: 50%; background: var(--card); cursor: pointer; }
.icon-button:hover { background: var(--card-2); }
.menu-button { display: none; }

/* Buttons and inputs */
.button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 9px 16px; border: 1px solid transparent; border-radius: 8px; background: var(--card-2); font-weight: 500; text-decoration: none; cursor: pointer; white-space: nowrap; }
.button:hover { border-color: var(--line-strong); }
.button:disabled { opacity: .55; cursor: default; }
.button-primary { background: var(--accent); color: #fff; }
.button-primary:hover { background: var(--accent-hover); border-color: transparent; }
.button-danger { background: transparent; color: #f38688; border-color: rgba(237, 66, 69, .35); }
.button-small { padding: 5px 10px; font-size: 13px; }
.button-ghost { background: transparent; border-color: var(--line-strong); }
input[type=text], input[type=number], select, textarea { width: 100%; padding: 9px 12px; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--bg); outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
textarea { min-height: 96px; resize: vertical; }
input[type=color] { width: 44px; height: 40px; padding: 2px; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--bg); cursor: pointer; }

/* Login, setup and server list */
.center-note { display: grid; place-items: center; min-height: calc(100vh - 60px); padding: 24px; text-align: center; }
.panel { width: min(100%, 440px); padding: 32px; border: 1px solid var(--line); border-radius: 16px; background: var(--side); }
.panel h1 { margin: 0 0 8px; font-size: 24px; }
.panel p { margin: 0 0 20px; color: var(--muted); }
.panel .error { color: #f38688; }
.panel code { font-family: var(--mono); font-size: 13px; }
.panel ol { text-align: left; color: var(--muted); padding-left: 20px; }
.spinner { width: 28px; height: 28px; border: 3px solid var(--line-strong); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.servers { max-width: 1100px; margin: 0 auto; padding: 32px 20px 64px; }
.servers-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.servers-head h1 { margin: 0; font-size: 24px; }
.servers-head p { margin: 4px 0 0; color: var(--muted); }
.server-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.server-card { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 22px 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--side); text-align: center; }
.server-card .guild-icon, .server-card .guild-initials { width: 72px; height: 72px; border-radius: 50%; font-size: 22px; }
.server-card h2 { margin: 0; font-size: 16px; font-weight: 600; width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.server-card .button { width: 100%; }
.guild-initials { display: inline-grid; place-items: center; background: var(--card-2); color: var(--muted); font-weight: 600; }
.empty { padding: 40px 20px; border: 1px dashed var(--line-strong); border-radius: 14px; color: var(--muted); text-align: center; }

/* Guild layout */
.layout { display: flex; min-height: calc(100vh - 60px); }
.sidebar { position: sticky; top: 60px; flex: 0 0 270px; height: calc(100vh - 60px); overflow-y: auto; padding: 16px 14px 24px; background: var(--side); border-right: 1px solid var(--line); }
.side-top { display: flex; justify-content: center; align-items: center; gap: 8px; margin-bottom: 18px; }
.home-pill { display: inline-flex; align-items: center; gap: 8px; padding: 6px 22px; border: 1px solid var(--line-strong); border-radius: 999px; background: #2b3039; font-weight: 600; cursor: pointer; }
.home-pill[aria-current=page] { border-color: rgba(255, 255, 255, .3); }
.home-pill svg { width: 16px; height: 16px; fill: currentColor; stroke: none; }
.refresh-button { display: grid; place-items: center; width: 34px; height: 34px; padding: 0; border: 0; border-radius: 50%; background: #2b3039; cursor: pointer; }
.refresh-button.spinning svg { animation: spin .8s linear infinite; }
.nav-item { display: flex; align-items: center; gap: 14px; width: 100%; padding: 10px 14px; border: 0; border-radius: 8px; background: transparent; text-align: left; cursor: pointer; }
.nav-item svg { color: var(--text); }
.nav-item span { text-decoration: underline; text-decoration-color: rgba(255, 255, 255, .35); text-underline-offset: 4px; }
.nav-item:hover { background: rgba(255, 255, 255, .04); }
.nav-item[aria-current=page] { background: rgba(255, 255, 255, .07); }
.nav-item[aria-current=page] span { text-decoration-color: currentColor; }
.nav-item .sparkle { color: var(--sparkle); }
.side-label { margin: 18px 14px 6px; font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }

.content { flex: 1; min-width: 0; padding: 28px 32px 80px; }
.content-inner { max-width: 920px; margin: 0 auto; display: flex; flex-direction: column; gap: 18px; }
.page-head h1 { margin: 0; font-size: 26px; font-weight: 600; }
.page-head p { margin: 6px 0 0; color: var(--muted); }

.card { border: 1px solid var(--line); border-radius: 12px; background: var(--card); }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 18px 20px 0; }
.card-head h2 { margin: 0; font-size: 16px; font-weight: 600; }
.card-head p { margin: 4px 0 0; color: var(--muted); font-size: 14px; }
.card-body { display: flex; flex-direction: column; gap: 16px; padding: 18px 20px; }
.card-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px; border-top: 1px solid var(--line); }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label, .field > .label { font-size: 13px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.field .hint { font-size: 13px; color: var(--soft); }
.row { display: flex; gap: 10px; align-items: center; }
.row > * { min-width: 0; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); gap: 14px; }

.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.switch-row .text strong { display: block; font-weight: 600; }
.switch-row .text span { color: var(--muted); font-size: 14px; }
.switch { position: relative; flex: none; width: 44px; height: 24px; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.switch .track { position: absolute; inset: 0; border-radius: 999px; background: #4e5058; transition: background .15s; pointer-events: none; }
.switch .track::after { content: ''; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform .15s; }
.switch input:checked + .track { background: var(--ok); }
.switch input:checked + .track::after { transform: translateX(20px); }
.switch input:focus-visible + .track { outline: 2px solid var(--accent); outline-offset: 2px; }

.list { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.list-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 14px; border-top: 1px solid var(--line); }
.list-item:first-child { border-top: 0; }
.list-item .main { min-width: 0; }
.list-item .main strong { display: block; }
.list-item .main > span { display: block; color: var(--muted); font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-empty { padding: 14px; color: var(--soft); font-size: 14px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 6px 4px 12px; border-radius: 999px; background: var(--card-2); font-size: 14px; }
.chip button { display: grid; place-items: center; width: 22px; height: 22px; padding: 0; border: 0; border-radius: 50%; background: transparent; color: var(--muted); cursor: pointer; }
.chip button:hover { background: rgba(255, 255, 255, .08); color: var(--text); }
.chip button svg { width: 14px; height: 14px; }

.overview { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 250px), 1fr)); gap: 14px; }
.overview-card { display: flex; flex-direction: column; gap: 6px; padding: 16px 18px; border: 1px solid var(--line); border-radius: 12px; background: var(--card); text-align: left; cursor: pointer; }
.overview-card:hover { border-color: var(--line-strong); }
.overview-card .top { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-weight: 600; }
.overview-card .detail { color: var(--muted); font-size: 14px; }
.status { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 500; color: var(--muted); }
.status::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--soft); }
.status.on { color: #7ad69a; }
.status.on::before { background: var(--ok); }

.guild-hero { display: flex; align-items: center; gap: 16px; }
.guild-hero .guild-icon, .guild-hero .guild-initials { width: 64px; height: 64px; border-radius: 50%; font-size: 20px; }
.note { padding: 12px 14px; border-radius: 10px; background: rgba(88, 101, 242, .12); color: #c9cdfb; font-size: 14px; }
.vars { display: flex; flex-wrap: wrap; gap: 6px; }
.vars code { padding: 2px 6px; border-radius: 6px; background: var(--card-2); font-family: var(--mono); font-size: 12px; color: var(--muted); cursor: pointer; }
.embed-preview { display: flex; border-radius: 4px; background: #2b2d31; overflow: hidden; }
.embed-preview .bar { width: 4px; flex: none; }
.embed-preview .body { padding: 10px 14px; color: #dbdee1; font-size: 14px; }
.muted { color: var(--muted); font-size: 13px; white-space: nowrap; }
.command-list .list-item code { font-family: var(--mono); font-size: 14px; }
.check-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr)); gap: 10px; }
.check { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }

.stack { display: flex; flex-direction: column; gap: 18px; }
.row.wrap { flex-wrap: wrap; }

/* Bot profile */
.profile-layout { display: grid; grid-template-columns: minmax(0, 340px) minmax(0, 1fr); gap: 24px; align-items: start; }
.profile-card { border: 1px solid var(--line); border-radius: 12px; background: #111214; overflow: hidden; }
.profile-banner { height: 120px; background: var(--accent) center / cover no-repeat; }
.profile-avatar { display: block; width: 88px; height: 88px; margin: -46px 0 0 16px; border: 6px solid #111214; border-radius: 50%; background: var(--card-2); object-fit: cover; }
.profile-body { padding: 8px 16px 18px; }
.profile-name { display: flex; align-items: center; gap: 8px; font-size: 18px; font-weight: 600; }
.app-tag { padding: 1px 6px; border-radius: 4px; background: var(--accent); color: #fff; font-size: 11px; font-weight: 600; }
.profile-bio { margin: 10px 0 0; font-size: 14px; white-space: pre-wrap; word-break: break-word; }
.profile-bio.empty { color: var(--soft); }

/* Moderation history */
.mod-item { justify-content: flex-start; align-items: flex-start; }
.mod-item .main { flex: 1; }
.mod-item .main > span { white-space: normal; }
.mod-avatar { flex: none; width: 36px; height: 36px; border-radius: 50%; font-size: 12px; object-fit: cover; }
.mod-item time { flex: none; font-size: 13px; }
.mod-tag { display: inline-block; margin-right: 8px; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; vertical-align: 1px; }
.mod-tag.bad { background: rgba(237, 66, 69, .16); color: #f38688; }
.mod-tag.warn { background: rgba(250, 166, 26, .16); color: #f8c171; }
.mod-tag.ok { background: rgba(59, 165, 92, .16); color: #7ad69a; }

.toast { position: fixed; left: 50%; bottom: 24px; z-index: 50; transform: translateX(-50%); max-width: calc(100vw - 32px); padding: 10px 16px; border-radius: 10px; background: #111214; border: 1px solid var(--line-strong); box-shadow: 0 8px 24px rgba(0, 0, 0, .4); }
.toast.ok { border-color: rgba(59, 165, 92, .6); }
.toast.bad { border-color: rgba(237, 66, 69, .6); }

.scrim { position: fixed; inset: 60px 0 0; z-index: 9; background: rgba(0, 0, 0, .5); }

@media (max-width: 860px) {
  .menu-button { display: inline-grid; }
  .sidebar { position: fixed; z-index: 10; top: 60px; left: 0; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: none; }
  .content { padding: 20px 16px 64px; }
  .account .name, .brand span { display: none; }
  .server-switch button { max-width: 180px; }
  .profile-layout { grid-template-columns: minmax(0, 1fr); }
}
