:root {
  --bg: #0f1012;
  --bg2: #16181b;
  --bg3: #1d2024;
  --line: #2a2e34;
  --text: #e6e3de;
  --dim: #9a9690;
  --accent: #e0553c;
  --accent2: #f0a24a;
  --code-bg: #121417;
  --kw: #e07a5f;
  --str: #9fcf7a;
  --num: #e8b765;
  --com: #6f7680;
  --fn: #79b8ff;
  --key: #c7a4ff;
  --host: #e0553c;
  --both: #4fae7e;
  --mono: ui-monospace, "Cascadia Code", "JetBrains Mono", Consolas, "SF Mono", Menlo, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f7f5f1; --bg2: #ffffff; --bg3: #efebe5; --line: #ddd7ce; --text: #1e1d1b; --dim: #6b665f;
    --accent: #c4402a; --accent2: #b86a12; --code-bg: #f1eee8; --kw: #b5432a; --str: #3d7a22; --num: #9a5b00;
    --com: #8b8780; --fn: #1f5fbf; --key: #7a3fc4; --host: #c4402a; --both: #2e8a5a;
    color-scheme: light;
  }
}
* { box-sizing: border-box; }
html { scroll-padding-top: 76px; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.65 var(--sans); }
a { color: var(--accent2); text-decoration: none; }
a:hover { text-decoration: underline; }
code, kbd { font-family: var(--mono); font-size: 0.88em; }
:not(pre) > code { background: var(--bg3); padding: 0.08em 0.38em; border-radius: 4px; overflow-wrap: anywhere; }
kbd { background: var(--bg3); border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; padding: 0 0.4em; }

.top {
  position: sticky; top: 0; z-index: 20; height: 58px; display: flex; align-items: center; gap: 14px;
  padding: 0 18px; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); white-space: nowrap; }
.brand:hover { text-decoration: none; }
.mark { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 8px; background: var(--accent); color: #fff; font-weight: 900; font-size: 13px; letter-spacing: -0.5px; }
.brand-text { font-size: 15px; }
.brand-text b { color: var(--accent2); font-weight: 700; }
.menu { display: none; background: none; border: 0; color: var(--text); font-size: 20px; cursor: pointer; padding: 4px 6px; }
.search { position: relative; flex: 1; max-width: 520px; margin-left: auto; }
.search input {
  width: 100%; height: 36px; padding: 0 12px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--bg2); color: var(--text); font: inherit; outline: none;
}
.search input:focus { border-color: var(--accent2); }
.results {
  position: absolute; top: 42px; left: 0; right: 0; max-height: 60vh; overflow: auto; background: var(--bg2);
  border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 12px 40px rgba(0,0,0,0.35); padding: 6px;
}
.results a { display: flex; justify-content: space-between; gap: 12px; padding: 7px 10px; border-radius: 6px; color: var(--text); }
.results a span { color: var(--dim); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.results a.sel, .results a:hover { background: var(--bg3); text-decoration: none; }
.results p { margin: 8px 10px; color: var(--dim); }
.langs { display: flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.langs button { background: none; border: 0; color: var(--dim); padding: 6px 10px; font: inherit; font-size: 13px; cursor: pointer; }
.langs button.on { background: var(--bg3); color: var(--text); }

.layout { display: grid; grid-template-columns: 260px minmax(0, 1fr); }
.side {
  position: sticky; top: 58px; height: calc(100vh - 58px); overflow-y: auto; padding: 20px 14px 40px;
  border-right: 1px solid var(--line); font-size: 14px;
}
.side .grp { margin-bottom: 18px; }
.side .grp > p { margin: 0 8px 6px; color: var(--dim); font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; }
.side a { display: block; padding: 4px 10px; border-radius: 6px; color: var(--text); }
.side a:hover { background: var(--bg3); text-decoration: none; }
.side a.on { background: var(--bg3); color: var(--accent2); }
.side details { margin: 1px 0; }
.side summary { cursor: pointer; padding: 4px 10px; border-radius: 6px; list-style: none; }
.side summary::-webkit-details-marker { display: none; }
.side summary::before { content: "▸"; display: inline-block; width: 14px; color: var(--dim); transition: transform 0.15s; }
.side details[open] summary::before { transform: rotate(90deg); }
.side summary:hover { background: var(--bg3); }
.side .fnl { padding: 2px 10px 2px 32px; font-family: var(--mono); font-size: 13px; color: var(--dim); }
.side .fnl.on { color: var(--accent2); }

main { min-width: 0; }
.page { max-width: 920px; padding: 34px 40px 120px; }
h1 { font-size: 30px; line-height: 1.25; margin: 0 0 16px; }
h2 { font-size: 22px; margin: 40px 0 12px; padding-top: 6px; }
h3 { font-size: 17px; margin: 24px 0 8px; }
p, li { color: var(--text); }
.intro { color: var(--dim); }

.hero { padding: 26px 0 10px; }
.eyebrow { color: var(--accent2); font-family: var(--mono); font-size: 13px; margin: 0 0 10px; }
.hero h1 { font-size: 40px; letter-spacing: -0.5px; }
.lead { font-size: 17px; color: var(--dim); max-width: 720px; }
.cta { display: flex; flex-wrap: wrap; gap: 10px; margin: 24px 0 8px; }
.btn {
  display: inline-flex; align-items: center; height: 38px; padding: 0 16px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--bg2); color: var(--text); font-weight: 600; white-space: nowrap;
}
.btn:hover { text-decoration: none; border-color: var(--dim); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; margin-top: 28px; }
.card { display: block; padding: 16px 18px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg2); color: var(--text); }
.card:hover { text-decoration: none; border-color: var(--accent2); }
.card h3 { margin: 0 0 4px; }
.card p { margin: 0; color: var(--dim); font-size: 14px; }

