:root {
  --bg: #0f1115;
  --bg-elev: #181b22;
  --bg-elev-2: #20242d;
  --border: #2a2f3a;
  --text: #e6e8ee;
  --text-dim: #9aa3b2;
  --accent: #5865f2;
  --accent-hover: #4752c4;
  --success: #2ecc71;
  --warn: #f1c40f;
  --danger: #e74c3c;
  --premium: #9b59b6;
  --pro: #f1c40f;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 4px 24px rgba(0,0,0,0.35);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.55;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

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

.container { max-width: 1100px; margin: 0 auto; padding: 0 20px; width: 100%; }
.site-main { flex: 1; padding: 32px 0 64px; }

/* Header */
.site-header {
  background: var(--bg-elev);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 12px;
  padding-bottom: 12px;
  gap: 16px;
  flex-wrap: wrap;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-weight: 700;
  font-size: 18px;
}
.brand:hover { text-decoration: none; }
.brand-mark { font-size: 22px; }
.site-nav {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
}
.site-nav a { color: var(--text-dim); font-weight: 500; }
.site-nav a:hover { color: var(--text); text-decoration: none; }
.site-nav a.active { color: var(--text); }
.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-elev-2);
  padding: 4px 10px 4px 4px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 14px;
}
.user-chip img { width: 24px; height: 24px; border-radius: 50%; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 9px 16px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease;
  font-family: inherit;
  text-decoration: none;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn-ghost:hover { background: var(--bg-elev-2); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #c0392b; }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-lg { padding: 12px 22px; font-size: 16px; }
.btn[disabled] { opacity: 0.6; cursor: not-allowed; }

/* Hero */
.hero {
  padding: 56px 0 40px;
  text-align: center;
}
.hero-inner h1 {
  font-size: clamp(28px, 4.6vw, 48px);
  line-height: 1.15;
  margin: 0 0 16px;
  font-weight: 800;
  letter-spacing: -0.02em;
}
.hero-inner h1 em {
  color: var(--accent);
  font-style: normal;
}
.lede {
  color: var(--text-dim);
  font-size: 18px;
  max-width: 680px;
  margin: 0 auto 28px;
}
.hero-cta {
  display: inline-flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
}

/* Feature grid */
.features { padding: 32px 0; }
.feature-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}
.feature {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.feature h3 { margin: 0 0 8px; font-size: 17px; }
.feature p { margin: 0; color: var(--text-dim); font-size: 14px; }

/* CTA band */
.cta-band {
  margin-top: 48px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 36px;
  text-align: center;
}
.cta-band h2 { margin: 0 0 8px; font-size: 26px; }
.cta-band p { color: var(--text-dim); margin: 0 0 20px; }

/* Cards */
.card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 16px;
}
.card h2 { margin-top: 0; }
.card.narrow { max-width: 560px; margin-left: auto; margin-right: auto; text-align: center; }

/* Footer */
.site-footer {
  background: var(--bg-elev);
  border-top: 1px solid var(--border);
  padding: 18px 0;
  color: var(--text-dim);
  font-size: 13px;
}
.footer-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.footer-links { display: inline-flex; gap: 18px; }
.footer-links a { color: var(--text-dim); }
.footer-links a:hover { color: var(--text); }

/* Long-form pages (TOS, Privacy) */
.legal {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  max-width: 820px;
  margin: 0 auto;
}
.legal h1 { margin-top: 0; }
.legal h2 { margin-top: 32px; font-size: 20px; }
.legal p, .legal li { color: var(--text); }
.legal .meta { color: var(--text-dim); font-size: 14px; margin-bottom: 24px; }

/* Dashboard guild cards */
.guild-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}
.guild-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text);
  text-decoration: none;
  transition: border-color 120ms ease, transform 120ms ease;
}
.guild-card:hover {
  border-color: var(--accent);
  text-decoration: none;
  transform: translateY(-1px);
}
.guild-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: var(--bg-elev-2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  flex-shrink: 0;
  overflow: hidden;
}
.guild-icon img { width: 100%; height: 100%; object-fit: cover; }
.guild-meta { flex: 1; min-width: 0; }
.guild-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.guild-status { color: var(--text-dim); font-size: 13px; }
.guild-status.in-server { color: var(--success); }

/* Forms */
form fieldset {
  border: none;
  padding: 0;
  margin: 0 0 24px;
}
.form-row { margin-bottom: 18px; }
.form-row label {
  display: block;
  font-weight: 600;
  margin-bottom: 6px;
  font-size: 14px;
}
.form-row .hint {
  color: var(--text-dim);
  font-size: 13px;
  margin-top: 4px;
}
input[type="text"], input[type="number"], select, textarea {
  width: 100%;
  background: var(--bg-elev-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
}
textarea { min-height: 80px; resize: vertical; }
.checkbox-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.checkbox-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

/* Tier badges */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  border: 1px solid var(--border);
}
.badge-free { color: var(--text-dim); }
.badge-pro { color: var(--pro); border-color: var(--pro); }
.badge-premium { color: var(--premium); border-color: var(--premium); }

