/* Markdown heading hierarchy */
.md-typeset h1 {
  color: #666;
  font-size: 2.2em;
  font-weight: 600;
  margin-bottom: 1.3em;
}

.md-typeset h2 {
  background: #f1f3fc;
  border-left: .22rem solid #4054c7;
  border-radius: .15rem;
  color: #4054c7;
  font-size: 1.5em;
  font-weight: 700;
  margin: 2em 0 1em;
  padding: .45em .7em;
}

.md-typeset h3 {
  border-bottom: 1px solid #dfe3f3;
  color: #4054c7;
  font-size: 1.2em;
  font-weight: 650;
  margin-top: 1.7em;
  padding-bottom: .35em;
}


/* Use the full desktop width for navigation, content, and table of contents. */
@media screen and (min-width: 76.25em) {
  .md-grid {
    max-width: none;
    margin-left: 0 !important;
    margin-right: 1rem !important;
  }

  .md-content__inner {
    max-width: none;
  }
}

/* Keep the document tree docked on tablets and narrow windows; on phones
   (below 45em) fall back to Material's slide-in drawer so the content keeps
   the full width. */
@media screen and (min-width: 45em) and (max-width: 76.234375em) {
  .md-header__button[for="__drawer"],
  .md-overlay {
    display: none;
  }

  .md-sidebar--primary {
    background: var(--md-default-bg-color);
    display: block !important;
    flex: 0 0 12.1rem;
    height: auto !important;
    position: sticky !important;
    top: 4.8rem !important;
    transform: none !important;
    width: 12.1rem;
    z-index: 1;
  }

  .md-sidebar--primary .md-sidebar__scrollwrap {
    height: calc(100vh - 4.8rem);
    overflow-y: auto;
    position: static;
  }

  /* Disable Material's mobile drill-down menu: keep all top-level folders visible. */
  .md-sidebar--primary .md-nav[data-md-level="1"] {
    display: block !important;
    opacity: 1 !important;
    pointer-events: auto !important;
    position: static !important;
    transform: none !important;
  }

  .md-sidebar--primary .md-nav[data-md-level="2"] {
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
    position: static !important;
    transform: none !important;
  }

  /* Compact navigation: a folder's file list is fully hidden while collapsed,
     so no blank space is left between folders. */
  .md-sidebar--primary .md-nav__item--nested > .md-nav {
    display: none !important;
  }

  .md-sidebar--primary .md-nav__toggle:checked ~ .md-nav {
    display: block !important;
  }

  .md-sidebar--primary .md-nav--primary > .md-nav__list > .md-nav__item > .md-nav {
    display: block !important;
  }

  .md-sidebar--primary .md-nav,
  .md-sidebar--primary .md-nav__list,
  .md-sidebar--primary .md-nav__item {
    height: auto !important;
    min-height: 0 !important;
  }

  .md-sidebar--primary .md-nav__title {
    display: none !important;
  }

}

/* On phones the directory is a slide-in drawer with its own drill-down
   navigation; hide the master toggle there. */
@media screen and (max-width: 44.984375em) {
  .md-nav-collapse-all {
    display: none;
  }
}


