:root {
  --bg: #f7f8fb; --surface: #ffffff; --surface-2: #eef2f8; --text: #111827; --muted: #5b6577;
  --border: #d9dfeb; --accent: #2563eb; --accent-text: #ffffff; --code-bg: #0f172a; --code-text: #e2e8f0;
  --note: #2563eb; --note-bg: #e8f0fe; --tip: #15803d; --tip-bg: #dcfce7; --warn: #b45309; --warn-bg: #fef3c7;
  --mark: #fde68a;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; --mono: ui-monospace, "SF Mono", Consolas, monospace;
  --top: 56px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1320; --surface: #161d2e; --surface-2: #1f2840; --text: #e7ebf5; --muted: #98a2b8;
    --border: #2b3550; --accent: #6b9bff; --accent-text: #0b1020; --code-bg: #0a0f1c; --code-text: #e2e8f0;
    --note: #8ab4ff; --note-bg: #16264a; --tip: #4ade80; --tip-bg: #12301f; --warn: #fbbf24; --warn-bg: #36290c;
    --mark: #6b5b12;
  }
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: calc(var(--top) + 16px); }
body { margin: 0; font: 16px/1.65 var(--font); background: var(--bg); color: var(--text); }
a { color: var(--accent); }
header.top { position: sticky; top: 0; z-index: 30; height: var(--top); display: flex; align-items: center; gap: 16px; padding: 0 20px; background: var(--surface); border-bottom: 1px solid var(--border); }
.brand { font-weight: 700; font-size: 18px; color: var(--text); text-decoration: none; white-space: nowrap; }
.brand span { color: var(--accent); }
.home { color: var(--muted); text-decoration: none; font-size: 14px; white-space: nowrap; }
button.icon { display: none; font-size: 20px; line-height: 1; background: none; border: 1px solid var(--border); color: var(--text); border-radius: 8px; padding: 6px 10px; cursor: pointer; }
.search { position: relative; flex: 1; max-width: 520px; margin-left: auto; }
.search input { width: 100%; font: inherit; font-size: 15px; color: var(--text); background: var(--bg); border: 1px solid var(--border); border-radius: 999px; padding: 7px 16px; }
.search input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.results { position: absolute; left: 0; right: 0; top: calc(100% + 8px); background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 12px 32px rgba(0,0,0,.18); max-height: 70vh; overflow: auto; }
.results a { display: block; padding: 10px 14px; text-decoration: none; color: var(--text); border-bottom: 1px solid var(--border); }
.results a:last-child { border-bottom: 0; }
.results a:hover, .results a.sel { background: var(--surface-2); }
.results .where { font-size: 12px; color: var(--muted); }
.results .t { font-weight: 600; }
.results .snip { font-size: 13.5px; color: var(--muted); line-height: 1.45; }
.results .none { padding: 14px; color: var(--muted); }
mark { background: var(--mark); color: inherit; border-radius: 3px; padding: 0 1px; }

.layout { display: grid; grid-template-columns: 290px minmax(0, 1fr); max-width: 1320px; margin: 0 auto; }
nav.side { position: sticky; top: var(--top); align-self: start; height: calc(100vh - var(--top)); overflow-y: auto; padding: 20px 12px 40px 20px; border-right: 1px solid var(--border); font-size: 14.5px; }
nav.side .grp { font-size: 11.5px; letter-spacing: .8px; text-transform: uppercase; color: var(--muted); font-weight: 700; margin: 20px 8px 6px; }
nav.side .grp:first-child { margin-top: 0; }
nav.side a.sec { display: block; padding: 5px 10px; border-radius: 8px; color: var(--text); text-decoration: none; line-height: 1.35; }
nav.side a.sec:hover { background: var(--surface-2); }
nav.side a.sec.active { background: var(--surface-2); font-weight: 600; }
nav.side .arts { margin: 2px 0 8px 14px; border-left: 2px solid var(--border); }
nav.side .arts a { display: block; padding: 3px 10px; color: var(--muted); text-decoration: none; font-size: 13.5px; line-height: 1.35; }
nav.side .arts a:hover { color: var(--text); }
nav.side .arts a.on { color: var(--accent); font-weight: 600; }

