:root {
  --bg: #ffffff; --fg: #1f2937; --muted: #64748b; --line: #e2e8f0; --panel: #f8fafc;
  --accent: #0f766e; --accent-soft: #ccfbf1; --code-bg: #f1f5f9; --link: #0f6cbd;
  --note: #0f6cbd; --tip: #15803d; --warn: #b45309;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f172a; --fg: #e2e8f0; --muted: #94a3b8; --line: #243244; --panel: #162033;
    --accent: #2dd4bf; --accent-soft: #134e4a; --code-bg: #1e293b; --link: #7cb7f0;
    --note: #7cb7f0; --tip: #4ade80; --warn: #fbbf24;
  }
}
* { box-sizing: border-box; }
html { scroll-padding-top: 76px; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 16px/1.65 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--link); }
.top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 16px; padding: 10px 20px; background: var(--bg); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; color: var(--fg); text-decoration: none; font-weight: 700; white-space: nowrap; }
.brand em { font-style: normal; font-weight: 400; color: var(--muted); }
.menu-btn { display: none; background: none; border: 1px solid var(--line); border-radius: 6px; font-size: 18px; padding: 4px 10px; color: var(--fg); cursor: pointer; }
.search { position: relative; flex: 1; max-width: 520px; margin-left: auto; }
.search input { width: 100%; padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); color: var(--fg); font: inherit; font-size: 14px; }
.search input:focus { outline: 2px solid var(--accent); border-color: transparent; }
.results { position: absolute; top: 100%; left: 0; right: 0; margin-top: 6px; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 10px 30px rgba(0,0,0,.18); max-height: 70vh; overflow: auto; }
.results a { display: block; padding: 10px 14px; text-decoration: none; color: var(--fg); border-bottom: 1px solid var(--line); }
.results a:last-child { border-bottom: 0; }
.results a:hover, .results a:focus { background: var(--panel); }
.results strong { display: block; font-size: 14px; }
.results span { display: block; font-size: 12.5px; color: var(--muted); line-height: 1.4; }
.results .none { padding: 12px 14px; color: var(--muted); }
.portal-link { white-space: nowrap; font-size: 14px; font-weight: 600; text-decoration: none; }
.shell { display: grid; grid-template-columns: 260px minmax(0, 1fr) 220px; max-width: 1400px; margin: 0 auto; }
.side { position: sticky; top: 57px; align-self: start; height: calc(100vh - 57px); overflow: auto; padding: 20px 12px 40px 20px; border-right: 1px solid var(--line); }
.nav-group { margin-bottom: 18px; }
.nav-title { font-size: 11.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); font-weight: 700; margin: 0 8px 6px; }
.side a { display: block; padding: 5px 10px; border-radius: 6px; color: var(--fg); text-decoration: none; font-size: 14.5px; }
.side a:hover { background: var(--panel); }
.side a.current { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.toc { position: sticky; top: 57px; align-self: start; max-height: calc(100vh - 57px); overflow: auto; padding: 24px 16px; }
.toc a { display: block; padding: 3px 8px; font-size: 13px; color: var(--muted); text-decoration: none; border-left: 2px solid var(--line); }
.toc a:hover { color: var(--fg); border-left-color: var(--accent); }
.content { padding: 28px 40px 60px; min-width: 0; }
article { max-width: 820px; }
h1 { font-size: 2rem; line-height: 1.25; margin: .2em 0 .6em; }
h2 { font-size: 1.45rem; margin: 2.2em 0 .6em; padding-bottom: .25em; border-bottom: 1px solid var(--line); }
h3 { font-size: 1.15rem; margin: 1.8em 0 .5em; }
h1 .anchor, h2 .anchor, h3 .anchor { margin-left: -1.1em; padding-right: .4em; color: var(--muted); text-decoration: none; opacity: 0; font-weight: 400; }
h2:hover .anchor, h3:hover .anchor { opacity: 1; }
p, li { max-width: 75ch; }
code { font: 0.9em ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; background: var(--code-bg); padding: .12em .38em; border-radius: 5px; }
pre { background: var(--code-bg); padding: 14px 16px; border-radius: 8px; overflow: auto; line-height: 1.5; border: 1px solid var(--line); }
pre code { background: none; padding: 0; font-size: 13px; }
.table-wrap { overflow-x: auto; margin: 1em 0; }
table { border-collapse: collapse; width: 100%; font-size: 14.5px; }
th, td { text-align: left; vertical-align: top; padding: 8px 12px; border: 1px solid var(--line); }
th { background: var(--panel); }
blockquote { margin: 1.2em 0; padding: 4px 16px; border-left: 4px solid var(--line); background: var(--panel); border-radius: 0 8px 8px 0; }
blockquote p { margin: .6em 0; }
.callout.note { border-left-color: var(--note); }
.callout.tip { border-left-color: var(--tip); }
.callout.warning { border-left-color: var(--warn); }
.callout.note strong:first-child { color: var(--note); }
.callout.tip strong:first-child { color: var(--tip); }
.callout.warning strong:first-child { color: var(--warn); }
.diagram { margin: 1.5em 0; padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); color: var(--fg); }
.diagram svg { width: 100%; height: auto; display: block; font-family: system-ui, sans-serif; font-size: 14px; }
.diagram .box { fill: var(--bg); stroke: var(--muted); }
.diagram .box-main { stroke: var(--accent); stroke-width: 2.5; fill: var(--accent-soft); }
.diagram figcaption { color: var(--muted); font-size: 13.5px; text-align: center; margin-top: 8px; }
.pager { display: flex; justify-content: space-between; gap: 16px; margin-top: 56px; max-width: 820px; }
.pager a { display: block; padding: 12px 16px; border: 1px solid var(--line); border-radius: 10px; text-decoration: none; color: var(--fg); min-width: 180px; }
.pager a:hover { border-color: var(--accent); }
.pager span { display: block; font-size: 12px; color: var(--muted); }
.pager .next { text-align: right; margin-left: auto; }
.foot { margin-top: 32px; color: var(--muted); font-size: 13px; }
@media (max-width: 1100px) { .shell { grid-template-columns: 240px minmax(0, 1fr); } .toc { display: none; } }
@media (max-width: 760px) {
  .menu-btn { display: block; }
  .portal-link { display: none; }
  .top { padding: 10px 14px; gap: 10px; }
  .brand span { display: none; }
  .shell { display: block; }
  .side { display: none; position: fixed; top: 57px; left: 0; bottom: 0; width: 82%; max-width: 320px; height: auto; background: var(--bg); z-index: 15; box-shadow: 0 0 40px rgba(0,0,0,.3); }
  .side.open { display: block; }
  .content { padding: 20px 16px 48px; }
  h1 { font-size: 1.6rem; }
  h1 .anchor, h2 .anchor, h3 .anchor { display: none; }
}
