:root {
  --bg: #0e0f12;
  --panel: #15171c;
  --raised: #1c1f26;
  --line: #272b34;
  --text: #ecebe8;
  --muted: #9097a3;
  --ember: #ff7a3d;
  --ember-soft: rgba(255, 122, 61, 0.14);
  --good: #3dd68c;
  --bad: #ff6369;
  --radius: 12px;
  color-scheme: dark;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, 'Segoe UI', Roboto, sans-serif;
}

h1, h2, h3, p { margin: 0; }
h1 { font-size: 26px; font-weight: 650; letter-spacing: -0.02em; }
h2 { font-size: 15px; font-weight: 600; margin-bottom: 14px; }
small, .muted, time { color: var(--muted); }
small { font-size: 12.5px; }
a { color: inherit; text-decoration: none; }
.grow { flex: 1; min-width: 0; }

/* --- layout --- */

.shell { display: grid; grid-template-columns: 260px 1fr; height: 100vh; }

aside {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 22px 14px 14px;
  background: var(--panel);
  border-right: 1px solid var(--line);
  overflow-y: auto;
}

.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px; font-weight: 650; font-size: 17px; letter-spacing: -0.01em; }
.ember {
  width: 14px; height: 14px; border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #ffd08a, var(--ember) 55%, #b3320c);
  box-shadow: 0 0 14px rgba(255, 122, 61, 0.7);
}

