:root {
  --bg: #ffffff;
  --bg-soft: #f6f7f9;
  --fg: #1d2129;
  --fg-muted: #5b6270;
  --border: #e3e6eb;
  --accent: #6b4de6;
  --accent-soft: #efebfd;
  --note: #2f6fdb;
  --note-bg: #eef4fe;
  --tip: #1f8a5b;
  --tip-bg: #eaf7f0;
  --warn: #b26a00;
  --warn-bg: #fff6e5;
  --code-inline-bg: #f0f1f4;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #11131a;
    --bg-soft: #181b24;
    --fg: #e4e7ee;
    --fg-muted: #9aa2b1;
    --border: #2a2f3b;
    --accent: #a993ff;
    --accent-soft: #241f3d;
    --note: #7aa7f5;
    --note-bg: #16223a;
    --tip: #5cc795;
    --tip-bg: #13291f;
    --warn: #f0b252;
    --warn-bg: #2d2313;
    --code-inline-bg: #222631;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html { scroll-padding-top: 4.5rem; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 16px/1.65 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, Helvetica, Arial, sans-serif;
}
a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 2px; }

.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: .75rem;
  height: 3.5rem; padding: 0 1.25rem;
  background: var(--bg); border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; font-size: 1.05rem; color: var(--fg); text-decoration: none; }
.brand-mark { color: var(--accent); }
.nav-toggle { display: none; background: none; border: 1px solid var(--border); color: var(--fg); border-radius: 6px; padding: .2rem .55rem; font-size: 1rem; cursor: pointer; }

.layout { display: grid; grid-template-columns: 17rem minmax(0, 1fr); max-width: 82rem; margin: 0 auto; }
.sidebar {
  position: sticky; top: 3.5rem; align-self: start;
  height: calc(100vh - 3.5rem); overflow-y: auto;
  padding: 1.5rem 1rem 2rem 1.25rem; border-right: 1px solid var(--border);
  font-size: .93rem;
}
.sidebar ul { list-style: none; margin: 0 0 1rem; padding: 0; }
.sidebar li a { display: block; padding: .3rem .6rem; border-radius: 6px; color: var(--fg-muted); text-decoration: none; }
.sidebar li a:hover { color: var(--fg); background: var(--bg-soft); }
.sidebar li a.active { color: var(--accent); background: var(--accent-soft); font-weight: 600; }
.nav-heading { margin: 1rem 0 .35rem .6rem; font-size: .75rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.nav-heading a { color: var(--fg-muted); text-decoration: none; }

.content { padding: 2rem 3rem 5rem; min-width: 0; }
article { max-width: 48rem; }
h1 { font-size: 2.1rem; line-height: 1.2; margin: .5rem 0 .75rem; }
h2 { font-size: 1.45rem; margin: 2.6rem 0 .75rem; padding-top: 1.2rem; border-top: 1px solid var(--border); }
h3 { font-size: 1.12rem; margin: 1.8rem 0 .5rem; }
.lede { font-size: 1.15rem; color: var(--fg-muted); margin-top: 0; }

code { font: .88em/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
:not(pre) > code { background: var(--code-inline-bg); padding: .12em .35em; border-radius: 4px; }
pre { overflow-x: auto; padding: 1rem 1.1rem; border-radius: 8px; margin: 0; font-size: .92rem; }
div.highlight, pre.has-copy { position: relative; margin: 1rem 0 1.25rem; }
pre:not(.chroma) { background: #0d1117; color: #e6edf3; }
.copy-btn {
  position: absolute; top: .5rem; right: .5rem;
  background: rgba(255,255,255,.08); color: #c9d1d9; border: 1px solid rgba(255,255,255,.15);
  border-radius: 5px; font-size: .75rem; padding: .15rem .5rem; cursor: pointer; opacity: 0; transition: opacity .15s;
}
.has-copy:hover .copy-btn, .copy-btn:focus { opacity: 1; }

table { border-collapse: collapse; width: 100%; margin: 1rem 0 1.5rem; font-size: .93rem; display: block; overflow-x: auto; }
th, td { border: 1px solid var(--border); padding: .5rem .7rem; text-align: left; vertical-align: top; }
th { background: var(--bg-soft); }

.callout { border-left: 4px solid var(--note); background: var(--note-bg); padding: .8rem 1rem; border-radius: 0 8px 8px 0; margin: 1.25rem 0; }
.callout > :last-child { margin-bottom: 0; }
.callout-title { display: block; color: var(--note); margin-bottom: .2rem; }
.callout-tip { border-color: var(--tip); background: var(--tip-bg); }
.callout-tip .callout-title { color: var(--tip); }
.callout-warning { border-color: var(--warn); background: var(--warn-bg); }
.callout-warning .callout-title { color: var(--warn); }

.toc { background: var(--bg-soft); border: 1px solid var(--border); border-radius: 8px; padding: .6rem 1rem; margin: 1.25rem 0 1.5rem; font-size: .92rem; }
.toc summary { cursor: pointer; font-weight: 600; }
.toc ul { margin: .4rem 0; padding-left: 1.1rem; }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); gap: 1rem; margin-top: 1.25rem; }
.card { display: block; border: 1px solid var(--border); border-radius: 10px; padding: 1rem 1.1rem; text-decoration: none; color: var(--fg); background: var(--bg); transition: border-color .15s, transform .15s; }
.card:hover { border-color: var(--accent); transform: translateY(-1px); }
.card h3 { margin: 0 0 .35rem; font-size: 1.02rem; color: var(--accent); }
.card p { margin: 0; font-size: .9rem; color: var(--fg-muted); }

.pager { display: flex; justify-content: space-between; gap: 1rem; margin-top: 3rem; padding-top: 1.5rem; border-top: 1px solid var(--border); }
.pager a { display: block; border: 1px solid var(--border); border-radius: 8px; padding: .6rem 1rem; text-decoration: none; max-width: 48%; }
.pager a small { display: block; color: var(--fg-muted); font-size: .75rem; }
.pager a.next { text-align: right; margin-left: auto; }
.pager a:hover { border-color: var(--accent); }

ol li, ul li { margin: .25rem 0; }

@media (max-width: 52rem) {
  .layout { grid-template-columns: 1fr; }
  .nav-toggle { display: inline-block; }
  .sidebar { display: none; position: fixed; top: 3.5rem; left: 0; right: 0; height: calc(100vh - 3.5rem); background: var(--bg); z-index: 9; border-right: 0; }
  body.nav-open .sidebar { display: block; }
  .content { padding: 1.25rem 1rem 4rem; }
  h1 { font-size: 1.7rem; }
}
.brand-version { display: inline-block; background: var(--accent); color: var(--bg); font-size: .78rem; line-height: 1; padding: .2rem .4rem; border-radius: 5px; vertical-align: 2px; }