table { width: 100%; border-collapse: collapse; margin: 12px 0 18px; font-size: 14px; display: block; overflow-x: auto; }
table tbody { display: table; width: 100%; }
th, td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--dim); font-weight: 600; font-size: 13px; white-space: nowrap; }
td code { white-space: nowrap; }
.events td:nth-child(3) code, .events td:nth-child(3) { white-space: normal; }

.code { position: relative; margin: 12px 0 16px; }
.code pre { margin: 0; padding: 14px 16px; background: var(--code-bg); border: 1px solid var(--line); border-radius: 10px; overflow-x: auto; font-size: 13.5px; line-height: 1.55; }
.code pre code { font-size: inherit; }
.copy {
  position: absolute; top: 8px; right: 8px; padding: 3px 9px; font-size: 12px; border-radius: 6px; border: 1px solid var(--line);
  background: var(--bg2); color: var(--dim); cursor: pointer; opacity: 0; transition: opacity 0.15s;
}
.code:hover .copy, .copy:focus { opacity: 1; }
.kw { color: var(--kw); }
.s { color: var(--str); }
.n { color: var(--num); }
.c { color: var(--com); font-style: italic; }
.k { color: var(--key); }
a.fn { color: var(--fn); }

.toc { display: flex; flex-wrap: wrap; gap: 6px; margin: 16px 0 6px; }
.toc a { padding: 3px 10px; border: 1px solid var(--line); border-radius: 99px; font-size: 13px; color: var(--text); }
.toc a:hover { border-color: var(--accent2); text-decoration: none; }

.api-sec h2 { border-bottom: 1px solid var(--line); padding-bottom: 8px; }
.fn-card { border: 1px solid var(--line); border-radius: 12px; background: var(--bg2); padding: 14px 18px 6px; margin: 14px 0; transition: border-color 0.4s, box-shadow 0.4s; }
.fn-card header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.fn-card h3 { margin: 0; font-family: var(--mono); font-size: 15px; font-weight: 600; overflow-wrap: anywhere; }
.fn-card h3 a { color: var(--text); }
.fn-card .ret { margin: 4px 0 6px; font-size: 13px; color: var(--dim); }
.fn-card .ret span { text-transform: uppercase; font-size: 11px; letter-spacing: 0.06em; }
.fn-card > p { margin: 8px 0; }
.params td:first-child { width: 1%; }
.ty { color: var(--fn); background: none !important; }
.flash { border-color: var(--accent2) !important; box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent2) 25%, transparent); }
tr.flash td { background: color-mix(in srgb, var(--accent2) 12%, transparent); }

.tag { display: inline-block; font-size: 11.5px; font-weight: 600; padding: 2px 8px; border-radius: 99px; white-space: nowrap; border: 1px solid; }
.tag.host { color: var(--host); border-color: color-mix(in srgb, var(--host) 45%, transparent); }
.tag.both { color: var(--both); border-color: color-mix(in srgb, var(--both) 45%, transparent); }

.filter { width: 100%; max-width: 360px; height: 36px; padding: 0 12px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg2); color: var(--text); font: inherit; margin: 6px 0 4px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 14px; }
.chips code { padding: 3px 8px !important; }

.ex { border: 1px solid var(--line); border-radius: 12px; background: var(--bg2); padding: 16px 18px; margin: 18px 0; }
.ex > header { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; }
.ex h2 { margin: 0 0 4px; font-size: 19px; }
.ex header p { margin: 0; color: var(--dim); font-size: 14px; }
.ex .files { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; }
.file { font-family: var(--mono); font-size: 12.5px; padding: 3px 9px; border-radius: 6px; border: 1px solid var(--line); background: var(--bg3); color: var(--text); cursor: pointer; }
.file:hover { border-color: var(--accent2); }
.file.on { border-color: var(--accent2); color: var(--accent2); }
.file.bin { cursor: default; color: var(--dim); background: none; }
.viewer .path { margin: 14px 0 0; font-family: var(--mono); font-size: 13px; color: var(--dim); }

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .menu { display: block; }
  .side { position: fixed; top: 58px; left: 0; width: 280px; z-index: 15; background: var(--bg); transform: translateX(-100%); transition: transform 0.2s; }
  body.nav-open .side { transform: none; box-shadow: 10px 0 40px rgba(0,0,0,0.4); }
  .page { padding: 24px 16px 100px; }
  .brand-text { display: none; }
  .hero h1 { font-size: 30px; }
  .ex > header { flex-direction: column; }
  .copy { opacity: 1; }
}
@media (max-width: 480px) {
  .top { gap: 8px; padding: 0 10px; }
  .langs button { padding: 6px 7px; }
}
