:root {
  --bg: #0e0f13;
  --bg-glow: rgba(139, 124, 246, 0.16);
  --surface: #17181e;
  --surface-2: #1e1f27;
  --surface-3: #262732;
  --line: #2a2b36;
  --line-strong: #393a48;
  --text: #ecedf3;
  --muted: #a0a2b2;
  --faint: #6f7181;
  --accent: #8b7cf6;
  --accent-strong: #7a69f0;
  --accent-ink: #ffffff;
  --accent-soft: rgba(139, 124, 246, 0.14);
  --ok: #34d399;
  --ok-soft: rgba(52, 211, 153, 0.13);
  --warn: #f5b942;
  --warn-soft: rgba(245, 185, 66, 0.13);
  --bad: #f87171;
  --bad-soft: rgba(248, 113, 113, 0.13);
  --discord: #313338;
  --discord-embed: #2b2d31;
  --discord-text: #dbdee1;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.28);
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f5f5f9;
    --bg-glow: rgba(139, 124, 246, 0.14);
    --surface: #ffffff;
    --surface-2: #f6f6fa;
    --surface-3: #ececf3;
    --line: #e4e4ec;
    --line-strong: #d3d3df;
    --text: #17181f;
    --muted: #5c5e6e;
    --faint: #8a8c9b;
    --accent: #6f5ef0;
    --accent-strong: #5f4de6;
    --accent-soft: rgba(111, 94, 240, 0.1);
    --ok: #0f9f6e;
    --ok-soft: rgba(15, 159, 110, 0.1);
    --warn: #b7791f;
    --warn-soft: rgba(183, 121, 31, 0.1);
    --bad: #d64545;
    --bad-soft: rgba(214, 69, 69, 0.09);
    --shadow: 0 10px 30px rgba(30, 30, 60, 0.08);
    color-scheme: light;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: radial-gradient(1200px 500px at 50% -200px, var(--bg-glow), transparent 70%) no-repeat, var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.25; letter-spacing: -0.01em; }
