:root {
    --bg: #ffffff;
    --bg-soft: #f6f7f9;
    --bg-code: #0f1720;
    --text: #1b2430;
    --muted: #5b6675;
    --line: #e3e7ec;
    --brand: #ffb80c;
    --brand-ink: #1b2430;
    --link: #0b63c5;
    --ok: #138a4b;
    --warn: #a15c00;
    --bad: #b42318;
    --side: 270px;
    --top: 56px;
    --radius: 8px;
}
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg: #0d1218; --bg-soft: #141b23; --bg-code: #070b10; --text: #e6ebf0; --muted: #97a3b1;
        --line: #232d38; --link: #6cb2ff; --ok: #3fcf83; --warn: #f0b04a; --bad: #ff7a70;
    }
}
:root[data-theme="dark"] {
    --bg: #0d1218; --bg-soft: #141b23; --bg-code: #070b10; --text: #e6ebf0; --muted: #97a3b1;
    --line: #232d38; --link: #6cb2ff; --ok: #3fcf83; --warn: #f0b04a; --bad: #ff7a70;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: calc(var(--top) + 16px); }
body {
    margin: 0; background: var(--bg); color: var(--text);
    font: 15px/1.65 "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
code, pre, kbd { font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 13px; }
:not(pre) > code { background: var(--bg-soft); border: 1px solid var(--line); padding: 1px 5px; border-radius: 4px; word-break: break-word; }

/* top bar */
.topbar {
    position: fixed; inset: 0 0 auto 0; height: var(--top); z-index: 50; display: flex; align-items: center; gap: 12px;
    padding: 0 16px; background: #1b2430; color: #fff; border-bottom: 3px solid var(--brand);
}
.topbar .logo { display: flex; align-items: center; gap: 10px; font-weight: 800; letter-spacing: .2px; color: #fff; }
.topbar .logo span.mark { background: var(--brand); color: var(--brand-ink); border-radius: 6px; padding: 2px 8px; font-size: 13px; }
.topbar .spacer { flex: 1; }
.topbar a.btn, .topbar button { font: inherit; font-size: 13px; }
.menu-btn { display: none; background: none; border: 1px solid #4a5868; color: #fff; border-radius: 6px; padding: 4px 10px; }
.theme-btn { background: none; border: 1px solid #4a5868; color: #fff; border-radius: 6px; padding: 4px 10px; cursor: pointer; }

/* layout */
.side {
    position: fixed; top: var(--top); bottom: 0; left: 0; width: var(--side); overflow-y: auto;
    padding: 18px 14px 40px; border-right: 1px solid var(--line); background: var(--bg-soft);
}
.side h4 { margin: 18px 8px 6px; font-size: 11px; text-transform: uppercase; letter-spacing: .8px; color: var(--muted); }
.side a { display: block; padding: 5px 8px; border-radius: 6px; color: var(--text); font-size: 14px; }
.side a:hover { background: var(--line); text-decoration: none; }
.side a.active { background: var(--brand); color: var(--brand-ink); font-weight: 600; }
.side a.sub { padding-left: 20px; font-size: 13px; color: var(--muted); }
.side a.sub.active { color: var(--brand-ink); }
main { margin-left: var(--side); padding: calc(var(--top) + 24px) 40px 80px; max-width: calc(var(--side) + 980px); }
main > section { max-width: 940px; }

h1 { font-size: 34px; line-height: 1.2; margin: 8px 0 12px; }
h2 { font-size: 24px; margin: 56px 0 12px; padding-top: 8px; border-top: 1px solid var(--line); }
h3 { font-size: 18px; margin: 32px 0 8px; }
h2 .anchor, h3 .anchor { opacity: 0; margin-left: 6px; font-weight: 400; }
h2:hover .anchor, h3:hover .anchor { opacity: .5; }
p.lead { font-size: 17px; color: var(--muted); max-width: 760px; }

table { width: 100%; border-collapse: collapse; margin: 12px 0 18px; font-size: 14px; display: block; overflow-x: auto; }
th, td { border: 1px solid var(--line); padding: 7px 10px; text-align: left; vertical-align: top; }
th { background: var(--bg-soft); font-weight: 600; white-space: nowrap; }

.callout { border-left: 4px solid var(--link); background: var(--bg-soft); padding: 10px 14px; border-radius: 0 var(--radius) var(--radius) 0; margin: 14px 0; }
.callout.warn { border-color: var(--warn); }
.callout.bad { border-color: var(--bad); }
.callout.ok { border-color: var(--ok); }
.callout > :first-child { margin-top: 0; } .callout > :last-child { margin-bottom: 0; }

.badge { display: inline-block; font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 4px; vertical-align: 2px; margin-right: 6px; color: #fff; }
.badge.post { background: #138a4b; } .badge.get { background: #0b63c5; }
.endpoint { font-family: "JetBrains Mono", ui-monospace, monospace; font-size: 15px; }

/* code blocks */
.code { position: relative; margin: 12px 0 18px; border-radius: var(--radius); overflow: hidden; background: var(--bg-code); border: 1px solid #1d2733; }
.code pre { margin: 0; padding: 14px 16px; overflow-x: auto; color: #d6e2ee; line-height: 1.55; }
.code .copy {
    position: absolute; top: 8px; right: 8px; font-size: 12px; background: #243140; color: #cbd6e2; border: 0; border-radius: 5px;
    padding: 3px 9px; cursor: pointer; opacity: .85;
}
.code .copy:hover { opacity: 1; }
.tabs { margin: 12px 0 18px; }
.tabs .tab-bar { display: flex; flex-wrap: wrap; gap: 2px; background: #16202b; border-radius: var(--radius) var(--radius) 0 0; padding: 4px 4px 0; }
.tabs .tab-bar button { background: none; border: 0; color: #9fb0c2; padding: 7px 14px; font: inherit; font-size: 13px; cursor: pointer; border-radius: 6px 6px 0 0; }
.tabs .tab-bar button.on { background: var(--bg-code); color: #fff; }
.tabs .code { margin: 0; border-radius: 0 0 var(--radius) var(--radius); }
.tabs .code:not(.on) { display: none; }
.tok-c { color: #6f8396; } .tok-s { color: #9ad48f; } .tok-k { color: #ff9e64; } .tok-n { color: #e5c07b; }

.diagram { background: var(--bg-soft); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; overflow-x: auto; }
.steps { counter-reset: s; list-style: none; padding: 0; }
.steps > li { counter-increment: s; position: relative; padding: 2px 0 12px 40px; }
.steps > li::before { content: counter(s); position: absolute; left: 0; top: 0; width: 28px; height: 28px; border-radius: 50%; background: var(--brand); color: var(--brand-ink); font-weight: 800; display: grid; place-items: center; font-size: 14px; }

/* demo */
.demo { display: grid; grid-template-columns: minmax(0, 1fr) 390px; gap: 24px; align-items: start; margin-top: 16px; }
.demo .panel { background: var(--bg-soft); border: 1px solid var(--line); border-radius: 12px; padding: 18px; }
.demo .btn-demo {
    display: inline-flex; align-items: center; gap: 8px; background: var(--brand); color: var(--brand-ink); border: 0; border-radius: 8px;
    padding: 12px 22px; font: inherit; font-weight: 800; font-size: 16px; cursor: pointer; box-shadow: 0 2px 0 rgba(0,0,0,.15);
}
.demo .btn-demo[disabled] { opacity: .6; cursor: wait; }
.demo .btn-ghost { background: none; border: 1px solid var(--line); color: var(--text); border-radius: 8px; padding: 10px 14px; font: inherit; cursor: pointer; margin-left: 6px; }
.demo .facts { margin: 14px 0 0; font-size: 13px; color: var(--muted); }
.demo .facts b { color: var(--text); }
.demo .log { margin-top: 14px; height: 210px; overflow-y: auto; background: var(--bg-code); color: #cfe0f0; border-radius: 8px; padding: 10px; font: 12px/1.5 ui-monospace, monospace; }
.demo .log .t { color: #6f8396; }
.phone {
    width: 390px; height: 780px; border-radius: 34px; border: 10px solid #111820; background: #000; overflow: hidden; position: relative;
    box-shadow: 0 18px 50px rgba(0,0,0,.25);
}
.phone iframe { border: 0; width: 100%; height: 100%; }
.phone .empty { position: absolute; inset: 0; display: grid; place-items: center; color: #8796a6; text-align: center; padding: 30px; font-size: 14px; }

.hero { display: grid; grid-template-columns: 1fr; gap: 10px; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; margin: 18px 0; }
.card { border: 1px solid var(--line); border-radius: 10px; padding: 14px; background: var(--bg-soft); }
.card h4 { margin: 0 0 4px; font-size: 15px; }
.card p { margin: 0; font-size: 13.5px; color: var(--muted); }

footer { margin-top: 70px; padding-top: 16px; border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; }

@media (max-width: 1180px) { .demo { grid-template-columns: 1fr; } .phone { margin: 0 auto; } }
@media (max-width: 900px) {
    .menu-btn { display: inline-block; }
    .side { transform: translateX(-100%); transition: transform .2s; z-index: 40; width: 280px; }
    body.nav-open .side { transform: none; box-shadow: 0 0 40px rgba(0,0,0,.3); }
    main { margin-left: 0; padding: calc(var(--top) + 16px) 16px 60px; }
    h1 { font-size: 27px; }
    .phone { width: 100%; max-width: 390px; height: 720px; }
    .topbar .hide-sm { display: none; }
}
td:first-child > code { white-space: nowrap; }
