:root {
  --bg: #fff;
  --text: #252525;
  --muted: #707070;
  --line: #d5d5d5;
  --link: #b42318;
  --link-hover: #7f1d1d;
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  color: var(--text);
  background: var(--bg);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--bg); color: var(--text); }
button { font: inherit; }

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 270px minmax(0, 1fr) 220px;
  background: var(--bg);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
  padding: 32px 24px 48px;
  background: var(--bg);
}

.brand {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 2px 0 28px;
  background: var(--bg);
  color: #292929;
}
.brand a { display: block; }
.brand img { display: block; width: 214px; height: auto; }

.navigation, .nav-children { display: grid; gap: 3px; }
.nav-children { padding-left: 14px; }
.nav-group > summary {
  cursor: pointer;
  list-style: none;
  padding: 8px 8px;
  font-weight: 650;
}
.nav-group > summary::-webkit-details-marker { display: none; }
.nav-group > summary::before { content: "›"; display: inline-block; width: 15px; color: var(--muted); transition: transform .15s ease; }
.nav-group[open] > summary::before { transform: rotate(90deg); }
.nav-page {
  display: block;
  width: 100%;
  padding: 7px 8px 7px 23px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--muted);
  text-align: left;
  cursor: pointer;
}
.nav-page:hover, .nav-page.active { color: var(--text); background: #e5e5e5; }

.main { min-width: 0; padding: 58px clamp(28px, 6vw, 90px) 100px; background: var(--bg); }
.article { max-width: 980px; margin: 0 auto; font-size: 16px; line-height: 1.8; overflow-wrap: anywhere; }
.article h1 { font-size: 32px; margin: 0 0 34px; line-height: 1.3; }
.article h2 { margin-top: 42px; font-size: 25px; }
.article h3 { margin-top: 32px; font-size: 20px; }
.article h4 { font-size: 17px; }
.article p { margin: 12px 0; }
.article a { color: var(--link); font-weight: 650; text-decoration: underline; text-underline-offset: 3px; }
.article a:hover { color: var(--link-hover); }
.article img { display: block; max-width: 100%; height: auto; margin: 22px auto; }
.article pre { overflow: auto; padding: 18px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); }
.article code { padding: .15em .35em; border: 1px solid var(--line); border-radius: 3px; background: var(--bg); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.article pre code { padding: 0; border: 0; }
.article blockquote { margin: 20px 0; padding: 3px 0 3px 18px; border-left: 3px solid #999; color: #555; }
.article table { width: 100%; border-collapse: collapse; margin: 24px 0; background: var(--bg); }
.article th, .article td { padding: 10px 12px; border: 1px solid var(--line); background: var(--bg) !important; text-align: left; }
.article hr { border: 0; border-top: 1px solid var(--line); margin: 32px 0; }
.loading, .error { padding-top: 20vh; text-align: center; color: var(--muted); }

.toc {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
  padding: 72px 30px 40px 16px;
  background: var(--bg);
}
.toc-title { margin-bottom: 10px; font-size: 13px; color: var(--muted); }
.toc a { display: block; padding: 5px 0; color: var(--muted); text-decoration: none; font-size: 13px; line-height: 1.45; }
.toc a[data-level="3"] { padding-left: 12px; }
.toc a[data-level="4"] { padding-left: 24px; }
.toc a:hover { color: var(--text); }
.catalog-button, .overlay { display: none; }

@media (max-width: 960px) {
  .app-shell { display: block; }
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 20;
    width: min(84vw, 330px);
    height: 100dvh;
    transform: translateX(-105%);
    transition: transform .2s ease;
    box-shadow: 12px 0 30px rgb(0 0 0 / 12%);
  }
  .sidebar.open { transform: translateX(0); }
  .brand { position: static; }
  .main { padding: 76px 20px 72px; }
  .article { font-size: 15px; }
  .article h1 { font-size: 27px; }
  .toc { display: none; }
  .catalog-button {
    display: block;
    position: fixed;
    top: 18px;
    left: 18px;
    z-index: 15;
    padding: 9px 15px;
    border: 1px solid #bbb;
    border-radius: 999px;
    background: var(--bg);
    color: var(--text);
    cursor: pointer;
  }
  .overlay {
    position: fixed;
    inset: 0;
    z-index: 19;
    background: rgb(0 0 0 / 30%);
  }
  .overlay:not([hidden]) { display: block; }
}
