:root {
  --brand: #d94b45;
  --brand-soft: #fff2f0;
  --text: #333942;
  --muted: #748094;
  --line: #e8e6e4;
  --sidebar: #f7f8fa;
  --shadow: 0 12px 32px rgba(48, 37, 31, .08);
  --header-height: 72px;
  --left-width: clamp(300px, 20vw, 380px);
  --right-width: clamp(230px, 16vw, 310px);
  color: var(--text);
  background: #fff;
  font-family: "Microsoft YaHei", "PingFang SC", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; font-size: 16px; line-height: 1.75; }
button, input { font: inherit; }

.docs-header {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 30;
  height: var(--header-height);
  display: grid;
  grid-template-columns: var(--left-width) minmax(320px, 1fr) var(--right-width);
  align-items: center;
  gap: clamp(18px, 2vw, 36px);
  padding: 0 clamp(20px, 2.2vw, 42px);
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, .97);
  backdrop-filter: blur(16px);
}

.brand {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text);
  text-decoration: none;
}
.brand-mark {
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  display: block;
  object-fit: contain;
}
.brand strong, .brand small { display: block; }
.brand strong { font-size: 17px; font-weight: 550; }
.brand small { color: var(--muted); font-size: 12px; line-height: 1.3; }

.search-wrap {
  position: relative;
  width: min(720px, 100%);
  height: 44px;
  margin: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f8f7f6;
}
.search-wrap:focus-within {
  border-color: #efaaa6;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(217, 75, 69, .08);
}
.search-wrap > svg { width: 19px; fill: none; stroke: var(--muted); stroke-width: 2; }
.search-wrap input { min-width: 0; flex: 1; border: 0; outline: 0; background: transparent; color: var(--text); }
.search-key { padding: 1px 7px; border: 1px solid var(--line); border-radius: 6px; color: #9299a5; font-size: 12px; }
.search-results {
  position: absolute;
  top: 52px;
  left: 0;
  right: 0;
  max-height: 420px;
  overflow: auto;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  box-shadow: var(--shadow);
}
.search-item { display: block; padding: 11px 12px; border-radius: 9px; color: var(--text); text-decoration: none; }
.search-item:hover { background: var(--brand-soft); }
.search-item strong, .search-item small { display: block; }
.search-item small { color: var(--muted); }
.search-empty { padding: 18px; color: var(--muted); text-align: center; }

.workbench-link {
  justify-self: end;
  height: 42px;
  display: flex;
  align-items: center;
  padding: 0 16px;
  border: 1px solid #f2b7b4;
  border-radius: 12px;
  color: var(--brand);
  text-decoration: none;
  white-space: nowrap;
}
.workbench-link:hover { background: var(--brand-soft); }
.mobile-nav-button { display: none; width: 42px; height: 42px; border: 0; background: transparent; color: var(--text); }
.mobile-nav-button svg { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }

.docs-layout {
  width: 100%;
  min-height: 100vh;
  padding-top: var(--header-height);
  display: grid;
  grid-template-columns: var(--left-width) minmax(0, 1fr) var(--right-width);
}

.docs-sidebar {
  position: sticky;
  top: var(--header-height);
  height: calc(100vh - var(--header-height));
  height: calc(100dvh - var(--header-height));
  display: flex;
  flex-direction: column;
  padding: 22px clamp(24px, 2.5vw, 48px) 18px;
  border-right: 1px solid var(--line);
  background: var(--sidebar);
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #989898 transparent;
}
.docs-sidebar nav { flex: 1; }
.nav-group { padding: 14px 0 22px; border-bottom: 1px solid #dfdfdf; }
.nav-group:first-child { padding-top: 0; }
.nav-group:last-child { border-bottom: 0; }
.nav-group-toggle {
  width: 100%;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 5px 8px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  text-align: left;
}
.nav-group-toggle:hover { background: transparent; }
.nav-group-title {
  min-width: 0;
  overflow: hidden;
  color: var(--text);
  font-size: 18px;
  font-weight: 400;
  line-height: 1.5;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.nav-group:not(.collapsed) .nav-group-title { color: var(--brand); }
.nav-group-toggle svg {
  width: 20px;
  height: 20px;
  flex: 0 0 20px;
  fill: none;
  stroke: #858585;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform .18s ease;
}
.nav-group.collapsed .nav-group-toggle svg { transform: rotate(-90deg); }
.nav-group-links { padding: 2px 0 0; }
.nav-link {
  display: block;
  max-width: 100%;
  padding: 8px 8px;
  overflow: hidden;
  border-radius: 7px;
  color: #596275;
  font-size: 16px;
  line-height: 1.55;
  text-decoration: none;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.nav-link:hover { color: var(--brand); }
.nav-link.active { color: var(--brand); font-weight: 550; }
.nav-group-empty { padding: 8px; color: #a2a7af; font-size: 14px; }
.nav-loading { padding: 12px 8px; color: var(--muted); }
.sidebar-footer { padding: 22px 8px 0; color: #a1a7af; font-size: 12px; }

.docs-main { grid-column: 2; width: 100%; min-width: 0; padding: clamp(34px, 3.1vw, 62px) clamp(24px, 3vw, 56px) clamp(54px, 5vw, 88px); }
.docs-article { min-height: 65vh; }
.article-head { margin-bottom: 38px; padding-bottom: 28px; border-bottom: 1px solid var(--line); }
.article-category { color: var(--brand); font-size: 14px; font-weight: 550; }
.docs-article h1 { margin: 8px 0 12px; font-size: clamp(34px, 3vw, 46px); line-height: 1.25; letter-spacing: -1px; }
.article-summary { margin: 0; color: var(--muted); font-size: 17px; }
.docs-article h2 { margin: 50px 0 17px; font-size: 27px; line-height: 1.4; }
.docs-article h3 { margin: 34px 0 13px; font-size: 21px; }
.docs-article h4, .docs-article h5, .docs-article h6 { margin: 24px 0 10px; font-size: 18px; line-height: 1.4; }
.docs-article p { margin: 13px 0; color: #4f5969; }
.docs-article ul, .docs-article ol { padding-left: 25px; color: #4f5969; }
.docs-article li { margin: 7px 0; }
.docs-article li > input[type="checkbox"] { width: 16px; height: 16px; margin: 0 8px 0 -22px; vertical-align: -2px; accent-color: var(--brand); }
.docs-article del { color: #8a909b; }
.docs-article hr { height: 1px; margin: 30px 0; border: 0; background: var(--line); }
.docs-article blockquote { margin: 22px 0; padding: 14px 18px; border-left: 4px solid var(--brand); border-radius: 0 10px 10px 0; background: var(--brand-soft); color: #645e5d; }
.docs-article code { padding: 2px 6px; border-radius: 5px; background: #f3f1f0; color: #b73c37; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: .9em; }
.docs-article pre { padding: 20px; overflow: auto; border-radius: 12px; background: #292d36; color: #f5f5f5; }
.docs-article pre code { padding: 0; background: transparent; color: inherit; }
.docs-article a { color: var(--brand); text-underline-offset: 3px; }
.docs-article img { max-width: 100%; border-radius: 12px; }
.markdown-table-wrap { margin: 24px 0; overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; }
.markdown-table-wrap table { width: 100%; min-width: 560px; border-collapse: collapse; }
.markdown-table-wrap th, .markdown-table-wrap td { padding: 11px 13px; border-bottom: 1px solid var(--line); border-right: 1px solid var(--line); color: #4f5969; text-align: left; vertical-align: top; }
.markdown-table-wrap th { color: var(--text); font-weight: 550; background: #fafafa; }
.markdown-table-wrap tr:last-child td { border-bottom: 0; }
.markdown-table-wrap th:last-child, .markdown-table-wrap td:last-child { border-right: 0; }
.updated-at { margin-top: 50px; color: #9aa1ac; font-size: 13px; }
.article-loading { min-height: 420px; display: grid; place-content: center; color: var(--muted); text-align: center; }
.article-loading span { width: 34px; height: 34px; margin: auto; border: 3px solid #f2d1cf; border-top-color: var(--brand); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.article-error { padding: 70px 20px; text-align: center; }
.article-error h1 { font-size: 28px; }
.article-pager { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 45px; padding-top: 28px; border-top: 1px solid var(--line); }
.pager-link { padding: 16px 18px; border: 1px solid var(--line); border-radius: 12px; color: var(--text); text-decoration: none; }
.pager-link:hover { border-color: #edaaa6; background: var(--brand-soft); }
.pager-link.next { text-align: right; }
.pager-link small, .pager-link strong { display: block; }
.pager-link small { color: var(--muted); font-size: 12px; }

.docs-toc {
  position: sticky;
  top: var(--header-height);
  height: calc(100vh - var(--header-height));
  height: calc(100dvh - var(--header-height));
  padding: clamp(34px, 3vw, 58px) clamp(22px, 2vw, 40px);
  overflow-y: auto;
  border-left: 1px solid var(--line);
}
.toc-title { margin-bottom: 10px; overflow: hidden; color: #9097a2; font-size: 13px; font-weight: 550; text-overflow: ellipsis; white-space: nowrap; }
.toc-link { display: block; max-width: 100%; padding: 5px 0 5px 12px; overflow: hidden; border-left: 2px solid #eeeae8; color: #7b8492; font-size: 13px; line-height: 1.5; text-decoration: none; text-overflow: ellipsis; white-space: nowrap; }
.toc-link.level-3 { padding-left: 24px; }
.toc-link:hover, .toc-link.active { border-left-color: var(--brand); color: var(--brand); }
.sidebar-mask { display: none; }

html.is-embedded,
html.is-embedded body {
  min-height: 0;
  background: transparent;
}

html.is-embedded .docs-header {
  display: none;
}

html.is-embedded .docs-layout {
  min-height: 0;
  padding-top: 0;
}

html.is-embedded .docs-sidebar,
html.is-embedded .docs-toc {
  top: 0;
  height: auto;
  max-height: none;
}

html.is-embedded .docs-main {
  padding-top: clamp(24px, 2.5vw, 42px);
}

@media (max-width: 1180px) {
  :root { --left-width: clamp(280px, 25vw, 330px); }
  .docs-header { grid-template-columns: var(--left-width) minmax(280px, 1fr) auto; }
  .docs-layout { grid-template-columns: var(--left-width) minmax(0, 1fr); }
  .docs-toc { display: none; }
}

@media (max-width: 780px) {
  .docs-header { height: auto; min-height: 64px; display: flex; flex-wrap: wrap; gap: 10px; padding: 10px 14px; }
  .brand { flex: 1; }
  .brand-mark { width: 38px; height: 38px; flex-basis: 38px; }
  .mobile-nav-button { display: block; order: -1; }
  .search-wrap { order: 3; width: 100%; height: 42px; }
  .search-key, .workbench-link { display: none; }
  .docs-layout { display: block; padding-top: 116px; }
  .docs-sidebar { position: fixed; top: 116px; left: 0; z-index: 25; width: min(88vw, 340px); height: calc(100vh - 116px); height: calc(100dvh - 116px); padding: 24px 26px; transform: translateX(-105%); transition: transform .2s ease; box-shadow: var(--shadow); }
  .docs-sidebar.open { transform: translateX(0); }
  .sidebar-mask { position: fixed; inset: 116px 0 0; z-index: 20; background: rgba(30, 28, 27, .28); }
  .sidebar-mask.show { display: block; }
  .docs-main { padding: 28px clamp(16px, 4.5vw, 24px) 50px; }
  .docs-article h1 { font-size: clamp(28px, 8vw, 34px); }
  .docs-article h2 { margin-top: 40px; font-size: 24px; }
  .article-pager { grid-template-columns: 1fr; }
}

@media (max-width: 780px) {
  html.is-embedded .docs-layout {
    padding-top: 0;
  }

  html.is-embedded .docs-sidebar {
    position: static;
    width: auto;
    height: auto;
    padding: 18px 20px;
    transform: none;
    box-shadow: none;
  }

  html.is-embedded .sidebar-mask {
    display: none;
  }
}
