:root {
  --bg: #08090b;
  --bg-2: #101114;
  --panel: #15161a;
  --panel-2: #1c1a16;
  --panel-3: #111d1d;
  --line: rgba(184, 215, 232, .16);
  --line-strong: rgba(184, 215, 232, .28);
  --text: #eef7fb;
  --muted: #a9a29a;
  --soft: #d4e0e7;
  --accent: #1689c7;
  --accent-2: #0b4164;
  --danger: #ff6b35;
  --success: #4cc38a;
  --shadow: 0 22px 70px rgba(0, 0, 0, .38);
  --radius: 8px;
  --sidebar-width: 315px;
  --shell-max: 1430px;
  --safe-x: max(0px, calc((100vw - var(--shell-max)) / 2));
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    linear-gradient(120deg, rgba(22, 137, 199, .12), transparent 32%),
    linear-gradient(260deg, rgba(7, 61, 95, .22), transparent 38%),
    linear-gradient(180deg, #0d0f13 0%, var(--bg) 44%, #090806 100%);
  color: var(--text);
}

a { color: inherit; }
.app-shell {
  min-height: 100vh;
  display: flex;
}

.sidebar {
  width: var(--sidebar-width);
  position: fixed;
  inset: 0 auto 0 var(--safe-x);
  background: rgba(14, 15, 18, .94);
  border-right: 1px solid var(--line);
  overflow-y: auto;
  padding: 22px 18px;
  z-index: 40;
  scrollbar-width: thin;
  scrollbar-color: rgba(22, 137, 199, .45) transparent;
}

.sidebar::-webkit-scrollbar { width: 8px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb {
  background: rgba(22, 137, 199, .36);
  border: 2px solid rgba(14, 15, 18, .94);
  border-radius: 999px;
}
.sidebar::-webkit-scrollbar-thumb:hover { background: rgba(22, 137, 199, .56); }

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 8px 22px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 16px;
}

.brand-logo {
  width: 44px;
  height: 44px;
  border-radius: var(--radius);
  display: block;
  object-fit: contain;
  background: rgba(255, 255, 255, .04);
  padding: 3px;
  box-shadow: 0 12px 32px rgba(22, 137, 199, .22);
}

.brand strong { display: block; font-size: 15px; }
.brand span { color: var(--muted); font-size: 12px; }
.nav-section { margin: 8px 0; }

.nav-title {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  color: #7c8c96;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .12em;
  margin: 0;
  padding: 9px 10px;
  font-family: inherit;
  cursor: pointer;
}

.nav-title:hover {
  color: var(--text);
  background: rgba(184, 215, 232, .05);
  border-color: var(--line);
}

.nav-title svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform .18s ease;
}

.nav-section.open .nav-title {
  color: #d8f2ff;
}

.nav-section.open .nav-title svg {
  transform: rotate(180deg);
}

.nav-items {
  display: none;
  padding: 3px 0 7px;
}

.nav-section.open .nav-items {
  display: block;
}

.nav-link {
  width: 100%;
  display: block;
  padding: 9px 11px 9px 18px;
  margin: 2px 0;
  border-radius: var(--radius);
  color: var(--soft);
  text-decoration: none;
  font-size: 14px;
  border: 1px solid transparent;
}

.nav-link:hover { background: rgba(184, 215, 232, .07); border-color: var(--line); }
.nav-link.active {
  background: linear-gradient(90deg, rgba(22, 137, 199, .18), rgba(7, 61, 95, .18));
  border-color: rgba(22, 137, 199, .40);
  color: #f3fbff;
}

.page {
  margin-left: calc(var(--safe-x) + var(--sidebar-width));
  width: calc(100% - var(--safe-x) - var(--safe-x) - var(--sidebar-width));
}

.topbar {
  height: 72px;
  position: sticky;
  top: 0;
  z-index: 30;
  padding: 14px 34px;
  background: rgba(8, 9, 11, .82);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--line);
}

