/* ==========================================================================
   开发文档 · 主题样式（替代 layui / zTree / SyntaxHighlighter）
   ========================================================================== */

:root {
    --brand-700: #0143d1;
    --brand-600: #1457ff;
    --brand-500: #3d7bff;
    --ink-900: #070b16;
    --ink-800: #101828;
    --ink-700: #1f2b3d;
    --ink-600: #3a4a61;
    --ink-500: #5b6b82;
    --ink-400: #8494a9;
    --ink-300: #b3c0d0;
    --line: #e7ecf3;
    --line-soft: #eff3f8;
    --bg: #ffffff;
    --bg-soft: #f7f9fc;
    --code-bg: #0a1220;
    --radius: 12px;
    --header-h: 64px;
    --shadow-sm: 0 1px 2px rgba(7, 11, 22, .05);
    --ease: cubic-bezier(.22, .61, .36, 1);
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
            "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
    --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
            "Liberation Mono", "Courier New", monospace;
}

*,
*::before,
*::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: 90px; }

body {
    margin: 0;
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.75;
    color: var(--ink-600);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}

a { color: var(--brand-600); text-decoration: none; }
img { max-width: 100%; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }

:focus-visible { outline: 2px solid var(--brand-500); outline-offset: 2px; border-radius: 6px; }

/* ---------- header ---------- */
.doc-header {
    position: sticky;
    top: 0;
    z-index: 60;
    height: var(--header-h);
    background: rgba(255, 255, 255, .9);
    border-bottom: 1px solid var(--line);
    -webkit-backdrop-filter: saturate(180%) blur(14px);
    backdrop-filter: saturate(180%) blur(14px);
}
.doc-header__inner {
    display: flex;
    align-items: center;
    gap: 22px;
    height: 100%;
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 24px;
}
.doc-brand { display: inline-flex; align-items: center; gap: 10px; flex: none; }
.doc-brand img { height: 26px; width: auto; display: block; }
.doc-brand span {
    padding-left: 10px;
    border-left: 1px solid var(--line);
    font-size: 14.5px;
    font-weight: 600;
    color: var(--ink-800);
}
.doc-nav { display: flex; align-items: center; gap: 4px; }
.doc-nav a {
    padding: 7px 12px;
    border-radius: 8px;
    font-size: 14px;
    color: var(--ink-500);
    transition: color .2s var(--ease), background-color .2s var(--ease);
}
.doc-nav a:hover { color: var(--brand-600); background: rgba(20, 87, 255, .06); }
.doc-nav a.is-current { color: var(--brand-600); font-weight: 600; }
.doc-nav__home { margin-left: auto; }

.doc-search {
    position: relative;
    margin-left: auto;
    width: 260px;
    flex: none;
}
.doc-search input {
    width: 100%;
    height: 36px;
    padding: 0 34px 0 34px;
    border: 1px solid var(--line);
    border-radius: 9px;
    background: var(--bg-soft);
    font-family: inherit;
    font-size: 13.5px;
    color: var(--ink-800);
    transition: border-color .2s var(--ease), background-color .2s var(--ease), box-shadow .2s var(--ease);
}
.doc-search input::placeholder { color: var(--ink-400); }
.doc-search input:focus {
    outline: none;
    background: #fff;
    border-color: var(--brand-500);
    box-shadow: 0 0 0 3px rgba(20, 87, 255, .1);
}
.doc-search__icon {
    position: absolute;
    left: 11px;
    top: 50%;
    width: 15px;
    height: 15px;
    transform: translateY(-50%);
    color: var(--ink-400);
    pointer-events: none;
}
.doc-search kbd {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    padding: 1px 6px;
    border: 1px solid var(--line);
    border-radius: 5px;
    background: #fff;
    font-family: var(--mono);
    font-size: 11px;
    color: var(--ink-400);
}

.doc-menu { display: none; width: 38px; height: 38px; align-items: center; justify-content: center; border-radius: 9px; border: 1px solid var(--line); flex: none; }
.doc-menu svg { width: 18px; height: 18px; }

/* ---------- shell ---------- */
.doc-shell {
    display: grid;
    grid-template-columns: 258px minmax(0, 1fr) 196px;
    gap: 44px;
    max-width: 1400px;
    margin: 0 auto;
    padding: 30px 24px 90px;
}

/* ---------- sidebar ---------- */
.doc-side {
    position: sticky;
    top: calc(var(--header-h) + 22px);
    align-self: start;
    max-height: calc(100vh - var(--header-h) - 44px);
    overflow-y: auto;
    padding-right: 10px;
    scrollbar-width: thin;
}
.doc-side::-webkit-scrollbar { width: 5px; }
.doc-side::-webkit-scrollbar-thumb { background: var(--line); border-radius: 3px; }