main { padding: 32px 40px 80px; max-width: 880px; min-width: 0; outline: none; }
main .crumb { color: var(--muted); font-size: 13.5px; margin: 0 0 6px; }
main h1 { font-size: 34px; line-height: 1.2; margin: 0 0 14px; letter-spacing: -.3px; }
main h2 { font-size: 24px; line-height: 1.3; margin: 48px 0 12px; padding-top: 28px; border-top: 1px solid var(--border); position: relative; }
main h2.first { border-top: 0; padding-top: 0; margin-top: 28px; }
main h3 { font-size: 18px; margin: 28px 0 8px; position: relative; }
main h4 { font-size: 15px; margin: 20px 0 6px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); }
main .anchor { position: absolute; left: -22px; top: 0; color: var(--muted); text-decoration: none; opacity: 0; font-weight: 400; }
main h2:hover .anchor, main h3:hover .anchor, main .anchor:focus { opacity: 1; }
main p, main li { overflow-wrap: anywhere; }
main li { margin: 4px 0; }
main hr { border: 0; border-top: 1px solid var(--border); margin: 28px 0; }
main img { max-width: 100%; }
code { font-family: var(--mono); font-size: .88em; background: var(--surface-2); padding: 1px 6px; border-radius: 5px; overflow-wrap: anywhere; }
.codewrap { position: relative; margin: 16px 0; }
pre { margin: 0; background: var(--code-bg); color: var(--code-text); border-radius: 10px; padding: 14px 16px; overflow-x: auto; font-size: 13.5px; line-height: 1.55; }
pre code { background: none; padding: 0; color: inherit; font-size: inherit; overflow-wrap: normal; }
.copy { position: absolute; top: 8px; right: 8px; font: 12px var(--font); color: #cbd5e1; background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.2); border-radius: 6px; padding: 3px 9px; cursor: pointer; }
.copy:hover { background: rgba(255,255,255,.2); }
.codewrap .lang { position: absolute; top: 8px; left: 14px; font: 11px var(--mono); color: #7c8aa5; text-transform: uppercase; }
.codewrap.hasLang pre { padding-top: 32px; }
.tablewrap { overflow-x: auto; margin: 16px 0; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
table { border-collapse: collapse; width: 100%; font-size: 14.5px; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); background: var(--surface-2); }
tr:last-child td { border-bottom: 0; }
blockquote { margin: 18px 0; padding: 12px 16px; border-left: 4px solid var(--note); background: var(--note-bg); border-radius: 0 10px 10px 0; }
blockquote > :first-child { margin-top: 0; } blockquote > :last-child { margin-bottom: 0; }
blockquote.tip { border-color: var(--tip); background: var(--tip-bg); }
blockquote.warn { border-color: var(--warn); background: var(--warn-bg); }
.video { margin: 20px 0 28px; }
.video .frame { position: relative; padding-top: 56.25%; border-radius: 12px; overflow: hidden; background: #000; }
.video iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.pager { display: flex; justify-content: space-between; gap: 16px; margin-top: 64px; padding-top: 24px; border-top: 1px solid var(--border); }
.pager a { flex: 1; padding: 12px 16px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); text-decoration: none; color: var(--text); }
.pager a:hover { border-color: var(--accent); }
.pager a small { display: block; color: var(--muted); font-size: 12px; }
.pager a.next { text-align: right; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; margin: 20px 0; }
.cards a { display: block; padding: 16px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); text-decoration: none; color: var(--text); }
.cards a:hover { border-color: var(--accent); }
.cards a b { display: block; margin-bottom: 4px; }
.cards a span { color: var(--muted); font-size: 14px; line-height: 1.45; display: block; }
.loading, .missing { color: var(--muted); }

@media (max-width: 900px) {
  button.icon { display: inline-block; }
  .layout { grid-template-columns: minmax(0, 1fr); }
  nav.side { position: fixed; z-index: 25; left: 0; top: var(--top); bottom: 0; width: min(320px, 88vw); height: auto; background: var(--surface); transform: translateX(-102%); transition: transform .18s; box-shadow: 0 0 40px rgba(0,0,0,.3); }
  body.navopen nav.side { transform: none; }
  body:not(.navopen) nav.side { box-shadow: none; visibility: hidden; }
  main { padding: 24px 16px 64px; }
  main h1 { font-size: 28px; }
  main .anchor { display: none; }
  .home { display: none; }
  header.top { padding: 0 12px; gap: 10px; } .search { min-width: 0; }
  .search { margin-left: 0; }
}
@media print {
  header.top, nav.side, .pager, .copy { display: none !important; }
  .layout { display: block; } main { max-width: none; padding: 0; }
  pre { white-space: pre-wrap; border: 1px solid #999; background: #fff; color: #000; }
}

@media (max-width: 480px) { .brand span { display: none; } }
td:first-child code, th code { white-space: nowrap; overflow-wrap: normal; }