.topbar-inner {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(0, 760px) 44px 220px;
  gap: 10px;
  justify-content: center;
  align-items: center;
}

.menu-button, .mobile-close { display: none; }
.search-wrap { position: relative; width: 100%; }

.search-wrap input {
  width: 100%;
  height: 44px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: rgba(20, 21, 25, .78);
  color: var(--text);
  outline: none;
  padding: 0 14px;
  font-size: 14px;
}

.search-wrap input:focus {
  border-color: rgba(22, 137, 199, .58);
  box-shadow: 0 0 0 4px rgba(22, 137, 199, .12);
}

.search-results {
  display: none;
  position: absolute;
  top: 52px;
  left: 0;
  right: 0;
  background: #15161a;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  max-height: 360px;
  overflow-y: auto;
}

.search-result { display: block; padding: 12px 14px; border-bottom: 1px solid var(--line); text-decoration: none; }
.search-result:hover { background: rgba(184, 215, 232, .07); }
.search-result strong { display: block; font-size: 14px; }
.search-result span { position: static; transform: none; font-size: 12px; color: var(--muted); }

.search-button {
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  display: inline-grid;
  place-items: center;
  padding: 0;
  border-radius: var(--radius);
  background: rgba(20, 21, 25, .78);
  color: #63c7ff;
  border: 1px solid var(--line);
  font-family: inherit;
  cursor: pointer;
}

.search-button:hover {
  background: rgba(22, 137, 199, .14);
  border-color: rgba(22, 137, 199, .36);
  color: #d8f2ff;
}

.search-button svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.content-layout {
  display: grid;
  grid-template-columns: minmax(0, 760px) 220px;
  gap: 44px;
  padding: 38px 34px 80px;
  justify-content: center;
}

.content { min-width: 0; }

.hero {
  border: 0;
  border-left: 3px solid var(--accent);
  border-radius: 0;
  background: transparent;
  padding: 4px 0 8px 18px;
  box-shadow: none;
  margin-bottom: 24px;
  position: relative;
  overflow: hidden;
}

.hero:after {
  display: none;
}

.eyebrow {
  color: var(--accent);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .16em;
  font-weight: 900;
}

h1 {
  font-size: clamp(25px, 2vw, 31px);
  line-height: 1.12;
  margin: 8px 0 8px;
  letter-spacing: 0;
}

h2 {
  margin: 36px 0 12px;
  font-size: 25px;
  letter-spacing: 0;
  border-top: 1px solid var(--line);
  padding-top: 28px;
}

h3 { margin: 24px 0 10px; font-size: 19px; color: #f3fbff; }
p, li { color: var(--soft); line-height: 1.72; font-size: 15.5px; }
.hero p {
  max-width: 760px;
  margin: 0;
  color: var(--muted);
}
ul, ol { padding-left: 22px; }
.content a:not(.card) { color: #63c7ff; }

.callout {
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent-2);
  background: rgba(7, 61, 95, .16);
  padding: 16px 18px;
  border-radius: var(--radius);
  margin: 18px 0;
  color: var(--soft);
}

.callout.warning { border-left-color: var(--accent); background: rgba(22, 137, 199, .10); }
.callout.success { border-left-color: var(--success); background: rgba(76, 195, 138, .08); }
.callout.danger { border-left-color: var(--danger); background: rgba(255, 107, 53, .10); }

.grid-list, .term-list, .command-list, .danger-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 18px 0;
}

.rule-card {
  background: rgba(21, 22, 26, .74);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin: 0;
}

