:root {
  color-scheme: light dark;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f0f1f4;
  --border: #e2e4e9;
  --text: #1f2430;
  --muted: #6b7280;
  --accent: #5865f2;
  --accent-text: #ffffff;
  --ok: #22a06b;
  --off: #e5484d;
  --warn: #d97706;
  --radius: 12px;
  --shadow: 0 1px 2px rgb(0 0 0 / 6%), 0 8px 24px rgb(0 0 0 / 4%);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161a;
    --surface: #1c1f25;
    --surface-2: #23272f;
    --border: #2c3038;
    --text: #e8eaed;
    --muted: #99a1ad;
    --shadow: 0 1px 2px rgb(0 0 0 / 30%), 0 8px 24px rgb(0 0 0 / 20%);
  }
}

* {
  box-sizing: border-box;
}

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

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

h1 {
  font-size: 1.6rem;
  margin: 0 0 0.5rem;
  letter-spacing: -0.01em;
}

h2 {
  font-size: 1.15rem;
  margin: 2rem 0 0.75rem;
}

h3 {
  font-size: 1rem;
  margin: 0 0 0.35rem;
}

p {
  margin: 0 0 0.75rem;
}

code {
  background: var(--surface-2);
  border-radius: 5px;
  padding: 0.1em 0.4em;
  font-size: 0.9em;
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.88em;
}

.lead {
  color: var(--muted);
  max-width: 60ch;
}

.hint {
  color: var(--warn);
  font-size: 0.9rem;
}

.empty {
  color: var(--muted);
  padding: 1rem 0;
}

/* -- chrome ---------------------------------------------------------------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1.5rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-weight: 650;
  color: var(--text);
}

.brand:hover {
  text-decoration: none;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 9px;
  background: var(--accent);
  color: var(--accent-text);
  font-weight: 700;
}

.topnav {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.topnav a {
  color: var(--muted);
  font-weight: 500;
}

.topnav a:hover {
  color: var(--text);
  text-decoration: none;
}

.account {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.account img {
  border-radius: 50%;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.dot-on {
  background: var(--ok);
}

.dot-off {
  background: var(--off);
}

.shell {
  display: flex;
  gap: 2rem;
  max-width: 64rem;
  margin: 0 auto;
  padding: 2rem 1.5rem 3rem;
}

.shell-wide {
  max-width: 78rem;
}

.content {
  flex: 1;
  min-width: 0;
}

.footer {
  border-top: 1px solid var(--border);
  padding: 1.25rem 1.5rem;
  color: var(--muted);
  font-size: 0.85rem;
  text-align: center;
}

/* -- sidebar --------------------------------------------------------------- */

.sidebar {
  width: 15rem;
  flex-shrink: 0;
}

.side-guild {
  display: flex;
  gap: 0.7rem;
  align-items: center;
  padding: 0.85rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 1rem;
}

.side-guild img,
.guild-initials {
  border-radius: 12px;
  flex-shrink: 0;
}

.guild-initials {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  background: var(--surface-2);
  font-weight: 650;
  font-size: 0.85rem;
}

.side-guild strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.guild-meta {
  color: var(--muted);
  font-size: 0.82rem;
}

.side-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.side-link {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.7rem;
  border-radius: 9px;
  color: var(--muted);
  font-weight: 500;
}

.side-link:hover {
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
}

.side-link.is-active {
  background: var(--accent);
  color: var(--accent-text);
}

.side-link.is-off {
  opacity: 0.6;
}

.side-back {
  display: inline-block;
  margin-top: 1rem;
  color: var(--muted);
  font-size: 0.9rem;
}

/* -- buttons --------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.55rem 1rem;
  border: 1px solid transparent;
  border-radius: 9px;
  font: inherit;
  font-weight: 550;
  cursor: pointer;
  background: var(--surface-2);
  color: var(--text);
}

.btn:hover {
  text-decoration: none;
  filter: brightness(0.97);
}

.btn-primary {
  background: var(--accent);
  color: var(--accent-text);
}

.btn-ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text);
}

.btn-danger {
  background: var(--off);
  color: #fff;
}

.btn-sm {
  padding: 0.35rem 0.7rem;
  font-size: 0.87rem;
}

/* -- landing --------------------------------------------------------------- */

.hero {
  padding: 2rem 0 1rem;
}

.hero h1 {
  font-size: 2.1rem;
  max-width: 18ch;
}

.hero-actions {
  display: flex;
  gap: 0.7rem;
  flex-wrap: wrap;
  margin: 1.25rem 0;
}

.hero-stats {
  display: flex;
  gap: 2rem;
  list-style: none;
  padding: 0;
  margin: 1.5rem 0 0;
  color: var(--muted);
}

.hero-stats strong {
  display: block;
  font-size: 1.4rem;
  color: var(--text);
}

.error-code {
  font-size: 3rem;
  font-weight: 700;
  color: var(--muted);
  margin: 0;
}

.features {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
  gap: 1rem;
}

.feature {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem;
}

