:root {
    --bg: #f4f6f5;
    --panel: #ffffff;
    --text: #1b2420;
    --muted: #66736d;
    --line: #e1e6e3;
    --accent: #128c4a;
    --accent-soft: #e3f4ea;
    --code-bg: #10201a;
    --code-text: #d8efe2;
    --note-bg: #fff4dc;
    --note-text: #6b4a00;
    color-scheme: light;
}
@media (prefers-color-scheme: dark) {
    :root {
        --bg: #111614;
        --panel: #1a211e;
        --text: #e5ebe8;
        --muted: #93a19a;
        --line: #2b3531;
        --accent: #25b866;
        --accent-soft: #173826;
        --code-bg: #0a1310;
        --code-text: #d8efe2;
        --note-bg: #3a2f14;
        --note-text: #f0d48a;
        color-scheme: dark;
    }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 15.5px/1.6 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.hidden { display: none !important; }

.top { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 14px; padding: 10px 24px; background: var(--panel); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 17px; color: var(--text); text-decoration: none; }
.brand img { width: 26px; height: 26px; }
.top .btn { margin-left: auto; padding: 6px 14px; border: 1px solid var(--line); border-radius: 8px; text-decoration: none; color: var(--text); font-weight: 600; font-size: 14px; }
.top .menu { display: none; }

.layout { display: grid; grid-template-columns: 240px minmax(0, 1fr); max-width: 1180px; margin: 0 auto; }
.toc { position: sticky; top: 53px; align-self: start; max-height: calc(100vh - 53px); overflow-y: auto; padding: 22px 12px 22px 24px; }
.toc a { display: block; padding: 5px 10px; border-radius: 6px; color: var(--muted); text-decoration: none; font-size: 14px; }
.toc a:hover { color: var(--text); background: var(--panel); }
.toc a.on { color: var(--accent); background: var(--accent-soft); font-weight: 600; }

.doc { padding: 26px 32px 60px; min-width: 0; }
.doc section { margin-bottom: 44px; scroll-margin-top: 70px; }
h1 { font-size: 30px; margin: 0 0 12px; }
h2 { font-size: 22px; margin: 0 0 12px; padding-top: 6px; border-top: 1px solid var(--line); padding-top: 22px; }
.doc section:first-child h1 + p { font-size: 16.5px; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.9em; background: var(--panel); border: 1px solid var(--line); border-radius: 4px; padding: 0 4px; }

pre.code { position: relative; background: var(--code-bg); color: var(--code-text); border-radius: 10px; padding: 14px 16px; overflow-x: auto; font: 13px/1.55 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; margin: 10px 0 16px; white-space: pre; }
pre.code .base { color: #8fe3b0; }
pre.code .copy { position: absolute; top: 8px; right: 8px; font: 600 12px system-ui, sans-serif; padding: 3px 9px; border-radius: 6px; border: 1px solid #ffffff33; background: #ffffff14; color: #fff; cursor: pointer; opacity: 0.7; }
pre.code:hover .copy { opacity: 1; }

.tabs { margin: 10px 0 16px; }
.tabs pre.code { margin-top: 0; border-top-left-radius: 0; }
.tab-bar { display: flex; gap: 2px; }
.tab-bar button { font: 600 13px system-ui, sans-serif; padding: 6px 14px; border: 0; border-radius: 8px 8px 0 0; background: var(--line); color: var(--muted); cursor: pointer; }
.tab-bar button.on { background: var(--code-bg); color: #fff; }

table { width: 100%; border-collapse: collapse; margin: 10px 0 18px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; font-size: 14.5px; display: block; overflow-x: auto; }
th, td { text-align: left; padding: 8px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { background: var(--bg); font-size: 13px; }
tr:last-child td { border-bottom: 0; }
table.ref th { background: var(--accent-soft); color: var(--accent); }
td:first-child { white-space: nowrap; }
td code { white-space: nowrap; }
.note { background: var(--note-bg); color: var(--note-text); padding: 10px 14px; border-radius: 8px; font-size: 14.5px; }
.foot { margin-top: 40px; font-size: 13px; }

@media (max-width: 820px) {
    .layout { grid-template-columns: 1fr; }
    .top { padding: 10px 16px; }
    .top .menu { display: inline-block; font: 600 14px system-ui, sans-serif; padding: 6px 12px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); color: var(--text); }
    .top .btn { margin-left: 0; }
    .top > .muted { display: none; }
    .toc { display: none; position: fixed; top: 53px; left: 0; right: 0; bottom: 0; max-height: none; background: var(--bg); z-index: 9; padding: 16px; }
    .toc.open { display: block; }
    .doc { padding: 20px 16px 50px; }
    td:first-child, td code { white-space: normal; }
}