.rule-card strong { color: #d8f2ff; }
.danger-list .rule-card { border-color: rgba(255, 107, 53, .28); background: rgba(255, 107, 53, .06); }
.command-list .rule-card strong { color: #8be3dc; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

.check-list {
  list-style: none;
  padding: 0;
  display: grid;
  gap: 10px;
}

.check-list li {
  position: relative;
  padding: 13px 14px 13px 42px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(21, 22, 26, .62);
}

.check-list li:before {
  content: "";
  position: absolute;
  left: 16px;
  top: 21px;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
}

.badge-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.badge {
  padding: 5px 8px;
  border-radius: var(--radius);
  background: rgba(184, 215, 232, .05);
  color: var(--soft);
  border: 1px solid var(--line);
  font-size: 11px;
  font-weight: 800;
}

.hero-actions { margin-top: 14px; }

.action-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 0 13px;
  border-radius: var(--radius);
  background: rgba(22, 137, 199, .14);
  border: 1px solid rgba(22, 137, 199, .40);
  color: #d8f2ff;
  text-decoration: none;
  font-size: 13px;
  font-weight: 800;
}

.action-button:hover {
  background: rgba(22, 137, 199, .22);
  border-color: rgba(22, 137, 199, .58);
}

.inline-action { margin-top: 4px; }

.role-ladder {
  display: grid;
  gap: 10px;
  margin: 18px 0;
}

.role-ladder .rule-card {
  border-left: 3px solid rgba(22, 137, 199, .62);
}

.reward-table {
  display: grid;
  gap: 10px;
  margin: 18px 0;
}

.reward-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px 18px;
  align-items: start;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(21, 22, 26, .68);
}

.reward-row strong {
  color: #d8f2ff;
}

.reward-row span {
  color: #63c7ff;
  font-weight: 900;
  white-space: nowrap;
}

.reward-row p {
  grid-column: 1 / -1;
  margin: 0;
  color: var(--muted);
}

.page-footer {
  margin-top: 44px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.page-footer a {
  text-decoration: none;
  color: var(--soft);
  border: 1px solid var(--line);
  padding: 12px 14px;
  border-radius: var(--radius);
  background: rgba(21, 22, 26, .62);
}

.toc {
  position: sticky;
  top: 100px;
  align-self: start;
  max-height: calc(100vh - 120px);
  overflow: auto;
  padding-left: 18px;
  border-left: 1px solid var(--line);
}

.toc-title {
  font-size: 12px;
  color: #7c8c96;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: .12em;
  margin-bottom: 12px;
}

.toc a { display: block; text-decoration: none; color: var(--muted); font-size: 13px; padding: 6px 0; }
.toc a:hover { color: var(--text); }
.copy-link { margin-left: 8px; opacity: 0; font-size: 13px; text-decoration: none; color: var(--accent); }
h2:hover .copy-link, h3:hover .copy-link { opacity: 1; }

@media (max-width: 1100px) {
  .content-layout { grid-template-columns: minmax(0, 860px); }
  .topbar-inner { grid-template-columns: minmax(0, 860px) 44px; }
  .toc { display: none; }
}

@media (max-width: 820px) {
  :root { --safe-x: 0px; }
  .sidebar { transform: translateX(-105%); transition: transform .2s ease; box-shadow: var(--shadow); }
  .sidebar.open { transform: translateX(0); }
  .page { margin-left: 0; width: 100%; }
  .topbar { padding: 12px 16px; }
  .topbar-inner {
    display: flex;
    justify-content: flex-start;
    gap: 12px;
  }
  .search-wrap { max-width: none; }
  .menu-button, .mobile-close {
    display: inline-flex;
    border: 1px solid var(--line);
    background: rgba(21, 22, 26, .85);
    color: var(--text);
    border-radius: var(--radius);
    padding: 10px 12px;
  }
  .mobile-close { width: 100%; justify-content: center; margin: 0 0 12px; }
  .content-layout { padding: 28px 18px 60px; }
  .hero { padding: 4px 0 8px 16px; }
  .grid-list, .term-list, .command-list, .danger-list { grid-template-columns: 1fr; }
  .reward-row { grid-template-columns: 1fr; }
}
