@import url("https://cdn.jsdelivr.net/npm/@fontsource/inter@5/400.css");
@import url("https://cdn.jsdelivr.net/npm/@fontsource/inter@5/600.css");
@import url("https://cdn.jsdelivr.net/npm/@fontsource/inter@5/700.css");
@import url("https://cdn.jsdelivr.net/npm/@fontsource/noto-sans-sc@5/400.css");
@import url("https://cdn.jsdelivr.net/npm/@fontsource/noto-sans-sc@5/500.css");
@import url("https://cdn.jsdelivr.net/npm/@fontsource/noto-sans-sc@5/700.css");

:root {
    --bg: #ffffff;
    --fg: #1f2328;
    --muted: #656d76;
    --accent: #3b5bdb;
    --accent-soft: #eef2ff;
    --border: #e6e8eb;
    --code-bg: #f6f8fa;
    --code-border: #eaecef;
    --sidebar-w: 272px;
    --good: #2e7d4f;
    --warn: #b26a00;
}

* { box-sizing: border-box; }

html {
    scroll-behavior: smooth;
    font-size: 16px;
}

body {
    margin: 0;
    font-family: "Inter", -apple-system, "Segoe UI", "Noto Sans SC", "PingFang SC",
        "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    background: var(--bg);
    color: var(--fg);
    line-height: 1.8;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

/* ---------- layout ---------- */

.layout {
    display: flex;
    min-height: 100vh;
}

nav.sidebar {
    width: var(--sidebar-w);
    flex-shrink: 0;
    border-right: 1px solid var(--border);
    padding: 1.6rem 1.1rem 3rem;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    background: #fbfcfd;
}

main.content {
    flex: 1;
    min-width: 0;
    max-width: 780px;
    margin: 0 auto;
    padding: 2.4rem 2.6rem 6rem;
}

@media (max-width: 900px) {
    .layout { flex-direction: column; }
    nav.sidebar { width: 100%; height: auto; position: static; border-right: none; border-bottom: 1px solid var(--border); }
    main.content { padding: 1.5rem 1.2rem 4rem; }
}

/* ---------- scrollbars ---------- */

* {
    scrollbar-width: thin;
    scrollbar-color: #d4d8dc transparent;
}
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d4d8dc; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #b9bec4; }

/* the sidebar and the page toc scroll without visible scrollbars */
nav.sidebar, aside.toc { scrollbar-width: none; }
nav.sidebar::-webkit-scrollbar, aside.toc::-webkit-scrollbar { display: none; }

/* ---------- sidebar ---------- */

.sidebar .site-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: .15rem;
}

.sidebar .site-title {
    display: inline-flex;
    align-items: center;
    gap: .45rem;
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--fg);
    text-decoration: none;
}

.sidebar .site-logo {
    width: 21px;
    height: 21px;
    object-fit: contain;
}

.sidebar .github-link {
    display: inline-flex;
    color: var(--muted);
}
.sidebar .github-link svg { width: 19px; height: 19px; fill: currentColor; }
.sidebar .github-link:hover { color: var(--fg); }

.sidebar .site-sub {
    font-size: .78rem;
    color: var(--muted);
    margin-bottom: .9rem;
}

.sidebar .lang-switch {
    display: inline-block;
    font-size: .78rem;
    padding: .12rem .6rem;
    border: 1px solid var(--border);
    border-radius: 12px;
    text-decoration: none;
    color: var(--muted);
    margin: 0 .2rem .9rem 0;
    background: #fff;
}
.sidebar .lang-switch:hover { border-color: var(--accent); color: var(--accent); }

.sidebar h4 {
    font-size: .72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--muted);
    margin: 1.5rem 0 .4rem;
}

.sidebar ul { list-style: none; margin: 0; padding: 0; }

.sidebar li a {
    display: block;
    padding: .3rem .6rem;
    border-radius: 6px;
    text-decoration: none;
    color: #454c54;
    font-size: .88rem;
    line-height: 1.5;
}

