:root {
  color-scheme: dark;
  --bg: #07090d;
  --bg-soft: #101010;
  --panel: rgba(12, 12, 12, 0.78);
  --panel-strong: rgba(18, 18, 18, 0.92);
  --glass: rgba(255, 255, 255, 0.06);
  --glass-border: rgba(255, 255, 255, 0.12);
  --text: #ffffff;
  --muted: #b8b8b8;
  --subtle: #747474;
  --line: rgba(255, 255, 255, 0.1);
  --accent: #e50914;
  --accent-2: #ffffff;
  --danger: #ff2d2d;
  --warning: #ff4a4a;
  --success: #ffffff;
  --shadow: 0 22px 70px rgba(0, 0, 0, 0.42);
  --sidebar: 292px;
  --topbar: 72px;
  --radius: 8px;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Consolas, monospace;
  --sans: "Inter", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --server-banner: url("assets/nooverlay.png");
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  font-family: var(--sans);
  background:
    linear-gradient(180deg, rgba(0, 0, 0, 0.62) 0%, rgba(0, 0, 0, 0.9) 42%, #050505 100%),
    radial-gradient(circle at 24% -10%, rgba(229, 9, 20, 0.2), transparent 34rem),
    radial-gradient(circle at 90% 8%, rgba(255, 255, 255, 0.08), transparent 32rem),
    var(--server-banner) center top / cover fixed no-repeat,
    linear-gradient(145deg, #030303 0%, #111111 46%, #050505 100%);
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  content: "";
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.8), transparent 78%);
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.site-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 50;
  width: var(--sidebar);
  padding: 20px 16px;
  overflow-y: auto;
  background: rgba(5, 5, 5, 0.82);
  border-right: 1px solid var(--line);
  backdrop-filter: blur(24px);
  box-shadow: var(--shadow);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 48px;
  margin-bottom: 18px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  overflow: hidden;
  background: #050505;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: var(--radius);
  box-shadow: 0 12px 36px rgba(229, 9, 20, 0.26);
}

.brand-mark img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.sidebar-brand strong,
.topbar-title {
  display: block;
  font-size: 15px;
  font-weight: 760;
}

.sidebar-brand span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.sidebar-search,
.search-trigger,
.search-input-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
}

.sidebar-search {
  position: sticky;
  top: 0;
  z-index: 2;
  height: 42px;
  margin-bottom: 14px;
  padding: 0 12px;
  backdrop-filter: blur(18px);
}

.sidebar-search span,
.search-input-row span {
  color: var(--muted);
}

.sidebar-search input,
.search-input-row input {
  width: 100%;
  min-width: 0;
  color: var(--text);
  background: transparent;
  border: 0;
  outline: 0;
}

.sidebar-search input::placeholder,
.search-input-row input::placeholder {
  color: var(--subtle);
}

.nav-section {
  margin: 20px 0;
}

.nav-section summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 8px;
  color: var(--subtle);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  list-style: none;
  border-radius: var(--radius);
}

.nav-section summary::-webkit-details-marker {
  display: none;
}

.nav-section summary::after {
  content: "⌄";
  color: var(--muted);
  transition: transform 180ms ease;
}

.nav-section:not([open]) summary::after {
  transform: rotate(-90deg);
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 38px;
  margin: 2px 0;
  padding: 8px 10px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.25;
  border: 1px solid transparent;
  border-radius: var(--radius);
  transition: background 160ms ease, color 160ms ease, transform 160ms ease, border-color 160ms ease;
}

.nav-link:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.055);
  border-color: rgba(255, 255, 255, 0.08);
  transform: translateX(2px);
}

.nav-link.active {
  color: #ffffff;
  font-weight: 700;
  background: linear-gradient(135deg, rgba(229, 9, 20, 0.98), rgba(95, 0, 8, 0.98));
  box-shadow: 0 12px 32px rgba(229, 9, 20, 0.22);
}

.nav-icon {
  width: 20px;
  text-align: center;
  filter: grayscale(1) contrast(1.25);
}

.main-frame {
  width: calc(100% - var(--sidebar));
  min-width: 0;
  margin-left: var(--sidebar);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 35;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--topbar);
  padding: 0 clamp(18px, 4vw, 44px);
  background: rgba(5, 5, 5, 0.78);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(22px);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.search-trigger {
  height: 38px;
  padding: 0 8px 0 13px;
  color: var(--muted);
  transition: color 160ms ease, border-color 160ms ease, background 160ms ease;
}