/* Flash banners */
.flash {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  border: 1px solid var(--border);
  background: var(--bg-elev);
}
.flash.success { border-color: var(--success); }
.flash.error { border-color: var(--danger); }

/* Section heading row */
.page-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 20px;
}
.page-head h1 { margin: 0; font-size: 26px; }
.page-head .sub { color: var(--text-dim); font-size: 14px; }

/* Rules list */
.rules-list { list-style: none; padding: 0; margin: 0; }
.rules-list li {
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin-bottom: 8px;
  display: flex;
  flex-direction: column;
}
.rules-list .rule-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}
.rules-list .rule-body { flex: 1; }
.rules-list .rule-title { font-weight: 600; }
.rules-list .rule-desc { color: var(--text-dim); font-size: 14px; margin-top: 4px; }
.rules-list .rule-edit { margin-top: 10px; }
.rules-list .rule-edit > summary {
  cursor: pointer;
  color: var(--text-dim);
  font-size: 13px;
  list-style: none;
  user-select: none;
}
.rules-list .rule-edit > summary::-webkit-details-marker { display: none; }
.rules-list .rule-edit > summary:hover { color: var(--text); }
.rules-list .rule-edit[open] > summary { margin-bottom: 10px; }
.rules-list .rule-edit-form {
  border-top: 1px solid var(--border);
  padding-top: 12px;
}

/* ===== Docs ===== */
.docs-layout {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  gap: 36px;
  align-items: start;
  margin: 24px 0 48px;
}
.docs-sidebar {
  position: sticky;
  top: 20px;
  align-self: start;
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  padding: 8px 4px;
  border-right: 1px solid var(--border);
}
.docs-sidebar nav { padding-right: 12px; }
.docs-group { margin-bottom: 18px; }
.docs-group-title {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin: 0 0 6px 8px;
}
.docs-group ul {
  list-style: none;
  padding: 0;
  margin: 0;
}
.docs-group li { margin: 0; }
.docs-group a {
  display: block;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  text-decoration: none;
  font-size: 14.5px;
  line-height: 1.35;
}
.docs-group a:hover {
  color: var(--text);
  background: var(--bg-elev);
}
.docs-group a.active {
  color: var(--text);
  background: var(--bg-elev-2);
  font-weight: 600;
}
.docs-content {
  min-width: 0;
  max-width: 820px;
}
.docs-title {
  margin: 0 0 24px;
  font-size: 36px;
  line-height: 1.15;
  letter-spacing: -0.01em;
}
.docs-body {
  font-size: 16px;
  line-height: 1.7;
  color: var(--text);
}
.docs-body h1, .docs-body h2, .docs-body h3, .docs-body h4 {
  position: relative;
  margin: 1.6em 0 0.6em;
  line-height: 1.25;
  scroll-margin-top: 80px;
}
.docs-body h2 {
  font-size: 24px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}
.docs-body h3 { font-size: 19px; }
.docs-body h4 { font-size: 16px; color: var(--text-dim); }
.docs-body .anchor {
  position: absolute;
  left: -1.1em;
  color: var(--text-dim);
  opacity: 0;
  text-decoration: none;
  font-weight: 400;
  padding-right: 0.3em;
  transition: opacity 0.15s ease;
}
.docs-body h1:hover .anchor,
.docs-body h2:hover .anchor,
.docs-body h3:hover .anchor,
.docs-body h4:hover .anchor { opacity: 1; }
.docs-body p { margin: 0.9em 0; }
.docs-body a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid transparent;
}
.docs-body a:hover {
  border-bottom-color: var(--accent);
}
.docs-body ul, .docs-body ol {
  margin: 0.9em 0;
  padding-left: 1.5em;
}
.docs-body li { margin: 0.25em 0; }
.docs-body code {
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 0.9em;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Consolas, "Liberation Mono", monospace;
}
.docs-body pre {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  overflow-x: auto;
  font-size: 14px;
  line-height: 1.55;
  margin: 1em 0;
}
.docs-body pre code {
  background: none;
  border: 0;
  padding: 0;
  font-size: inherit;
}
.docs-body blockquote {
  margin: 1.2em 0;
  padding: 4px 16px;
  border-left: 3px solid var(--accent);
  background: var(--bg-elev);
  color: var(--text-dim);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.docs-body blockquote p { margin: 0.6em 0; }
.docs-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.2em 0;
  font-size: 14.5px;
}
.docs-body th, .docs-body td {
  text-align: left;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
}
.docs-body th {
  background: var(--bg-elev);
  font-weight: 600;
}
.docs-body hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 2em 0;
}

@media (max-width: 820px) {
  .docs-layout {
    grid-template-columns: 1fr;
    gap: 16px;
  }
  .docs-sidebar {
    position: static;
    max-height: none;
    border-right: 0;
    border-bottom: 1px solid var(--border);
    padding-bottom: 12px;
  }
  .docs-title { font-size: 28px; }
  .docs-body .anchor { display: none; }
}