h1 { font-size: 26px; font-weight: 700; }
h2 { font-size: 17px; font-weight: 650; }
h3 { font-size: 15px; font-weight: 650; }
p { margin: 0; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 13px; }
svg.i { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* layout */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 12px;
  padding: 12px max(16px, calc((100vw - 1080px) / 2));
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand .logo { width: 32px; height: 32px; border-radius: 9px; background: var(--accent); display: grid; place-items: center; color: #fff; }
.brand .logo svg.i { width: 18px; height: 18px; }
.brand small { font-weight: 500; color: var(--muted); }
.topbar .spacer { flex: 1; }
.me { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 14px; min-width: 0; }
.me img { width: 28px; height: 28px; border-radius: 50%; }
.me span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 160px; }
.wrap { max-width: 1080px; margin: 0 auto; padding: 24px 16px 64px; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.between { justify-content: space-between; }
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.cols { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; }
@media (max-width: 820px) { .cols { grid-template-columns: minmax(0, 1fr); } }

/* cards */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.card > h2 + p, .card > .head + p { margin-top: 4px; }
.card .head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.card-list { display: flex; flex-direction: column; }
.item { display: flex; gap: 12px; align-items: flex-start; padding: 14px 0; border-top: 1px solid var(--line); }
.item:first-child { border-top: 0; padding-top: 4px; }
.item .body { flex: 1; min-width: 0; }
.item .title { font-weight: 600; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.item .text { color: var(--muted); font-size: 14px; margin-top: 2px; overflow-wrap: anywhere; }
.clamp { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.item .actions { display: flex; gap: 6px; flex: none; }
@media (max-width: 560px) { .item { flex-wrap: wrap; } .item .actions { width: 100%; justify-content: flex-end; } }
.empty { text-align: center; padding: 28px 12px; color: var(--muted); }
.empty svg.i { width: 28px; height: 28px; color: var(--faint); margin-bottom: 6px; }

/* buttons and inputs */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 38px; padding: 0 16px; border-radius: 10px; border: 1px solid transparent;
  background: var(--accent); color: var(--accent-ink); font: inherit; font-weight: 600; font-size: 14px;
  cursor: pointer; white-space: nowrap; transition: background 0.15s, border-color 0.15s, opacity 0.15s;
}
.btn:hover { background: var(--accent-strong); text-decoration: none; }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn.ghost { background: transparent; color: var(--text); border-color: var(--line-strong); }
.btn.ghost:hover { background: var(--surface-2); }
.btn.quiet { background: transparent; color: var(--muted); padding: 0 10px; }
.btn.quiet:hover { background: var(--surface-2); color: var(--text); }
.btn.danger { background: transparent; color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, transparent); }
.btn.danger:hover { background: var(--bad-soft); }
.btn.small { height: 32px; padding: 0 12px; font-size: 13px; border-radius: 8px; }
.btn.big { height: 46px; padding: 0 22px; font-size: 15px; border-radius: 12px; }
.btn.discord { background: #5865f2; color: #fff; }
.btn.discord:hover { background: #4752c4; }
.btn .spin { width: 14px; height: 14px; border-width: 2px; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; font-weight: 600; color: var(--muted); }
.field .hint { font-size: 12.5px; color: var(--faint); }
.fields { display: flex; flex-direction: column; gap: 14px; margin-top: 14px; }
input[type=text], input[type=number], select, textarea {
  width: 100%; font: inherit; font-size: 14px; color: var(--text);
  background: var(--surface-2); border: 1px solid var(--line-strong); border-radius: 10px; padding: 9px 12px;
  outline: none; transition: border-color 0.15s, box-shadow 0.15s;
}
textarea { resize: vertical; min-height: 96px; line-height: 1.45; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input[type=number] { max-width: 140px; }
.counter { font-size: 12px; color: var(--faint); text-align: right; }

.setting { display: flex; align-items: center; gap: 16px; padding: 14px 0; border-top: 1px solid var(--line); }
.setting:first-of-type { border-top: 0; }
.setting .body { flex: 1; min-width: 0; }
.setting .name { font-weight: 600; }
.setting .desc { font-size: 13.5px; color: var(--muted); }
.switch { position: relative; width: 44px; height: 26px; flex: none; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; border-radius: 99px; background: var(--surface-3); border: 1px solid var(--line-strong); transition: background 0.15s; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform 0.15s; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3); }
.switch input:checked + span { background: var(--accent); border-color: var(--accent); }
.switch input:checked + span::after { transform: translateX(18px); }
.switch input:focus-visible + span { box-shadow: 0 0 0 3px var(--accent-soft); }

/* chips and badges */
.badge { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 9px; border-radius: 99px; font-size: 12px; font-weight: 600; background: var(--surface-3); color: var(--muted); white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.accent { background: var(--accent-soft); color: var(--accent); }
.badge svg.i { width: 12px; height: 12px; stroke-width: 2.6; }
.role { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; padding: 2px 9px 2px 7px; border-radius: 99px; background: var(--surface-3); }
.role i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 4px; height: 32px; padding: 0 6px 0 12px; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--line-strong); font-size: 14px; }
.chip button { border: 0; background: none; color: var(--muted); cursor: pointer; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; }
.chip button:hover { background: var(--surface-3); color: var(--text); }
.chip button svg.i { width: 14px; height: 14px; }

/* banners */
.banner { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-radius: var(--radius-sm); font-size: 14px; border: 1px solid transparent; }
.banner svg.i { margin-top: 2px; }
.banner.warn { background: var(--warn-soft); color: var(--text); border-color: color-mix(in srgb, var(--warn) 30%, transparent); }
.banner.warn svg.i { color: var(--warn); }
.banner.bad { background: var(--bad-soft); border-color: color-mix(in srgb, var(--bad) 30%, transparent); }
.banner.bad svg.i { color: var(--bad); }
.banner.info { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 30%, transparent); }
.banner.info svg.i { color: var(--accent); }
.banner b { font-weight: 650; }

/* login */
.login { max-width: 440px; margin: 9vh auto 0; text-align: center; padding: 34px 28px; box-shadow: var(--shadow); }
.login .logo { width: 64px; height: 64px; border-radius: 18px; background: var(--accent); color: #fff; display: grid; place-items: center; margin: 0 auto 18px; box-shadow: 0 10px 30px color-mix(in srgb, var(--accent) 40%, transparent); }
.login .logo svg.i { width: 32px; height: 32px; }
.login p { margin-top: 10px; color: var(--muted); }
.login .btn { margin-top: 24px; width: 100%; }
.login .fine { font-size: 13px; color: var(--faint); margin-top: 16px; }

/* servers */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head p { margin-top: 4px; }
.section-title { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--faint); margin: 28px 0 12px; }
.server { display: flex; align-items: center; gap: 14px; padding: 16px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); color: var(--text); text-align: left; font: inherit; cursor: pointer; width: 100%; transition: border-color 0.15s, transform 0.15s; }
.server:hover { border-color: var(--accent); text-decoration: none; transform: translateY(-1px); }
.server.off { cursor: default; opacity: 0.72; }
.server.off:hover { border-color: var(--line); transform: none; }
.server .body { flex: 1; min-width: 0; }
.server .name { font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.server .meta { margin-top: 4px; display: flex; gap: 6px; flex-wrap: wrap; }
.avatar { width: 48px; height: 48px; border-radius: 14px; flex: none; background: var(--surface-3); display: grid; place-items: center; font-weight: 700; color: var(--muted); overflow: hidden; font-size: 15px; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.lg { width: 56px; height: 56px; border-radius: 16px; font-size: 18px; }

/* server page */
.guild-head { display: flex; align-items: center; gap: 14px; margin: 6px 0 18px; }
.guild-head .body { min-width: 0; flex: 1; }
.guild-head h1 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 560px) { .guild-head .wide { display: none; } .guild-head .btn { padding: 0 10px; } }
.back { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); font-size: 14px; margin-bottom: 6px; }
.back:hover { color: var(--text); text-decoration: none; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 20px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { flex: none; display: inline-flex; align-items: center; gap: 7px; padding: 10px 12px; color: var(--muted); font-weight: 600; font-size: 14px; border: 0; border-bottom: 2px solid transparent; background: none; cursor: pointer; font-family: inherit; margin-bottom: -1px; }
.tab:hover { color: var(--text); }
.tab.on { color: var(--text); border-bottom-color: var(--accent); }
.tab .count { background: var(--surface-3); color: var(--muted); border-radius: 99px; font-size: 11.5px; padding: 0 7px; line-height: 18px; }

.stats { display: grid; gap: 12px; grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 720px) { .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.stat .v { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; }
.stat .k { font-size: 13px; color: var(--muted); }

.steps { display: flex; flex-direction: column; }
.step { display: flex; gap: 14px; padding: 16px 0; border-top: 1px solid var(--line); }
.step:first-child { border-top: 0; padding-top: 6px; }
.step .dot { width: 28px; height: 28px; border-radius: 50%; flex: none; display: grid; place-items: center; font-weight: 700; font-size: 13px; background: var(--surface-3); color: var(--muted); }
.step.done .dot { background: var(--ok-soft); color: var(--ok); }
.step .dot svg.i { width: 15px; height: 15px; stroke-width: 3; }
.step .body { flex: 1; min-width: 0; }
.step .body > p { color: var(--muted); font-size: 14px; margin-top: 2px; }
.step .row { margin-top: 10px; }
.setup-grid { display: grid; gap: 12px; grid-template-columns: repeat(3, minmax(0, 1fr)); margin-top: 12px; }
@media (max-width: 720px) { .setup-grid { grid-template-columns: minmax(0, 1fr); } }

/* Discord message preview */
.preview { background: var(--discord); border-radius: 12px; padding: 16px; color: var(--discord-text); font-size: 15px; }
.preview .who { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; font-weight: 600; color: #f2f3f5; }
.preview .who .pic { width: 36px; height: 36px; border-radius: 50%; background: var(--accent); display: grid; place-items: center; color: #fff; }
.preview .who .pic svg.i { width: 18px; height: 18px; }
.preview .who .tag { background: #5865f2; color: #fff; font-size: 10px; font-weight: 700; padding: 1px 5px; border-radius: 4px; }
.embed { background: var(--discord-embed); border-left: 4px solid #8b7cf6; border-radius: 4px; padding: 10px 14px 14px; margin-left: 44px; max-width: 460px; }
.embed .t { font-weight: 700; color: #f2f3f5; margin-bottom: 4px; overflow-wrap: anywhere; }
.embed .d { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14px; line-height: 1.4; }
.dbtn { display: inline-flex; align-items: center; gap: 6px; margin: 8px 0 0 44px; background: #5865f2; color: #fff; font-size: 14px; font-weight: 500; padding: 6px 14px; border-radius: 4px; }

/* tickets */
.ticket-meta { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.num { color: var(--faint); font-weight: 600; font-variant-numeric: tabular-nums; }

/* toasts, spinner */
#toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 50; display: flex; flex-direction: column; gap: 8px; align-items: center; width: calc(100% - 32px); max-width: 460px; pointer-events: none; }
.toast { pointer-events: auto; display: flex; gap: 10px; align-items: center; padding: 11px 16px; border-radius: 12px; background: var(--surface-3); border: 1px solid var(--line-strong); box-shadow: var(--shadow); font-size: 14px; animation: rise 0.2s ease-out; }
.toast.ok svg.i { color: var(--ok); }
.toast.bad svg.i { color: var(--bad); }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
.boot { min-height: 60vh; display: grid; place-items: center; }
.spin { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--line-strong); border-top-color: var(--accent); animation: turn 0.8s linear infinite; display: inline-block; }
@keyframes turn { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { * { animation-duration: 0.01ms !important; transition: none !important; } }