.search-trigger:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.085);
  border-color: rgba(255, 255, 255, 0.18);
}

kbd {
  min-width: 24px;
  padding: 3px 6px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-bottom-color: rgba(255, 255, 255, 0.22);
  border-radius: 5px;
}

.quick-link {
  display: inline-flex;
  align-items: center;
  height: 38px;
  padding: 0 14px;
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.075);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  transition: transform 160ms ease, background 160ms ease;
}

.quick-link:hover {
  background: rgba(255, 255, 255, 0.12);
  transform: translateY(-1px);
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
}

.mobile-menu {
  display: none;
}

.mobile-menu span {
  display: block;
  width: 16px;
  height: 2px;
  margin: 2px 0;
  background: currentColor;
  border-radius: 3px;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 880px) 238px;
  gap: 28px;
  width: 100%;
  max-width: 1240px;
  margin: 0 auto;
  padding: 42px clamp(18px, 4vw, 44px) 80px;
}

.doc-card {
  position: relative;
  min-width: 0;
  background: var(--panel);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(22px);
}

.doc-progress {
  position: sticky;
  top: var(--topbar);
  z-index: 5;
  height: 3px;
  width: 0;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  border-radius: var(--radius) var(--radius) 0 0;
}

.page-transition {
  padding: clamp(26px, 5vw, 58px);
  animation: page-in 240ms ease both;
}

@keyframes page-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.markdown-body {
  color: #e8e8e8;
  font-size: 16px;
  line-height: 1.8;
}

.markdown-body > *:first-child {
  margin-top: 0;
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4 {
  color: var(--text);
  line-height: 1.22;
}

.markdown-body h1 {
  margin: 0 0 18px;
  font-size: clamp(34px, 5vw, 56px);
  letter-spacing: 0;
}

.markdown-body h2 {
  margin: 44px 0 14px;
  padding-top: 10px;
  font-size: 27px;
}

.markdown-body h3 {
  margin: 30px 0 10px;
  font-size: 20px;
}

.markdown-body p {
  margin: 14px 0;
}

.markdown-body a {
  color: var(--accent);
  font-weight: 650;
  border-bottom: 1px solid rgba(229, 9, 20, 0.38);
}

.markdown-body ul,
.markdown-body ol {
  margin: 14px 0;
  padding-left: 1.45rem;
}

.markdown-body li {
  margin: 7px 0;
}

.markdown-body blockquote,
.markdown-alert {
  margin: 22px 0;
  padding: 16px 18px;
  color: #f4f4f4;
  background: rgba(229, 9, 20, 0.08);
  border: 1px solid rgba(229, 9, 20, 0.24);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
}

.markdown-alert.warning {
  background: rgba(255, 74, 74, 0.08);
  border-color: rgba(255, 74, 74, 0.24);
  border-left-color: var(--warning);
}

.markdown-alert.danger {
  background: rgba(255, 45, 45, 0.08);
  border-color: rgba(255, 45, 45, 0.24);
  border-left-color: var(--danger);
}

.markdown-alert.success {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.2);
  border-left-color: var(--success);
}

.markdown-body code {
  padding: 0.18rem 0.38rem;
  color: #ffffff;
  font-family: var(--mono);
  font-size: 0.88em;
  background: rgba(229, 9, 20, 0.14);
  border: 1px solid rgba(229, 9, 20, 0.26);
  border-radius: 5px;
}

.markdown-body pre {
  position: relative;
  margin: 24px 0;
  padding: 18px;
  overflow-x: auto;
  background: rgba(2, 6, 12, 0.76);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius);
}

.markdown-body pre code {
  padding: 0;
  color: #ffffff;
  background: transparent;
  border: 0;
}

