
:root {
  --bg: #f7f7f8;
  --panel: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --line: #e5e7eb;
  --accent: #2563eb;
  --accent-soft: #dbeafe;
  --sidebar-bg: #111827;
  --sidebar-text: #e5e7eb;
  --sidebar-muted: #9ca3af;
  --codebar: #f3f4f6;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; background: var(--bg); color: var(--text); line-height: 1.65; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.layout { display: grid; grid-template-columns: 320px minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; overflow: auto; background: var(--sidebar-bg); color: var(--sidebar-text); padding: 20px 16px 24px; border-right: 1px solid #030712; }
.brand { margin-bottom: 16px; padding-bottom: 14px; border-bottom: 1px solid rgba(255,255,255,.1); }
.brand-title { font-weight: 750; font-size: 1.05rem; }
.brand-sub { color: var(--sidebar-muted); font-size: .88rem; margin-top: 2px; }
.toc-search { width: 100%; border: 1px solid rgba(255,255,255,.15); background: rgba(255,255,255,.08); color: white; border-radius: 10px; padding: 10px 12px; margin: 0 0 14px; outline: none; }
.toc-search::placeholder { color: var(--sidebar-muted); }
.sidebar-nav { display: flex; flex-direction: column; gap: 2px; }
.sidebar-nav a { color: var(--sidebar-text); border-radius: 8px; padding: 7px 9px; font-size: .92rem; line-height: 1.25; text-decoration: none; }
.sidebar-nav a:hover { background: rgba(255,255,255,.08); }
.sidebar-nav a.current { background: rgba(37,99,235,.55); color: white; font-weight: 650; }
.toc-divider { height: 1px; background: rgba(255,255,255,.12); margin: 14px 0; }
.sidebar-nav .toc-l0 { font-weight: 700; margin-top: 6px; }
.sidebar-nav .toc-l1 { padding-left: 18px; font-size: .88rem; color: #d1d5db; }
.sidebar-nav .toc-l2 { padding-left: 30px; font-size: .84rem; color: #cbd5e1; }
.content-wrap { min-width: 0; }
.topbar { display: none; position: sticky; top: 0; z-index: 10; background: var(--panel); border-bottom: 1px solid var(--line); padding: 10px 16px; }
.menu-btn { border: 1px solid var(--line); background: white; border-radius: 8px; padding: 8px 10px; }
.content { max-width: 1100px; margin: 0 auto; padding: 42px 48px 80px; background: var(--panel); min-height: 100vh; box-shadow: 0 0 0 1px var(--line); }
h1, h2, h3, h4, h5, h6 { line-height: 1.25; margin-top: 2.1em; margin-bottom: .65em; scroll-margin-top: 24px; }
h1 { font-size: 2.25rem; margin-top: 0; border-bottom: 1px solid var(--line); padding-bottom: .35em; }
h2 { font-size: 1.65rem; border-bottom: 1px solid var(--line); padding-bottom: .25em; }
h3 { font-size: 1.28rem; }
h4 { font-size: 1.08rem; }
p { margin: .85em 0; }
ul, ol { padding-left: 1.45rem; }
li { margin: .25em 0; }
blockquote { margin: 1rem 0; border-left: 4px solid var(--accent); padding: .2rem 1rem; background: #f8fafc; color: #334155; }
hr { border: 0; border-top: 1px solid var(--line); margin: 2rem 0; }
table { width: 100%; border-collapse: collapse; margin: 1.2rem 0; font-size: .95rem; display: block; overflow-x: auto; }
th, td { border: 1px solid var(--line); padding: 8px 10px; vertical-align: top; }
th { background: #f9fafb; font-weight: 700; }
code:not(.highlight code) { background: #f3f4f6; border: 1px solid #e5e7eb; padding: .12rem .32rem; border-radius: 5px; font-size: .92em; }
.anchor { opacity: 0; margin-right: .35rem; color: #9ca3af; }
h1:hover .anchor, h2:hover .anchor, h3:hover .anchor, h4:hover .anchor { opacity: 1; }
.codeblock { margin: 1.1rem 0; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: #fff; }
.codebar { display: flex; justify-content: space-between; align-items: center; gap: 12px; background: var(--codebar); border-bottom: 1px solid var(--line); color: var(--muted); font-size: .82rem; padding: 6px 10px; }
.copy-btn { border: 1px solid #d1d5db; background: white; border-radius: 7px; padding: 4px 8px; color: #374151; cursor: pointer; font-size: .78rem; }
.copy-btn:hover { background: #f9fafb; }
.codebody { overflow-x: auto; }
.highlight { margin: 0; background: #fff; }
.highlight pre { margin: 0; padding: 14px 16px; overflow-x: auto; font-size: .9rem; line-height: 1.55; }
.chapter-nav { display: flex; justify-content: space-between; gap: 12px; margin-top: 3rem; padding-top: 1rem; border-top: 1px solid var(--line); }
.chapter-nav a { display: inline-block; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: #f9fafb; }
.footer-note { color: var(--muted); font-size: .86rem; margin-top: 2rem; }
pre { line-height: 125%; }
td.linenos .normal { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; }
span.linenos { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; }
td.linenos .special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }
span.linenos.special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }
.highlight .hll { background-color: #ffffcc }
.highlight { background: #f8f8f8; }
.highlight .c { color: #3D7B7B; font-style: italic } /* Comment */
.highlight .err { border: 1px solid #F00 } /* Error */
.highlight .k { color: #008000; font-weight: bold } /* Keyword */
.highlight .o { color: #666 } /* Operator */
.highlight .ch { color: #3D7B7B; font-style: italic } /* Comment.Hashbang */
.highlight .cm { color: #3D7B7B; font-style: italic } /* Comment.Multiline */
.highlight .cp { color: #9C6500 } /* Comment.Preproc */
.highlight .cpf { color: #3D7B7B; font-style: italic } /* Comment.PreprocFile */
.highlight .c1 { color: #3D7B7B; font-style: italic } /* Comment.Single */
.highlight .cs { color: #3D7B7B; font-style: italic } /* Comment.Special */
.highlight .gd { color: #A00000 } /* Generic.Deleted */
.highlight .ge { font-style: italic } /* Generic.Emph */
.highlight .ges { font-weight: bold; font-style: italic } /* Generic.EmphStrong */
.highlight .gr { color: #E40000 } /* Generic.Error */
.highlight .gh { color: #000080; font-weight: bold } /* Generic.Heading */
.highlight .gi { color: #008400 } /* Generic.Inserted */
.highlight .go { color: #717171 } /* Generic.Output */
.highlight .gp { color: #000080; font-weight: bold } /* Generic.Prompt */
.highlight .gs { font-weight: bold } /* Generic.Strong */
.highlight .gu { color: #800080; font-weight: bold } /* Generic.Subheading */
.highlight .gt { color: #04D } /* Generic.Traceback */
.highlight .kc { color: #008000; font-weight: bold } /* Keyword.Constant */
.highlight .kd { color: #008000; font-weight: bold } /* Keyword.Declaration */
.highlight .kn { color: #008000; font-weight: bold } /* Keyword.Namespace */
.highlight .kp { color: #008000 } /* Keyword.Pseudo */
.highlight .kr { color: #008000; font-weight: bold } /* Keyword.Reserved */
.highlight .kt { color: #B00040 } /* Keyword.Type */
.highlight .m { color: #666 } /* Literal.Number */
.highlight .s { color: #BA2121 } /* Literal.String */
.highlight .na { color: #687822 } /* Name.Attribute */
.highlight .nb { color: #008000 } /* Name.Builtin */
.highlight .nc { color: #00F; font-weight: bold } /* Name.Class */
.highlight .no { color: #800 } /* Name.Constant */
.highlight .nd { color: #A2F } /* Name.Decorator */
.highlight .ni { color: #717171; font-weight: bold } /* Name.Entity */
.highlight .ne { color: #CB3F38; font-weight: bold } /* Name.Exception */
.highlight .nf { color: #00F } /* Name.Function */
.highlight .nl { color: #767600 } /* Name.Label */
.highlight .nn { color: #00F; font-weight: bold } /* Name.Namespace */
.highlight .nt { color: #008000; font-weight: bold } /* Name.Tag */
.highlight .nv { color: #19177C } /* Name.Variable */
.highlight .ow { color: #A2F; font-weight: bold } /* Operator.Word */
.highlight .w { color: #BBB } /* Text.Whitespace */
.highlight .mb { color: #666 } /* Literal.Number.Bin */
.highlight .mf { color: #666 } /* Literal.Number.Float */
.highlight .mh { color: #666 } /* Literal.Number.Hex */
.highlight .mi { color: #666 } /* Literal.Number.Integer */
.highlight .mo { color: #666 } /* Literal.Number.Oct */
.highlight .sa { color: #BA2121 } /* Literal.String.Affix */
.highlight .sb { color: #BA2121 } /* Literal.String.Backtick */
.highlight .sc { color: #BA2121 } /* Literal.String.Char */
.highlight .dl { color: #BA2121 } /* Literal.String.Delimiter */
.highlight .sd { color: #BA2121; font-style: italic } /* Literal.String.Doc */
.highlight .s2 { color: #BA2121 } /* Literal.String.Double */
.highlight .se { color: #AA5D1F; font-weight: bold } /* Literal.String.Escape */
.highlight .sh { color: #BA2121 } /* Literal.String.Heredoc */
.highlight .si { color: #A45A77; font-weight: bold } /* Literal.String.Interpol */
.highlight .sx { color: #008000 } /* Literal.String.Other */
.highlight .sr { color: #A45A77 } /* Literal.String.Regex */
.highlight .s1 { color: #BA2121 } /* Literal.String.Single */
.highlight .ss { color: #19177C } /* Literal.String.Symbol */
.highlight .bp { color: #008000 } /* Name.Builtin.Pseudo */
.highlight .fm { color: #00F } /* Name.Function.Magic */
.highlight .vc { color: #19177C } /* Name.Variable.Class */
.highlight .vg { color: #19177C } /* Name.Variable.Global */
.highlight .vi { color: #19177C } /* Name.Variable.Instance */
.highlight .vm { color: #19177C } /* Name.Variable.Magic */
.highlight .il { color: #666 } /* Literal.Number.Integer.Long */
@media (max-width: 900px) {
  .layout { display: block; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 320px; transform: translateX(-100%); transition: transform .2s ease; z-index: 20; }
  body.sidebar-open .sidebar { transform: translateX(0); }
  .topbar { display: block; }
  .content { padding: 28px 20px 60px; box-shadow: none; }
}