.feature p {
  color: var(--muted);
  font-size: 0.92rem;
}

.feature-emoji {
  font-size: 1.5rem;
  margin-bottom: 0.4rem;
}

.feature-meta {
  color: var(--muted);
  font-size: 0.82rem;
  margin: 0;
}

.how ol {
  color: var(--muted);
  padding-left: 1.2rem;
}

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

.guilds {
  list-style: none;
  padding: 0;
  margin: 1rem 0 0;
  display: grid;
  gap: 0.6rem;
}

.guild {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.8rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.guild img {
  border-radius: 14px;
}

.guild-initials {
  width: 48px;
  height: 48px;
}

.guild-body {
  flex: 1;
  min-width: 0;
}

.guild-body strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.guild-absent {
  opacity: 0.75;
}

/* -- modules --------------------------------------------------------------- */

.modules {
  list-style: none;
  padding: 0;
  margin: 1.25rem 0 0;
  display: grid;
  gap: 0.6rem;
}

.module {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.module.is-off {
  opacity: 0.62;
}

.module-head {
  display: flex;
  gap: 0.8rem;
}

.module-emoji {
  font-size: 1.4rem;
}

.module p {
  color: var(--muted);
  font-size: 0.92rem;
  margin: 0.15rem 0;
}

.module-meta {
  color: var(--muted);
  font-size: 0.8rem;
}

.toggle {
  width: 44px;
  height: 25px;
  border-radius: 999px;
  border: none;
  background: var(--surface-2);
  cursor: pointer;
  padding: 3px;
  display: flex;
  transition: background 0.15s ease;
}

.toggle span {
  width: 19px;
  height: 19px;
  border-radius: 50%;
  background: var(--muted);
  transition: transform 0.15s ease, background 0.15s ease;
}

.toggle.is-on {
  background: var(--accent);
}

.toggle.is-on span {
  background: #fff;
  transform: translateX(19px);
}

/* -- forms ----------------------------------------------------------------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin: 1.25rem 0;
  display: grid;
  gap: 1rem;
  box-shadow: var(--shadow);
}

.card h2 {
  margin: 0;
}

.card-danger {
  border-color: color-mix(in srgb, var(--off) 40%, var(--border));
}

.card label {
  display: grid;
  gap: 0.35rem;
}

.card label > span:first-child {
  font-weight: 550;
}

.card small {
  color: var(--muted);
}

input[type="text"],
input[type="number"],
select,
textarea {
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 0.5rem 0.65rem;
  width: 100%;
  max-width: 32rem;
}

textarea {
  resize: vertical;
}

select:disabled {
  opacity: 0.55;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
  gap: 1rem;
}

.log-row {
  display: grid;
  grid-template-columns: 11rem minmax(0, 22rem) auto auto;
  align-items: center;
  gap: 0.75rem;
}

.log-row > span:first-child {
  text-transform: capitalize;
}

.inline-form {
  display: inline-block;
  margin-top: 0.5rem;
}

.card button[type="submit"] {
  justify-self: start;
}

/* -- tables, stats, pills -------------------------------------------------- */

.table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin: 1rem 0;
  display: block;
  overflow-x: auto;
  white-space: nowrap;
}

.table th,
.table td {
  padding: 0.6rem 0.8rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.table th {
  color: var(--muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.table tr:last-child td {
  border-bottom: none;
}

.stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(8rem, 1fr));
  gap: 0.6rem;
  margin: 1.25rem 0;
}

.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.8rem 1rem;
  color: var(--muted);
  font-size: 0.82rem;
}

.stat span {
  display: block;
  font-size: 1.35rem;
  font-weight: 650;
  color: var(--text);
}

.pill {
  display: inline-block;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
  margin-left: 0.4rem;
}

.pill-ready,
.pill-unban,
.pill-untimeout {
  background: color-mix(in srgb, var(--ok) 18%, transparent);
  color: var(--ok);
}

.pill-dead,
.pill-ban,
.pill-kick {
  background: color-mix(in srgb, var(--off) 18%, transparent);
  color: var(--off);
}

.pill-warn,
.pill-timeout,
.pill-reconnecting,
.pill-spawning {
  background: color-mix(in srgb, var(--warn) 18%, transparent);
  color: var(--warn);
}

/* -- flash ----------------------------------------------------------------- */

.flash {
  padding: 0.7rem 1rem;
  border-radius: 9px;
  margin-bottom: 1rem;
  font-weight: 500;
}

.flash-ok {
  background: color-mix(in srgb, var(--ok) 15%, transparent);
  color: var(--ok);
}

.flash-error {
  background: color-mix(in srgb, var(--off) 15%, transparent);
  color: var(--off);
}

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

@media (max-width: 48rem) {
  .shell {
    flex-direction: column;
    padding: 1.25rem 1rem 2rem;
    gap: 1.25rem;
  }

  .sidebar {
    width: auto;
  }

  .side-nav {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .log-row {
    grid-template-columns: 1fr;
  }

  .hero h1 {
    font-size: 1.6rem;
  }
}
