:root {
  --bg: #f4f7f6; --surface: #ffffff; --text: #0f1b1d; --muted: #4a5a5c; --line: #d3dcdc;
  --accent: #0b6b66; --on-accent: #ffffff; --soft: #e3f1ef; --code: #eef3f2; --warn: #8a5a00; --warn-bg: #fff5dc;
  --radius: 14px; --side: 280px; --top: 56px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1415; --surface: #111d1f; --text: #e8f0ef; --muted: #9db0b0; --line: #24373a;
    --accent: #4fd1c5; --on-accent: #04201e; --soft: #12302f; --code: #0f2123; --warn: #f5c76b; --warn-bg: #2a2210;
  }
}
:root[data-theme="dark"] {
  --bg: #0b1415; --surface: #111d1f; --text: #e8f0ef; --muted: #9db0b0; --line: #24373a;
  --accent: #4fd1c5; --on-accent: #04201e; --soft: #12302f; --code: #0f2123; --warn: #f5c76b; --warn-bg: #2a2210;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: calc(var(--top) + 12px); }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.65 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; -webkit-text-size-adjust: 100%; }
a { color: var(--accent); text-underline-offset: 3px; }
.skip { position: absolute; left: -999px; top: 0; background: var(--accent); color: var(--on-accent); padding: 8px 12px; z-index: 50; }
.skip:focus { left: 8px; top: 8px; }

.top { position: sticky; top: 0; z-index: 20; height: var(--top); display: flex; align-items: center; gap: 12px; padding: 0 16px; background: var(--surface); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--text); font-weight: 600; white-space: nowrap; }
.brand b { color: var(--accent); }
.mark { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; background: var(--accent); color: var(--on-accent); font-weight: 700; }
.menu, .theme { background: none; border: 1px solid var(--line); color: var(--text); border-radius: 10px; width: 40px; height: 40px; font-size: 18px; cursor: pointer; flex: none; }
.menu { display: none; }
.search { position: relative; flex: 1; max-width: 460px; margin-left: auto; }
.search input { width: 100%; height: 40px; border: 1px solid var(--line); border-radius: 999px; padding: 0 16px; background: var(--bg); color: var(--text); font: inherit; font-size: 15px; }
#res { position: absolute; top: 46px; left: 0; right: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; max-height: 70vh; overflow: auto; box-shadow: 0 12px 30px rgba(0, 0, 0, .18); }
#res a { display: block; padding: 10px 14px; text-decoration: none; color: var(--text); border-bottom: 1px solid var(--line); }
#res a:last-child { border-bottom: 0; }
#res a:hover, #res a:focus { background: var(--soft); }
#res small { display: block; color: var(--muted); font-size: 13px; line-height: 1.4; }
#res .none { padding: 12px 14px; color: var(--muted); }

.layout { display: grid; grid-template-columns: var(--side) minmax(0, 1fr); max-width: 1180px; margin: 0 auto; }
.side { position: sticky; top: var(--top); align-self: start; height: calc(100vh - var(--top)); overflow: auto; padding: 20px 12px 28px 16px; border-right: 1px solid var(--line); }
.grp { margin-bottom: 6px; }
.grp summary { cursor: pointer; font-weight: 600; padding: 8px 8px; border-radius: 8px; list-style: none; display: flex; justify-content: space-between; }
.grp summary::after { content: "▾"; color: var(--muted); }
.grp:not([open]) summary::after { content: "▸"; }
.grp ul { list-style: none; margin: 0 0 8px; padding: 0 0 0 8px; border-left: 2px solid var(--line); margin-left: 10px; }
.grp li a { display: inline-block; padding: 5px 8px; color: var(--muted); text-decoration: none; border-radius: 6px; font-size: 15px; line-height: 1.4; }
.grp li a:hover { color: var(--text); }
.grp li a[aria-current="page"] { color: var(--accent); font-weight: 600; background: var(--soft); }
.aiBox { margin-top: 16px; padding: 12px; border: 1px dashed var(--line); border-radius: var(--radius); display: grid; gap: 4px; font-size: 14px; }
.aiBox b { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }

