/* ── 防抖:禁止 smooth scroll 及滚动条跳动 ── */
html {
    scroll-behavior: auto !important;
    scrollbar-gutter: stable;
}

/* ── 消除页面过渡闪烁 ── */
*, *::before, *::after {
    animation-duration: 0s !important;
    transition-duration: 0s !important;
}

html, body {
    overscroll-behavior: none;
}

/* ── 内容区拉伸 ── */
.bd-main .bd-content .bd-article-container {
    max-width: 100%;
}

/* ── 主侧边栏 ── */
.bd-sidebar-primary {
    max-height: 100vh;
    overflow-y: auto;
}

.bd-sidebar-primary .bd-links {
    font-size: .9em;
}

.bd-sidebar-primary .bd-links a {
    padding: .3em .6em;
    line-height: 1.45;
    border-radius: .25rem;
    transition: background-color .15s, color .15s;
}

.bd-sidebar-primary .bd-links a:hover {
    background-color: var(--pst-color-surface);
    text-decoration: none;
}

.bd-sidebar-primary .bd-links a.current {
    font-weight: 600;
}

/* ── 导航栏布局 ── */

@media (min-width: 960px) {
    /* 中栏弹性填充,把右栏推到右侧 */
    .bd-header .navbar-header-items__center {
        flex: 1 1 auto !important;
        justify-content: center;
        padding-left: 1rem;
        padding-right: 1rem;
    }

    /* 右栏紧贴右侧,与下方产品支持等内容的右边缘对齐 */
    .navbar-header-items__end {
        flex-shrink: 0;
        justify-content: flex-end;
    }
}

/* 导航链接美化 */
.bd-header .bd-navbar-elements .nav-link {
    font-size: .9em;
    font-weight: 500;
    transition: color .15s;
}

.bd-header .bd-navbar-elements .nav-item.current .nav-link {
    color: var(--pst-color-primary) !important;
    font-weight: 600;
}

/* 搜索框美化 */
.bd-header .search-button-field {
    border-radius: .35rem;
    padding: .35em .75em;
    font-size: .85em;
    transition: box-shadow .15s, border-color .15s;
}

.bd-header .search-button-field:hover {
    border-color: var(--pst-color-secondary);
}

/* ── 版本筛选下拉 ── */
.version-filter__container {
    position: relative;
    display: inline-flex;
    margin-left: .25em;
}

.version-filter__button {
    display: inline-flex;
    align-items: center;
    gap: .35em;
    font-size: .85em;
    font-weight: 500;
    padding: .25em .75em;
    border: 1px solid var(--pst-color-border);
    border-radius: .25rem;
    background: transparent;
    color: var(--pst-color-text-base);
    cursor: pointer;
    white-space: nowrap;
    line-height: 1.5;
}

.version-filter__button:hover {
    border-color: var(--pst-color-secondary);
    color: var(--pst-color-secondary);
}

.version-filter__caret {
    display: inline-block;
    width: 0;
    height: 0;
    margin-left: .15em;
    vertical-align: .255em;
    border-top: .3em solid currentColor;
    border-right: .3em solid transparent;
    border-left: .3em solid transparent;
}