nav { flex: 1; display: flex; flex-direction: column; gap: 2px; }
nav h3 { margin: 16px 10px 6px; font-size: 11px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: #c9ccd3; }
nav a:hover { background: var(--raised); color: var(--text); }
nav a.active { background: var(--ember-soft); color: #ffb48f; }

.icon { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #3a3f4a; flex: none; }
.dot.on { background: var(--good); box-shadow: 0 0 8px rgba(61, 214, 140, 0.6); }

.user { display: flex; align-items: center; gap: 10px; padding: 10px 8px 0; border-top: 1px solid var(--line); }
.user .grow { display: flex; flex-direction: column; line-height: 1.25; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar { width: 32px; height: 32px; border-radius: 50%; flex: none; display: grid; place-items: center; background: var(--raised); color: var(--muted); font-weight: 600; object-fit: cover; }

.body { display: flex; flex-direction: column; min-width: 0; height: 100vh; }
.content { flex: 1; overflow-y: auto; padding: 36px clamp(16px, 4vw, 48px) 64px; }
.content > * { max-width: 980px; margin-inline: auto; }
.content > * + * { margin-top: 20px; }
.banner { padding: 8px 16px; text-align: center; font-size: 13px; background: var(--ember-soft); color: #ffb48f; }
.menu { display: none; margin: 10px 16px 0; align-self: flex-start; }

.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; }
.page-head p { margin-top: 6px; color: var(--muted); max-width: 62ch; }
.enable { display: flex; align-items: center; gap: 10px; font-weight: 600; padding-top: 6px; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; }
.card footer { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line); }
.split { display: grid; grid-template-columns: 1.5fr 1fr; gap: 20px; align-items: start; }
.stack { display: grid; gap: 20px; }

/* --- overview --- */

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; color: var(--muted); font-size: 13px; }
.stat b { display: block; font-size: 28px; font-weight: 650; letter-spacing: -0.02em; color: var(--text); font-variant-numeric: tabular-nums; }
.stat.up b { color: var(--good); }
.stat.down b { color: var(--bad); }

ul, ol { list-style: none; margin: 0; padding: 0; }
.feed li, .top li, .modlist a { display: flex; align-items: center; gap: 12px; padding: 9px 0; }
.feed li + li, .top li + li, .modlist li + li { border-top: 1px solid var(--line); }
.feed time { font-size: 12.5px; white-space: nowrap; }
.top { counter-reset: place; }
.top li::before { counter-increment: place; content: counter(place); width: 22px; color: var(--muted); font-variant-numeric: tabular-nums; }
.modlist a:hover { color: #ffb48f; }
.modlist small { margin-left: auto; }

.tag { flex: none; min-width: 62px; white-space: nowrap; padding: 2px 8px; border-radius: 6px; font-size: 12px; font-weight: 600; text-align: center; background: var(--raised); color: var(--muted); }
.tag.join, .tag.boost, .tag.login { background: rgba(61, 214, 140, 0.13); color: var(--good); }
.tag.leave, .tag.ban, .tag.denied { background: rgba(255, 99, 105, 0.13); color: var(--bad); }
.tag.live, .tag.clip { background: rgba(145, 70, 255, 0.18); color: #bf9bff; }
.tag.levelup { background: var(--ember-soft); color: #ffb48f; }

/* --- forms --- */

.field { display: grid; grid-template-columns: 240px 1fr; gap: 8px 24px; padding: 14px 0; align-items: start; }
.field + .field { border-top: 1px solid var(--line); }
.field:first-child { padding-top: 0; }
.field .label { font-weight: 550; padding-top: 7px; }
.field .label small { display: block; font-weight: 400; margin-top: 2px; }
.field.bool { align-items: center; }
.field.bool .label { padding-top: 0; }

input[type='text'], input[type='number'], input[type='search'], textarea, select {
  width: 100%;
  padding: 8px 11px;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
}
textarea { resize: vertical; min-height: 76px; }
input:focus, textarea:focus, select:focus, button:focus-visible, a:focus-visible { outline: 2px solid var(--ember); outline-offset: 1px; }
input[type='checkbox'] { accent-color: var(--ember); width: 16px; height: 16px; }

button, .button {
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--raised);
  color: var(--text);
  font: inherit;
  font-weight: 550;
  cursor: pointer;
}
button:hover, .button:hover { border-color: #3a404c; }
button:disabled { opacity: 0.55; cursor: progress; }
.primary { background: var(--ember); border-color: var(--ember); color: #1a0d05; }
.primary:hover { background: #ff8d58; border-color: #ff8d58; }
.ghost { background: transparent; color: var(--muted); }
.ghost:hover { color: var(--text); }

.switch { position: relative; display: inline-block; width: 42px; height: 24px; flex: none; }
.switch input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch span { position: absolute; inset: 0; border-radius: 12px; background: #343945; transition: background 0.15s; pointer-events: none; }
.switch span::after { content: ''; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform 0.15s; }
.switch input:checked + span { background: var(--ember); }
.switch input:checked + span::after { transform: translateX(18px); }
.switch input:focus-visible + span { outline: 2px solid var(--ember); outline-offset: 2px; }

.vars { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.vars button { padding: 2px 8px; font-size: 12.5px; font-family: ui-monospace, Consolas, monospace; color: #ffb48f; background: var(--ember-soft); border-color: transparent; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.chips select { width: auto; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 4px 4px 4px 11px; border-radius: 999px; background: var(--raised); border: 1px solid var(--line); font-size: 13.5px; }
.chip button { padding: 0 6px; border: 0; background: none; color: var(--muted); font-size: 16px; line-height: 1; }

.search { margin-top: 10px; max-width: 360px; }
.results { display: grid; gap: 2px; margin-top: 4px; }
.person { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; background: transparent; border-color: transparent; }
.person:hover { background: var(--raised); }

.rows { display: grid; gap: 8px; justify-items: start; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; width: 100%; }
.row select { width: auto; flex: 1; min-width: 160px; }
.row .emoji { width: 64px; flex: none; text-align: center; }
.inline { display: flex; align-items: center; gap: 8px; white-space: nowrap; color: var(--muted); }
.inline input { width: 84px; }
.inline input.cmd { width: 140px; }
.row textarea { flex: 1; min-width: 220px; min-height: 0; }

.names { width: 100%; border-collapse: collapse; }
.names th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; padding: 0 10px 10px 0; }
.names td { padding: 6px 10px 6px 0; border-top: 1px solid var(--line); vertical-align: middle; }
.names tr.category td { padding-top: 16px; font-weight: 600; }
.names td:first-child { width: 28px; }
.names td:last-child { width: 90px; padding-right: 0; }

/* --- login and toasts --- */

.login-page { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: radial-gradient(circle at 50% 0%, rgba(255, 122, 61, 0.12), transparent 60%); }
.login-page .card { width: min(400px, 100%); display: grid; gap: 18px; padding: 32px; }
.login-page .brand { padding: 0; font-size: 20px; }
.login-page .button { text-align: center; padding: 11px; }
.error { color: var(--bad); }

#toasts { position: fixed; right: 20px; bottom: 20px; display: grid; gap: 8px; z-index: 10; max-width: min(420px, calc(100vw - 40px)); }
.toast { padding: 11px 16px; border-radius: 10px; background: var(--raised); border: 1px solid var(--line); border-left: 3px solid var(--good); box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45); }
.toast.error { border-left-color: var(--bad); }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  aside { position: fixed; inset: 0 auto 0 0; width: 270px; z-index: 5; transform: translateX(-100%); transition: transform 0.2s; }
  .nav-open aside { transform: none; box-shadow: 0 0 0 100vmax rgba(0, 0, 0, 0.55); }
  .menu { display: block; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .split { grid-template-columns: 1fr; }
  .field { grid-template-columns: 1fr; }
  .field.bool { grid-template-columns: 1fr auto; }
  .page-head { flex-direction: column; gap: 12px; }
  .names td:nth-child(2), .names th:nth-child(2) { display: none; }
}

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