.markdown-body table {
  display: block;
  width: 100%;
  margin: 24px 0;
  overflow-x: auto;
  border-collapse: collapse;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.markdown-body th,
.markdown-body td {
  padding: 13px 15px;
  text-align: left;
  border-bottom: 1px solid var(--line);
}

.markdown-body th {
  color: var(--text);
  font-size: 13px;
  background: rgba(255, 255, 255, 0.06);
}

.markdown-body tr:last-child td {
  border-bottom: 0;
}

.markdown-body hr {
  margin: 34px 0;
  border: 0;
  border-top: 1px solid var(--line);
}

.doc-footer {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 52px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
}

.pager-link {
  display: block;
  padding: 16px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  transition: transform 160ms ease, background 160ms ease, border-color 160ms ease;
}

.pager-link:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.075);
  border-color: rgba(255, 255, 255, 0.18);
  transform: translateY(-2px);
}

.pager-link.next {
  text-align: right;
}

.pager-link small {
  display: block;
  margin-bottom: 4px;
  color: var(--subtle);
  font-size: 12px;
}

.toc-panel {
  position: sticky;
  top: calc(var(--topbar) + 28px);
  align-self: start;
}

.toc-card {
  padding: 18px;
  background: rgba(18, 24, 34, 0.54);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  backdrop-filter: blur(18px);
}

.toc-card strong {
  display: block;
  margin-bottom: 12px;
  font-size: 13px;
}

.toc-card a {
  display: block;
  padding: 6px 0;
  color: var(--muted);
  font-size: 13px;
  border-left: 1px solid transparent;
}

.toc-card a:hover,
.toc-card a.active {
  color: var(--accent);
}

.search-modal[hidden] {
  display: none;
}

.search-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: start center;
  padding: 11vh 18px 30px;
}

.search-backdrop,
.sidebar-scrim {
  position: fixed;
  inset: 0;
  background: rgba(1, 4, 8, 0.68);
  backdrop-filter: blur(8px);
}

.search-box {
  position: relative;
  z-index: 1;
  width: min(720px, 100%);
  overflow: hidden;
  background: rgba(13, 18, 27, 0.94);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.search-input-row {
  height: 58px;
  padding: 0 10px 0 18px;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
}

.search-results {
  max-height: min(58vh, 540px);
  overflow-y: auto;
  padding: 10px;
}

.search-result {
  display: block;
  padding: 14px;
  border-radius: var(--radius);
}

.search-result:hover,
.search-result.active {
  background: rgba(255, 255, 255, 0.075);
}

.search-result strong {
  display: block;
  margin-bottom: 4px;
}

.search-result span {
  color: var(--muted);
  font-size: 13px;
}

.empty-state {
  padding: 26px;
  color: var(--muted);
  text-align: center;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 1120px) {
  .content-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .toc-panel {
    display: none;
  }
}

@media (max-width: 820px) {
  :root {
    --topbar: 64px;
  }

  .sidebar {
    transform: translateX(-104%);
    transition: transform 220ms ease;
  }

  body.sidebar-open .sidebar {
    transform: translateX(0);
  }

  body.sidebar-open .sidebar-scrim {
    display: block;
  }

  .main-frame {
    width: 100%;
    margin-left: 0;
  }

  .mobile-menu {
    display: inline-grid;
  }

  .topbar {
    padding: 0 14px;
  }

  .topbar-title {
    position: absolute;
    left: 58px;
  }

  .search-trigger span,
  .quick-link {
    display: none;
  }

  .content-grid {
    padding: 22px 12px 60px;
  }

  .page-transition {
    padding: 24px 18px;
  }

  .markdown-body {
    font-size: 15px;
  }

  .doc-footer {
    grid-template-columns: 1fr;
  }

  .pager-link.next {
    text-align: left;
  }
}

.discord-corner {
  position: fixed;
  right: 18px;
  bottom: 16px;
  z-index: 45;
  display: block;
  width: min(190px, calc(100vw - 36px));
  height: auto;
  overflow: hidden;
  opacity: 0.78;
  filter: drop-shadow(0 8px 18px rgba(229, 9, 20, 0.28));
  transition: opacity 160ms ease, transform 160ms ease, filter 160ms ease;
}

.discord-corner:hover {
  opacity: 1;
  transform: translateY(-2px);
  filter: drop-shadow(0 10px 24px rgba(229, 9, 20, 0.38));
}

.discord-corner img {
  display: block;
  width: 100%;
  height: auto;
}

@media (max-width: 820px) {
  .discord-corner {
    right: 12px;
    bottom: 12px;
    width: 150px;
    opacity: 0.72;
  }
}