/* ── 下拉菜单 ── */
.version-filter__menu {
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 2000;
    display: none;
    min-width: 10rem;
    padding: .35rem 0;
    margin: .125rem 0 0;
    background-color: var(--pst-color-on-background, var(--bs-body-bg, #fff));
    border: 1px solid var(--pst-color-border);
    border-radius: .25rem;
    box-shadow: 0 .5rem 1rem rgba(0, 0, 0, .15);
    list-style: none;
}

.version-filter__menu.show {
    display: block;
}

.version-filter__menu-item {
    display: block;
    width: 100%;
    padding: .3em 1em;
    font-size: .85em;
    font-weight: 500;
    text-align: left;
    border: none;
    background: none;
    color: var(--pst-color-text-base);
    cursor: pointer;
    white-space: nowrap;
    line-height: 1.5;
}

.version-filter__menu-item:hover {
    background-color: var(--pst-color-surface);
}

.version-filter__menu-item.active {
    font-weight: 700;
    background-color: var(--pst-color-surface);
}

/* ── 深色模式适配 ── */
html[data-theme="dark"] .version-filter__button {
    border-color: var(--pst-color-border);
    color: var(--pst-color-text-base);
}

html[data-theme="dark"] .version-filter__button:hover {
    border-color: var(--pst-color-secondary);
    color: var(--pst-color-secondary);
}

html[data-theme="dark"] .version-filter__menu {
    background-color: var(--pst-color-on-background, var(--bs-body-bg, #1b1b1b));
}

/* ── 文章内容美化 ── */

/* 标题层次更清晰 */
.bd-article h1 {
    font-size: 1.75em;
    border-bottom: 2px solid var(--pst-color-border);
    padding-bottom: .3em;
    margin-bottom: .8em;
}

.bd-article h2 {
    font-size: 1.35em;
    border-bottom: 1px solid var(--pst-color-border);
    padding-bottom: .2em;
    margin-top: 1.5em;
    margin-bottom: .6em;
}

.bd-article h3 {
    font-size: 1.15em;
    margin-top: 1.2em;
    margin-bottom: .4em;
}

/* 表格美化 */
.bd-article table {
    border-collapse: collapse;
    box-shadow: 0 1px 3px var(--pst-color-shadow);
    border-radius: .35rem;
    overflow: hidden;
}

.bd-article table thead th {
    background-color: var(--pst-color-surface);
    font-weight: 600;
    border-bottom: 2px solid var(--pst-color-border);
    padding: .55em .85em;
}

.bd-article table tbody td {
    padding: .45em .85em;
    border-bottom: 1px solid var(--pst-color-border-muted);
}

.bd-article table tbody tr:last-child td {
    border-bottom: none;
}

.bd-article table tbody tr:hover {
    background-color: var(--pst-color-surface);
}

/* 行内代码 */
.bd-article code.literal {
    padding: .1em .35em;
    border-radius: .25rem;
    font-size: .9em;
}

/* 代码块 */
.bd-article div.highlight {
    border-radius: .35rem;
    box-shadow: 0 1px 3px var(--pst-color-shadow);
    margin: 1em 0;
}

.bd-article div.highlight pre {
    padding: 1em;
    line-height: 1.5;
}

/* 产品支持表格中的 √/x 居中加粗 */
.bd-article table td[align="center"] {
    text-align: center;
    font-weight: 600;
}

/* ── toctree 折叠状态(点击 section header 切换) ── */
nav.bd-links.bd-links--collapsed {
    display: none;
}

/* ── 隐藏正文中 Sphinx 默认的扁平 toctree 列表,用 JS 动态注入树形结构 ── */
.bd-article > section > ul.simple {
    display: none;
}
.bd-article .toctree-wrapper.compound {
    margin: 1em 0;
}
.bd-article .toctree-wrapper.compound ul.nav.bd-sidenav {
    display: block;
    padding-left: 0;
    list-style: none;
}
.bd-article .toctree-wrapper.compound li.toctree-l1 {
    list-style: none;
}
.bd-article .toctree-wrapper.compound a.reference {
    text-decoration: none;
    white-space: normal;
    word-break: break-all;
}
.bd-article .toctree-wrapper.compound .toctree-l1.current > a.reference,
.bd-article .toctree-wrapper.compound .toctree-l2.current > a.reference,
.bd-article .toctree-wrapper.compound .toctree-l3.current > a.reference,
.bd-article .toctree-wrapper.compound .toctree-l4.current > a.reference {
    color: var(--pst-color-primary);
    font-weight: 600;
}
.bd-article .toctree-wrapper.compound details > summary {
    cursor: pointer;
    user-select: none;
    list-style: none;
}
.bd-article .toctree-wrapper.compound details > summary::-webkit-details-marker {
    display: none;
}
.bd-article .toctree-wrapper.compound details > summary .toctree-toggle {
    transition: transform .2s;
    display: inline-block;
}
.bd-article .toctree-wrapper.compound details[open] > summary .toctree-toggle {
    transform: rotate(0deg);
}
.bd-article .toctree-wrapper.compound details:not([open]) > summary .toctree-toggle {
    transform: rotate(-90deg);
}
.bd-article .toctree-wrapper.compound .toctree-l2 {
    padding-left: 1em;
}
.bd-article .toctree-wrapper.compound .toctree-l3 {
    padding-left: 2em;
}
.bd-article .toctree-wrapper.compound .toctree-l4 {
    padding-left: 3em;
}
.bd-article .toctree-wrapper.compound .toctree-l5 {
    padding-left: 4em;
}

/* ── 侧边栏 toctree 美化 ── */

/* 当前页高亮 */
.bd-sidebar-primary .toctree-l1.current > a.reference,
.bd-sidebar-primary .toctree-l2.current > a.reference,
.bd-sidebar-primary .toctree-l3.current > a.reference {
    color: var(--pst-color-primary);
    font-weight: 600;
}

/* details/summary 过渡动画 */
.bd-sidebar-primary details > summary {
    cursor: pointer;
    user-select: none;
}

.bd-sidebar-primary details > summary .toctree-toggle {
    transition: transform .2s;
    display: inline-block;
}

.bd-sidebar-primary details[open] > summary .toctree-toggle {
    transform: rotate(0deg);
}

.bd-sidebar-primary details:not([open]) > summary .toctree-toggle {
    transform: rotate(-90deg);
}

/* 子项缩进调整 */
.bd-sidebar-primary .toctree-l2 {
    padding-left: 1em;
}

.bd-sidebar-primary .toctree-l3 {
    padding-left: 2em;
}

.bd-sidebar-primary .toctree-l4 {
    padding-left: 3em;
}

/* ── 浮动下载按钮 ── */
.download-float-btn {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    z-index: 1050;
    display: inline-flex;
    align-items: center;
    gap: .5em;
    padding: .55em 1.1em;
    background: var(--pst-color-primary);
    color: #fff;
    border: none;
    border-radius: 2rem;
    box-shadow: 0 2px 12px rgba(0, 0, 0, .2);
    cursor: pointer;
    font-size: .88em;
    font-weight: 500;
    text-decoration: none;
    visibility: visible !important;
}

.download-float-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 18px rgba(0, 0, 0, .3);
    color: #fff;
    text-decoration: none;
}

.download-float-btn svg {
    width: 1.15em;
    height: 1.15em;
    fill: currentColor;
    flex-shrink: 0;
}