.main { padding: 28px 32px 56px; min-width: 0; }
.crumbs { margin: 0 0 6px; color: var(--accent); font-size: 14px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; }
h1 { font-size: 2rem; line-height: 1.2; letter-spacing: -0.02em; margin: 0 0 10px; }
.lead { font-size: 1.1rem; color: var(--muted); margin: 0 0 20px; }
.tag { font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--warn-bg); color: var(--warn); vertical-align: middle; }
.tag.big { font-size: 13px; margin-left: 6px; }
.prose { max-width: 760px; }
.prose h2 { font-size: 1.45rem; margin: 2.2em 0 .5em; line-height: 1.3; padding-top: .4em; border-top: 1px solid var(--line); }
.prose h3 { font-size: 1.15rem; margin: 1.8em 0 .4em; }
.prose h4 { font-size: 1rem; margin: 1.4em 0 .3em; }
.anchor { opacity: 0; font-weight: 400; text-decoration: none; margin-left: 4px; }
h2:hover .anchor, h3:hover .anchor, h4:hover .anchor, .anchor:focus { opacity: .6; }
.prose p, .prose li { overflow-wrap: anywhere; }
.prose ul, .prose ol { padding-left: 1.4em; }
.prose li { margin: .25em 0; }
code { background: var(--code); padding: .1em .35em; border-radius: 6px; font: .9em ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
pre { position: relative; background: var(--code); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; overflow-x: auto; line-height: 1.5; }
pre code { background: none; padding: 0; font-size: 14px; }
.copy { position: absolute; top: 8px; right: 8px; font: 12px system-ui; border: 1px solid var(--line); background: var(--surface); color: var(--text); border-radius: 8px; padding: 3px 9px; cursor: pointer; }
blockquote { margin: 1.2em 0; padding: 12px 16px; border-left: 4px solid var(--accent); background: var(--soft); border-radius: 0 12px 12px 0; }
blockquote p { margin: .3em 0; }
.tbl { overflow-x: auto; margin: 1.2em 0; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
table { border-collapse: collapse; width: 100%; font-size: 15px; min-width: 460px; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { background: var(--soft); font-weight: 600; }
tr:last-child td { border-bottom: 0; }
img { max-width: 100%; height: auto; }
.toc { margin: 0 0 24px; padding: 12px 16px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); max-width: 760px; font-size: 15px; }
.toc ul { list-style: none; margin: 6px 0 0; padding: 0; columns: 2; column-gap: 24px; }
.toc li { break-inside: avoid; padding: 2px 0; }
.toc .l3 { padding-left: 14px; font-size: 14px; }
.toc a { text-decoration: none; }
.pn { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; max-width: 760px; margin-top: 40px; }
.pn a { display: block; padding: 12px 16px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); text-decoration: none; color: var(--text); font-weight: 600; }
.pn a small { display: block; color: var(--muted); font-weight: 400; font-size: 13px; }
.pn .next { text-align: right; }
.pn a:hover { border-color: var(--accent); }
.foot { max-width: 760px; margin-top: 32px; padding-top: 16px; border-top: 1px solid var(--line); color: var(--muted); font-size: 14px; }

@media (max-width: 860px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .menu { display: inline-block; }
  .side { position: fixed; inset: var(--top) 0 0 0; z-index: 15; height: auto; background: var(--bg); transform: translateX(-102%); transition: transform .2s; border-right: 0; width: min(88vw, 340px); border-right: 1px solid var(--line); }
  .side.open { transform: none; }
  .main { padding: 20px 16px 48px; }
  h1 { font-size: 1.6rem; }
  .brand span:last-child { display: none; }
  .toc ul { columns: 1; }
  .pn { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } .side { transition: none; } }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
