:root {
  --main: #edb41e;
  --main-soft: rgba(237, 180, 30, 0.14);
  --bg: #0e0b16;
  --bg2: #18131f;
  --bg3: #241d30;
  --border: #2f2643;
  --text: #ffffff;
  --muted: #a69dbd;
  --focus: #f7dc4b;
  --cold: #7bdefd;
  --top-h: 64px;
}
* { box-sizing: border-box; }
html { scroll-padding-top: calc(var(--top-h) + 16px); }
body {
  margin: 0;
  font-family: Montserrat, system-ui, sans-serif;
  color: var(--text);
  background: var(--bg) url("bg.webp") center top / cover fixed;
  line-height: 1.65;
}
body::before { content: ""; position: fixed; inset: 0; background: rgba(14, 11, 22, 0.82); z-index: -1; }
a { color: var(--cold); }

/* top bar */
.topbar {
  position: sticky; top: 0; z-index: 20; height: var(--top-h);
  display: flex; align-items: center; gap: 18px; padding: 0 20px;
  background: rgba(17, 13, 24, 0.92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); font-weight: 800; }
.brand img { height: 40px; width: auto; }
.brand span { color: var(--main); font-size: 18px; letter-spacing: 0.5px; }
.site-nav { display: flex; gap: 4px; padding: 4px; border-radius: 40px; background: rgba(255, 255, 255, 0.08); }
.site-nav a {
  text-decoration: none; color: rgba(255, 255, 255, 0.6); font-weight: 700; font-size: 14px;
  padding: 7px 16px; border-radius: 40px; transition: all 0.2s ease-out;
}
.site-nav a:hover { color: #fff; background: rgba(255, 255, 255, 0.1); }
.site-nav a.is-active { color: #1b1405; background: var(--main); }
.search { position: relative; margin-left: auto; width: min(340px, 40vw); }
.search input {
  width: 100%; padding: 9px 14px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--bg2); color: var(--text); font: inherit; font-size: 14px; outline: none;
}
.search input:focus { border-color: var(--main); }
.results {
  position: absolute; top: calc(100% + 6px); right: 0; width: min(440px, 92vw); max-height: 70vh; overflow: auto;
  background: var(--bg2); border: 1px solid var(--border); border-radius: 12px; padding: 6px; box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
}
.results a { display: block; padding: 9px 12px; border-radius: 8px; text-decoration: none; color: var(--text); }
.results a:hover, .results a.sel { background: var(--bg3); }
.results small { display: block; color: var(--muted); font-size: 12px; }
.results mark { background: var(--main-soft); color: var(--focus); border-radius: 3px; }
.results .empty { padding: 10px 12px; color: var(--muted); font-size: 14px; }
.menu-btn { display: none; background: none; border: 0; color: var(--text); font-size: 24px; cursor: pointer; }

/* layout */
.layout { display: grid; grid-template-columns: 260px minmax(0, 1fr) 220px; gap: 32px; max-width: 1400px; margin: 0 auto; padding: 0 20px; }
.sidebar {
  position: sticky; top: var(--top-h); height: calc(100vh - var(--top-h)); overflow-y: auto; padding: 24px 6px 40px 0;
}
.nav-section { margin-bottom: 18px; }
.nav-title { margin: 0 0 6px; font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: 1px; color: var(--main); }
.sidebar ul { list-style: none; margin: 0; padding: 0; }
.sidebar li a {
  display: block; padding: 6px 12px; border-radius: 8px; text-decoration: none; color: var(--muted); font-size: 14px; font-weight: 500;
  border-left: 2px solid transparent;
}
.sidebar li a:hover { color: var(--text); background: rgba(255, 255, 255, 0.04); }
.sidebar li a.active { color: var(--text); background: var(--main-soft); border-left-color: var(--main); font-weight: 700; }

.content { min-width: 0; padding: 28px 0 40px; }
.crumb { margin: 0 0 4px; font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: 1px; color: var(--main); }
article {
  background: rgba(24, 19, 31, 0.88); border: 1px solid var(--border); border-radius: 14px; padding: 28px 34px 34px;
}
article h1 { margin: 0 0 18px; font-size: 32px; font-weight: 800; line-height: 1.2; }
article h2 { margin: 34px 0 12px; font-size: 23px; font-weight: 800; color: var(--focus); padding-bottom: 6px; border-bottom: 1px solid var(--border); }
article h3 { margin: 24px 0 8px; font-size: 18px; font-weight: 700; color: var(--cold); }
article h4 { margin: 18px 0 6px; font-size: 16px; }
article h1 .anchor { display: none; }
.anchor { color: var(--border); text-decoration: none; margin-right: 8px; font-weight: 400; opacity: 0; transition: opacity 0.15s; }
h2:hover .anchor, h3:hover .anchor, h4:hover .anchor { opacity: 1; }
article p, article li { color: #e7e2f3; }
article strong { color: #fff; }
article ul, article ol { padding-left: 22px; }
article li { margin: 3px 0; }
article code {
  font-family: ui-monospace, Consolas, monospace; font-size: 0.88em; background: var(--bg3); color: var(--focus);
  padding: 2px 6px; border-radius: 5px; border: 1px solid var(--border);
}
article pre { background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 14px; overflow-x: auto; }
article pre code { background: none; border: 0; padding: 0; color: #e7e2f3; }
article blockquote {
  margin: 16px 0; padding: 10px 16px; border-left: 3px solid var(--main); background: var(--main-soft); border-radius: 0 10px 10px 0;
}
article blockquote p { margin: 4px 0; }
.table-wrap { overflow-x: auto; margin: 14px 0; border: 1px solid var(--border); border-radius: 10px; }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; }
th { background: var(--bg3); color: var(--focus); font-weight: 700; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
tbody tr:nth-child(even) td { background: rgba(255, 255, 255, 0.02); }
article img { max-width: 100%; border-radius: 10px; }
hr { border: 0; border-top: 1px solid var(--border); margin: 28px 0; }

.pager { display: flex; justify-content: space-between; gap: 14px; margin-top: 20px; }
.pager a {
  flex: 1; max-width: 48%; padding: 12px 16px; border: 1px solid var(--border); border-radius: 12px; background: rgba(24, 19, 31, 0.88);
  text-decoration: none; color: var(--text); font-weight: 700;
}
.pager a:hover { border-color: var(--main); }
.pager span { display: block; font-size: 12px; color: var(--muted); font-weight: 600; }
.pager .next { text-align: right; margin-left: auto; }
.foot { margin-top: 28px; font-size: 12px; color: var(--muted); text-align: center; }

.toc { position: sticky; top: var(--top-h); align-self: start; padding: 28px 0; max-height: calc(100vh - var(--top-h)); overflow-y: auto; }
.toc-title { margin: 0 0 8px; font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); }
.toc ul { list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--border); }
.toc li a { display: block; padding: 3px 12px; font-size: 13px; color: var(--muted); text-decoration: none; }
.toc li.lvl3 a { padding-left: 24px; font-size: 12px; }
.toc li a:hover, .toc li a.on { color: var(--focus); }

@media (max-width: 1180px) {
  .layout { grid-template-columns: 240px minmax(0, 1fr); }
  .toc { display: none; }
}
@media (max-width: 820px) {
  .layout { grid-template-columns: minmax(0, 1fr); padding: 0 16px; }
  .menu-btn { display: block; }
  .brand span, .site-nav { display: none; }
  .search { width: auto; flex: 1; }
  .sidebar {
    position: fixed; top: var(--top-h); left: 0; width: 280px; z-index: 30; background: var(--bg2);
    border-right: 1px solid var(--border); padding: 16px; transform: translateX(-100%); transition: transform 0.2s;
  }
  .sidebar.open { transform: none; }
  article { padding: 20px 18px 24px; }
  article h1 { font-size: 26px; }
  .pager { flex-direction: column; }
  .pager a { max-width: none; }
}
.mobile-nav { display: none; gap: 6px; margin-bottom: 18px; }
.mobile-nav a { flex: 1; text-align: center; padding: 8px; border-radius: 10px; text-decoration: none; font-weight: 700; color: var(--muted); background: rgba(255, 255, 255, 0.06); }
.mobile-nav a.is-active { color: #1b1405; background: var(--main); }
@media (max-width: 820px) { .mobile-nav { display: flex; } }