.sidebar li a:hover { background: #f0f2f5; color: var(--fg); }

.sidebar li a.active {
    background: var(--accent-soft);
    color: var(--accent);
    font-weight: 600;
}

/* ---------- breadcrumbs ---------- */

nav.breadcrumbs {
    font-size: .82rem;
    color: var(--muted);
    margin-bottom: 1.6rem;
}
.breadcrumbs a { color: var(--muted); text-decoration: none; }
.breadcrumbs a:hover { color: var(--accent); }
.breadcrumbs .sep { margin: 0 .45rem; color: #c3c8cd; }
.breadcrumbs .current { color: var(--fg); }

/* ---------- content typography ---------- */

h1 {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1.35;
    letter-spacing: -.01em;
    margin: 0 0 2.2rem;
}
h2 {
    font-size: 1.35rem;
    font-weight: 700;
    letter-spacing: -.005em;
    margin: 3rem 0 1rem;
}
h3 {
    font-size: 1.08rem;
    font-weight: 600;
    margin: 2.2rem 0 .8rem;
}

p { margin: .95rem 0; }

ul, ol { padding-left: 1.5rem; margin: .95rem 0; }
li { margin: .4rem 0; }

a { color: var(--accent); text-decoration: none; }
main.content a:hover { text-decoration: underline; }

/* the opening paragraph belongs to the body, not to the title */
p.lead { margin-top: 0; }
p.lead + h2 { margin-top: 1.6rem; }

p.lang-note {
    margin: 0 0 1.2rem;
    font-size: .84rem;
    color: var(--muted);
}

/* small annotation under a code block or paragraph */
p.note {
    font-size: .84rem;
    color: var(--muted);
    margin: .5rem 0 1rem;
}

h2[id], h3[id] { scroll-margin-top: 1.6rem; }

/* ---------- code ---------- */

code {
    font-family: "Cascadia Code", Consolas, "JetBrains Mono", ui-monospace, monospace;
    font-size: .86em;
    background: var(--code-bg);
    padding: .12em .38em;
    border-radius: 5px;
}

pre {
    background: var(--code-bg);
    border: 1px solid var(--code-border);
    border-radius: 8px;
    padding: 1rem 1.2rem;
    overflow-x: auto;
    line-height: 1.65;
    margin: 1.1rem 0;
}

pre code {
    background: none;
    border: none;
    padding: 0;
    font-size: .83rem;
}

/* shiki sets an inline background; unify it with the site's code background */
pre.shiki { background: var(--code-bg) !important; }

/* ---------- tables ---------- */

table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.2rem 0;
    font-size: .9rem;
    line-height: 1.65;
}
th, td {
    text-align: left;
    padding: .55rem .8rem;
    border: none;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
}
th {
    border-bottom: 2px solid #d7dade;
    font-weight: 600;
    background: none;
}

/* first column stays on one line (for tables with short label columns) */
table.nowrap-first th:first-child,
table.nowrap-first td:first-child {
    white-space: nowrap;
}

/* ---------- callouts ---------- */

blockquote {
    margin: 1.2rem 0;
    padding: .7rem 1.2rem;
    border-left: 3px solid var(--accent);
    background: var(--accent-soft);
    border-radius: 0 8px 8px 0;
}
blockquote p { margin: .3rem 0; }

.tip, .warn-box {
    padding: .85rem 1.2rem;
    border-radius: 8px;
    margin: 1.2rem 0;
    font-size: .93rem;
    line-height: 1.75;
}
.tip { background: #ebf5ef; border-left: 3px solid var(--good); }
.warn-box { background: #fdf3e3; border-left: 3px solid var(--warn); }

/* ---------- screenshots ---------- */

figure.shot { margin: 1.4rem 0; }

figure.shot img {
    display: block;
    max-width: 100%;
    height: auto;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--code-bg);
}

figure.shot figcaption {
    margin-top: .55rem;
    font-size: .85rem;
    line-height: 1.7;
    color: var(--muted);
}

/* 竖条形状的图（侧边栏、参数抽屉）不必撑满正文宽度。 */
figure.shot.narrow img { max-width: min(100%, 240px); }
figure.shot.medium img { max-width: min(100%, 420px); }

/* ---------- layer diagram ---------- */

.layers {
    display: flex;
    flex-direction: column;
    gap: .5rem;
    margin: 1.2rem 0;
}
.layers .layer {
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fbfcfd;
    padding: .6rem 1rem;
}
.layers .layer-row {
    display: flex;
    gap: .5rem;
}
.layers .layer-row .layer { flex: 1; }
.layer .layer-name {
    font-family: "Cascadia Code", Consolas, ui-monospace, monospace;
    font-size: .9rem;
    color: var(--accent);
    margin-bottom: .1rem;
}
.layer .layer-desc {
    font-size: .85rem;
    color: var(--muted);
}
@media (max-width: 700px) {
    .layers .layer-row { flex-direction: column; }
}

/* ---------- prev / next footer ---------- */

.pager {
    display: flex;
    justify-content: space-between;
    margin-top: 4rem;
    padding-top: 1.2rem;
    border-top: 1px solid var(--border);
    gap: 1rem;
}
.pager a {
    text-decoration: none;
    padding: .65rem 1rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    max-width: 48%;
    color: var(--fg);
    font-size: .92rem;
}
.pager a:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }
.pager .dir { display: block; font-size: .75rem; color: var(--muted); }

/* ---------- on-page table of contents (right column) ---------- */

aside.toc {
    width: 230px;
    flex-shrink: 0;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    /* top padding aligns the toc with the page title,
       past the breadcrumbs row of the content column */
    padding: 5.4rem 1.4rem 3rem 0;
    font-size: .8rem;
}
.toc .toc-title {
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: .08em;
    font-size: .7rem;
    font-weight: 600;
    margin-bottom: .5rem;
}
.toc ul {
    list-style: none;
    margin: 0;
    padding: 0;
    border-left: 1px solid var(--border);
}
.toc li { margin: 0; }
.toc li a {
    display: block;
    padding: .2rem .8rem;
    margin-left: -1px;
    color: var(--muted);
    text-decoration: none;
    border-left: 2px solid transparent;
    line-height: 1.5;
}
.toc li a:hover { color: var(--fg); text-decoration: none; }
.toc li a.active { color: var(--accent); border-left-color: var(--accent); }
.toc li.toc-h3 a { padding-left: 1.7rem; }
@media (max-width: 1250px) {
    aside.toc { display: none; }
}

/* ---------- landing (redirect page) ---------- */

.landing {
    max-width: 720px;
    margin: 0 auto;
    padding: 14vh 2rem 4rem;
    text-align: center;
}
.landing h1 { font-size: 2.4rem; margin-bottom: .4rem; }
.landing .tagline { color: var(--muted); font-size: 1.05rem; }
.landing .landing-logo { width: 76px; height: 76px; object-fit: contain; margin-bottom: .6rem; }