/* Folder-tree presentation for the docked primary navigation (>= 45em). */
@media screen and (min-width: 45em) {

.md-sidebar--primary .md-nav__list {
  border-left: 0;
  margin-left: 0;
  padding-left: 0;
}

.md-sidebar--primary .md-nav--primary > .md-nav__list > .md-nav__item > .md-nav > .md-nav__list {
  border-left: 0;
  margin-left: 0;
  padding-left: 0;
}

/* Draw a guide only below an expanded folder, aligned with its icon. */
.md-sidebar--primary .md-nav[data-md-level="2"] > .md-nav__list {
  border-left: 1px solid #dfe3f3;
  margin-left: 1rem;
  padding-left: 1rem;
}

.md-sidebar--primary .md-nav__link {
  font-size: .66rem;
  line-height: 1.2;
  min-height: 0;
  padding-bottom: .2rem;
  padding-top: .2rem;
}

.md-sidebar--primary .md-nav__link .md-ellipsis {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.md-sidebar--primary .md-nav__item--nested > .md-nav__link {
  align-items: center;
  background: #f0f1f8;
  border-radius: .38rem;
  color: #292b35;
  font-weight: 700;
  margin: .17rem 0;
  padding: .34rem .45rem .34rem 1.85rem;
  position: relative;
}

.md-sidebar--primary .md-nav__item--nested > .md-nav__link::before {
  content: "📁";
  font-size: .75rem;
  left: .5rem;
  line-height: 1;
  position: absolute;
  top: .39rem;
}

/* The top-level “文档” label is a tree root, not a folder card. */
.md-sidebar--primary .md-nav--primary > .md-nav__list > .md-nav__item--nested > .md-nav__link {
  background: transparent;
  margin: 0 0 .15rem;
}

.md-sidebar--primary .md-nav--primary > .md-nav__list > .md-nav__item--nested > .md-nav__link:hover {
  background: transparent;
}

/* The top bar already identifies this area as “文档”; hide the duplicate tree root. */
.md-sidebar--primary .md-nav--primary > .md-nav__list > .md-nav__item > .md-nav__link,
.md-sidebar--primary .md-nav--primary > .md-nav__list > .md-nav__item > .md-nav__title {
  display: none;
}

.md-sidebar--primary .md-nav--primary > .md-nav__list > .md-nav__item > .md-nav {
  display: block;
}

/* Reduce the left gutter before the document tree. */
.md-sidebar--primary .md-nav--primary {
  margin-left: 0 !important;
  position: relative;
}

.md-sidebar--primary .md-nav__item--nested > .md-nav__link .md-nav__icon {
  color: #31333d;
}

.md-sidebar--primary .md-nav__item--nested > .md-nav__link:hover {
  background: #e6e8f5;
}

.md-sidebar--primary .md-nav__item--active > .md-nav__link {
  color: #4054c7;
}

.md-sidebar--primary .md-nav__item--nested > .md-nav {
  margin-left: .4rem;
}

}

/* Master "collapse all / expand all" toggle above the document tree. */
.md-nav-collapse-all {
  padding: .15rem .45rem .4rem;
}

.md-nav-collapse-all button {
  width: 100%;
  border: 1px solid #dfe3f3;
  border-radius: .38rem;
  background: #f0f1f8;
  color: #4054c7;
  cursor: pointer;
  font-size: .66rem;
  font-weight: 700;
  line-height: 1.4;
  padding: .32rem .45rem;
}

.md-nav-collapse-all button:hover {
  background: #e6e8f5;
}

/* Hide sidebar scrollbars entirely; wheel/trackpad scrolling still works. */
.md-sidebar .md-sidebar__scrollwrap {
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.md-sidebar .md-sidebar__scrollwrap::-webkit-scrollbar {
  display: none;
}

/* In the narrow drawer mode, the nav list has its own scroll area; hide that
   scrollbar as well so the directory never shows duplicate scrollbars. */
.md-sidebar--primary .md-nav--primary .md-nav__list,
.md-sidebar--primary .md-nav--primary .md-nav__title ~ .md-nav__list {
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.md-sidebar--primary .md-nav--primary .md-nav__list::-webkit-scrollbar,
.md-sidebar--primary .md-nav--primary .md-nav__title ~ .md-nav__list::-webkit-scrollbar {
  display: none;
}

/* Content images are clickable to zoom. */
.md-content .md-typeset img {
  cursor: zoom-in;
}

.md-content .md-typeset a img {
  cursor: pointer;
}

.md-lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.78);
  cursor: zoom-out;
  animation: md-lightbox-fade 0.18s ease;
}

.md-lightbox img {
  width: auto !important;
  height: auto !important;
  max-width: 90vw;
  max-height: 84vh;
  border-radius: .25rem;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
  cursor: zoom-out;
}

.md-lightbox__caption {
  margin-top: .8rem;
  max-width: 80vw;
  color: rgba(255, 255, 255, 0.85);
  font-size: .8rem;
  text-align: center;
}

@keyframes md-lightbox-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Keep the native search dialog centered when it opens. */
@media screen and (min-width: 76.25em) {
  /* 首屏先隐藏 Material 的原始右侧位置，避免脚本定位前闪现。 */
  .md-header form[data-md-component="palette"].md-header__option {
    visibility: hidden;
  }

  /* 搜索框常驻时，Material 会收起所有 .md-header__option；
   * 主题开关也在其中，因此必须单独保留它的父容器。 */
  #__search:checked ~ .md-header form[data-md-component="palette"].md-header__option {
    display: flex !important;
    max-width: 3rem !important;
    opacity: 1 !important;
    overflow: visible;
    visibility: visible;
  }

  #__search ~ .md-header label.md-header__button[for="__search"] {
    display: none;
  }

  #__search ~ .md-header .md-search {
    display: block;
  }

  #__search ~ .md-header .md-search__inner {
    box-sizing: border-box;
    left: 50vw !important;
    margin: 0 !important;
    opacity: 1 !important;
    pointer-events: auto !important;
    position: fixed !important;
    right: auto !important;
    top: .35rem !important;
    transform: translateX(-50%) !important;
    transition: none !important;
    width: min(30rem, calc(100vw - 4rem)) !important;
    z-index: 20;
  }

  #__search ~ .md-header .md-search__overlay {
    display: none;
  }

  #__search ~ .md-header .md-search:not(.md-search--has-query) .md-search__output {
    display: none;
  }

  .md-sidebar--secondary {
    flex: 0 0 16rem;
    width: 16rem;
  }

  .md-sidebar--secondary .md-nav__link {
    font-size: .68rem;
    line-height: 1.25;
    padding-bottom: .18rem;
    padding-top: .18rem;
  }

  .md-sidebar--secondary .md-nav__link .md-ellipsis {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}