.doc-side__label {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 0 4px;
    padding: 0 8px 10px;
    border-bottom: 1px solid var(--line);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: .06em;
    color: var(--ink-800);
}
.doc-group + .doc-group { margin-top: 16px; }
.doc-group__title {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 0 4px;
    padding: 6px 8px 4px;
    font-size: 11.5px;
    font-weight: 700;
    letter-spacing: .08em;
    color: var(--ink-400);
}
.doc-group__title::after {
    content: "";
    flex: 1 1 auto;
    height: 1px;
    background: var(--line-soft);
}
.doc-link {
    position: relative;
    display: block;
    margin-left: 10px;
    padding: 6px 8px 6px 11px;
    border-left: 1px solid var(--line);
    border-radius: 0 7px 7px 0;
    font-size: 13.5px;
    line-height: 1.55;
    color: var(--ink-600);
    transition: color .18s var(--ease), background-color .18s var(--ease), border-color .18s var(--ease);
}
.doc-link:hover {
    color: var(--brand-600);
    background: rgba(20, 87, 255, .04);
    border-left-color: var(--ink-300);
}
.doc-link.is-current {
    color: var(--brand-700);
    font-weight: 600;
    background: rgba(20, 87, 255, .07);
    border-left-color: var(--brand-600);
}
.doc-link[hidden] { display: none; }
.doc-group[hidden] { display: none; }

/* ---------- article ---------- */
.doc-main { min-width: 0; max-width: 860px; }
.doc-article { min-height: 60vh; }

.doc-article > h1:first-child { margin-top: 0; }
.doc-article h1 {
    margin: 0 0 22px;
    padding-bottom: 18px;
    border-bottom: 1px solid var(--line);
    font-size: clamp(26px, 2.4vw, 32px);
    line-height: 1.28;
    letter-spacing: -.02em;
    font-weight: 800;
    color: var(--ink-900);
    text-wrap: balance;
}
.doc-article h1 a,
.doc-article h4 a {
    color: inherit;
    text-decoration: none;
    border: 0;
    position: relative;
}
.doc-article h1 a::after,
.doc-article h4 a::after {
    content: "#";
    margin-left: 8px;
    font-weight: 500;
    color: var(--brand-500);
    opacity: 0;
    transition: opacity .18s var(--ease);
}
.doc-article h1 a:hover::after,
.doc-article h4 a:hover::after { opacity: 1; }

.doc-article h2 {
    margin: 42px 0 14px;
    font-size: 22px;
    line-height: 1.35;
    font-weight: 700;
    letter-spacing: -.02em;
    color: var(--ink-900);
}
.doc-article h3 {
    margin: 32px 0 12px;
    font-size: 18px;
    line-height: 1.4;
    font-weight: 700;
    color: var(--ink-900);
}
.doc-article h2 a,
.doc-article h3 a { color: inherit; border: 0; }
.doc-article h4 {
    position: relative;
    margin: 34px 0 12px;
    padding-left: 13px;
    font-size: 16.5px;
    font-weight: 700;
    color: var(--ink-900);
    letter-spacing: -.01em;
}
.doc-article h4::before {
    content: "";
    position: absolute;
    left: 0;
    top: .45em;
    width: 3px;
    height: 14px;
    border-radius: 2px;
    background: var(--brand-600);
}

.doc-article p { margin: 12px 0; line-height: 1.85; }
.doc-article ul, .doc-article ol { margin: 12px 0; padding-left: 22px; }
.doc-article li { margin: 6px 0; line-height: 1.8; }
.doc-article li::marker { color: var(--ink-300); }
.doc-article br { line-height: 0; }

.doc-article a:not([href^="#"]) {
    color: var(--brand-600);
    border-bottom: 1px solid rgba(20, 87, 255, .28);
    transition: border-color .18s var(--ease);
}
.doc-article a:not([href^="#"]):hover { border-bottom-color: var(--brand-600); }

.doc-article blockquote {
    margin: 18px 0;
    padding: 14px 18px;
    border: 1px solid #dbe8ff;
    border-left: 3px solid var(--brand-500);
    border-radius: 10px;
    background: linear-gradient(180deg, #f7faff, #f2f7ff);
    color: var(--ink-600);
}
.doc-article blockquote p { margin: 0; font-size: 14px; line-height: 1.8; }

.doc-article code {
    padding: 1px 6px;
    border: 1px solid #e1eaf7;
    border-radius: 5px;
    background: #f3f7fd;
    font-family: var(--mono);
    font-size: .86em;
    color: #1746c9;
    white-space: nowrap;
}

/* tables */
.doc-article .table-wrap {
    margin: 16px 0 22px;
    border: 1px solid var(--line);
    border-radius: 12px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
.doc-article table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    line-height: 1.65;
}
.doc-article th {
    padding: 11px 14px;
    background: var(--bg-soft);
    border-bottom: 1px solid var(--line);
    font-weight: 600;
    color: var(--ink-800);
    text-align: left;
    white-space: nowrap;
}
.doc-article td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--line-soft);
    color: var(--ink-600);
    vertical-align: top;
}
.doc-article tr:last-child td { border-bottom: 0; }
.doc-article tbody tr:hover td { background: #fbfdff; }
.doc-article td code { white-space: nowrap; }

/* code blocks */
.doc-article .code-block {
    position: relative;
    margin: 16px 0 22px;
    border-radius: 12px;
    background: var(--code-bg);
    box-shadow: 0 20px 40px -30px rgba(7, 11, 22, .8);
    overflow: hidden;
}
.doc-article .code-block pre {
    margin: 0;
    padding: 18px 20px;
    overflow-x: auto;
    font-family: var(--mono);
    font-size: 12.6px;
    line-height: 1.9;
    color: #c8d8ee;
    tab-size: 4;
}
.doc-article .code-block code {
    padding: 0;
    border: 0;
    background: none;
    color: inherit;
    font-size: inherit;
    white-space: pre;
}
.doc-copy {
    position: absolute;
    top: 10px;
    right: 10px;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 10px;
    border: 1px solid rgba(255, 255, 255, .14);
    border-radius: 7px;
    background: rgba(255, 255, 255, .06);
    font-size: 11.5px;
    color: rgba(255, 255, 255, .72);
    opacity: 0;
    transition: opacity .2s var(--ease), background-color .2s var(--ease), color .2s var(--ease);
}
.doc-article .code-block:hover .doc-copy { opacity: 1; }
.doc-copy:hover { background: rgba(255, 255, 255, .14); }
.doc-copy.is-done { color: #5be3b4; border-color: rgba(91, 227, 180, .45); }

/* ---------- toc ---------- */
.doc-toc {
    position: sticky;
    top: calc(var(--header-h) + 22px);
    align-self: start;
    max-height: calc(100vh - var(--header-h) - 44px);
    overflow-y: auto;
    padding-left: 4px;
}
.doc-toc__label {
    margin: 0 0 10px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .14em;
    text-transform: uppercase;
    color: var(--ink-300);
}
.doc-toc nav { display: grid; gap: 1px; }
.doc-toc a {
    display: block;
    padding: 5px 0 5px 12px;
    border-left: 1px solid var(--line);
    font-size: 12.5px;
    line-height: 1.55;
    color: var(--ink-400);
    transition: color .18s var(--ease), border-color .18s var(--ease);
}
.doc-toc a:hover { color: var(--ink-700); }
.doc-toc a.is-sub { padding-left: 24px; font-size: 12px; color: var(--ink-300); }
.doc-toc a.is-sub:hover { color: var(--ink-600); }
.doc-toc a.is-sub.is-current { color: var(--brand-600); }
.doc-toc a.is-current { color: var(--brand-600); border-left-color: var(--brand-600); font-weight: 600; }

/* ---------- footer ---------- */
.doc-foot {
    margin-top: 56px;
    padding-top: 22px;
    border-top: 1px solid var(--line);
    display: flex;
    flex-wrap: wrap;
    gap: 10px 24px;
    align-items: center;
    justify-content: space-between;
    font-size: 12.5px;
    color: var(--ink-400);
}
.doc-foot__links { display: flex; gap: 16px; }
.doc-foot__links a { color: var(--ink-500); }
.doc-foot__links a:hover { color: var(--brand-600); }

/* ---------- mask ---------- */
.doc-mask {
    position: fixed;
    inset: 0;
    z-index: 55;
    background: rgba(7, 11, 22, .4);
    opacity: 0;
    visibility: hidden;
    transition: opacity .25s var(--ease), visibility .25s;
}
body.doc-drawer-open .doc-mask { opacity: 1; visibility: visible; }

/* ---------- responsive ---------- */
@media (max-width: 1280px) {
    .doc-shell { grid-template-columns: 250px minmax(0, 1fr); gap: 36px; }
    .doc-toc { display: none; }
}
@media (max-width: 960px) {
    .doc-nav { display: none; }
    .doc-menu { display: inline-flex; }
    .doc-search { width: 220px; }
    .doc-shell { grid-template-columns: minmax(0, 1fr); gap: 0; padding: 20px 20px 70px; }
    .doc-side {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        z-index: 70;
        width: 280px;
        max-height: none;
        padding: 22px 16px 40px;
        background: #fff;
        border-right: 1px solid var(--line);
        transform: translateX(-102%);
        transition: transform .28s var(--ease);
        box-shadow: 20px 0 50px -40px rgba(7, 11, 22, .5);
    }
    body.doc-drawer-open .doc-side { transform: none; }
    .doc-main { max-width: none; }
}
@media (max-width: 640px) {
    .doc-header__inner { gap: 12px; padding: 0 14px; }
    .doc-brand span { display: none; }
    .doc-search { width: 100%; margin-left: 0; }
    .doc-search kbd { display: none; }
    .doc-shell { padding: 16px 14px 60px; }
    .doc-article h1 { font-size: 24px; }
.doc-article h4 { font-size: 15.5px; margin-top: 28px; }
    .doc-article table { min-width: 620px; }
    .doc-article th, .doc-article td { padding: 8px 10px; font-size: 12.5px; }
    .doc-article .code-block pre { padding: 14px; font-size: 12px; }
    .doc-copy { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    *, *::before, *::after { transition-duration: .001ms !important; animation-duration: .001ms !important; }
}

@media print {
    .doc-header, .doc-side, .doc-toc, .doc-forward, .doc-copy { display: none !important; }
    .doc-shell { display: block; padding: 0; max-width: none; }
    .doc-article { max-width: none; }
}