/* 主题切换：固定在居中搜索框左侧，避免被搜索框遮挡。 */
@media screen and (min-width: 76.25em) {
  .md-header__button[for^="__palette"] {
    align-items: center;
    display: flex;
    height: 2.4rem;
    /* 与搜索框左边缘保持固定距离；窄窗口也不会跑到屏幕外。 */
    left: max(1rem, calc(50vw - min(15rem, calc((100vw - 4rem) / 2)) - 2.7rem));
    position: fixed;
    top: .35rem;
    z-index: 21;
  }

  /* Material 在加载后会给两个 label 都加 hidden；按当前配色强制保留一个。 */
  body[data-md-color-scheme="slate"] .md-header__button[for="__palette_0"],
  body:not([data-md-color-scheme="slate"]) .md-header__button[for="__palette_1"] {
    display: flex !important;
  }

  body[data-md-color-scheme="slate"] .md-header__button[for="__palette_1"],
  body:not([data-md-color-scheme="slate"]) .md-header__button[for="__palette_0"] {
    display: none !important;
  }

  /* 由父容器负责定位，使图标和 3.75rem 高的搜索框严格居中。 */
  #__search:checked ~ .md-header form[data-md-component="palette"].md-header__option {
    align-items: center;
    height: 3.75rem;
    justify-content: center;
    left: max(1rem, calc(50vw - min(15rem, calc((100vw - 4rem) / 2)) - 2.7rem));
    position: fixed;
    top: 0;
    width: 2.7rem;
    z-index: 21;
  }

  #__search ~ .md-header form[data-md-component="palette"] .md-header__button[for^="__palette"] {
    height: auto;
    left: auto;
    margin: 0;
    position: static;
    top: auto;
  }
}
/* 独立的主题切换按钮，不再依赖 Material 会被搜索状态收起的内部控件。 */
.md-header form[data-md-component="palette"] {
  display: none !important;
}

#site-palette-toggle {
  align-items: center;
  background: transparent;
  border: 0;
  color: #fff;
  cursor: pointer;
  display: flex;
  justify-content: center;
  margin: 0;
  padding: 0;
  position: fixed;
  pointer-events: auto !important;
  touch-action: manipulation;
  width: 2.5rem;
  z-index: 2147483647;
}

#site-palette-toggle svg {
  fill: currentcolor;
  height: 1.5rem;
  pointer-events: none;
  width: 1.5rem;
}

/* 旧的常驻搜索规则优先级更高；最终隐藏 Material 的两枚原生主题按钮。 */
#__search ~ .md-header form[data-md-component="palette"].md-header__option {
  display: none !important;
}

.md-header .md-header__button[for^="__palette"] {
  display: none !important;
  visibility: hidden !important;
}

/* 文档分类下的资料列表始终用 1、2、3 编号，不使用 a、b、c。 */
.md-typeset ul ol {
  list-style-type: decimal;
}

/* 一级资料分类与其二级编号列表采用紧凑间距。 */
.md-typeset ul > li:has(> ol) > p {
  margin: 0 0 .2rem;
}

.md-typeset ul > li:has(> ol) > ol {
  margin: .05rem 0 .25rem -.9rem !important;
  padding-left: 0;
  list-style-position: inside;
}

.md-typeset ul > li:has(> ol) > ol > li {
  margin-bottom: 0;
}

.md-copyright {
  margin: auto;
  text-align: center;
}

/* 表格使用完整网格线，便于横向比对参数。 */
.md-typeset table:not([class]) {
  border: .05rem solid var(--md-default-fg-color--lighter);
  border-collapse: separate;
  border-radius: .2rem;
  border-spacing: 0;
}

.md-typeset table:not([class]) th,
.md-typeset table:not([class]) td {
  border-right: .05rem solid var(--md-default-fg-color--lighter);
  border-bottom: .05rem solid var(--md-default-fg-color--lighter);
}

.md-typeset table:not([class]) th:last-child,
.md-typeset table:not([class]) td:last-child {
  border-right: 0;
}

.md-typeset table:not([class]) tr:last-child td {
  border-bottom: 0;
}

/* 宽屏下始终展开顶层分类目录，首页也能看到左侧目录。 */
@media screen and (min-width: 45em) {
  .md-sidebar--primary .md-nav--primary > .md-nav__list > .md-nav__item--section > .md-nav__container {
    display: none !important;
  }
  .md-sidebar--primary .md-nav--lifted > .md-nav__list > .md-nav__item--nested {
    display: block !important;
  }
  .md-sidebar--primary .md-nav--primary > .md-nav__list > .md-nav__item--nested > .md-nav {
    grid-template-rows: minmax(.4rem, 1fr) !important;
    opacity: 1 !important;
    visibility: visible !important;
  }
}

/* 窄屏下也保留顶部导航标签（Anlogic / AI工具 并行显示，过窄时可横向滑动）。 */
@media screen and (max-width: 76.234375em) {
  .md-tabs {
    display: block;
  }
}
