:root {
    --bg: #0b1020;
    --panel: #ffffff;
    --ink: #1f2430;
    --muted: #6b7280;
    --border: #e5e7eb;
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --accent: #10b981;
    --code-bg: #0f172a;
    --code-ink: #e2e8f0;
}
* { box-sizing: border-box; }
body { margin: 0; color: var(--ink); background: #f6f7fb;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

.topbar { display: flex; align-items: center; justify-content: space-between;
    padding: 14px 28px; background: #fff; border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 5; }
.topbar .brand { font-weight: 800; font-size: 20px; }
.topbar .brand span { color: var(--primary); }
.topbar nav { display: flex; align-items: center; }
.topbar nav a { margin-left: 20px; color: var(--ink); font-weight: 500; font-size: 14px; }
.topbar nav a:hover { color: var(--primary); text-decoration: none; }
.lang { margin-left: 20px; display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.lang button { border: none; background: #fff; color: var(--muted); font-weight: 700; font-size: 12px;
    padding: 6px 10px; cursor: pointer; }
.lang button.active { background: var(--primary); color: #fff; }

/* Hamburger — hidden on desktop, shown on mobile. */
.nav-toggle { display: none; width: 42px; height: 34px; flex-direction: column; justify-content: center;
    align-items: center; gap: 5px; background: none; border: none; cursor: pointer; padding: 0; }
.nav-toggle span { display: block; width: 24px; height: 2px; background: #1f2430; border-radius: 2px; transition: .2s; }
.nav-toggle[aria-expanded="true"] span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-toggle[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.nav-toggle[aria-expanded="true"] span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

.hero { background: linear-gradient(135deg, #111827, #1e3a8a); color: #fff; padding: 56px 28px 44px; text-align: center; }
.hero h1 { margin: 0 0 12px; font-size: 34px; letter-spacing: -0.02em; }
.hero p { margin: 0 auto 24px; max-width: 640px; color: #cbd5e1; font-size: 16px; line-height: 1.6; }
.baseurl { display: inline-flex; align-items: center; gap: 10px; background: rgba(255,255,255,.08);
    border: 1px solid rgba(255,255,255,.18); border-radius: 10px; padding: 8px 10px 8px 14px; }
.baseurl span { color: #94a3b8; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; }
.baseurl code { color: #fff; font-size: 15px; }

.container { max-width: 940px; margin: -28px auto 48px; padding: 0 24px; }
.card { background: var(--panel); border: 1px solid var(--border); border-radius: 14px;
    padding: 24px 24px 26px; margin-bottom: 22px; box-shadow: 0 6px 24px rgba(15,23,42,.05); }
.card h2 { margin: 0 0 6px; font-size: 20px; }
.muted { color: var(--muted); font-size: 14px; }

/* live demo */
.demo-controls { display: flex; gap: 16px; flex-wrap: wrap; margin: 14px 0; }
.demo-controls label { display: flex; flex-direction: column; gap: 6px; font-size: 13px;
    color: var(--muted); font-weight: 600; flex: 1; min-width: 200px; }
.demo-controls select { padding: 10px 12px; border: 1px solid var(--border); border-radius: 9px;
    font-size: 14px; background: #fff; color: var(--ink); }
pre.json { background: var(--code-bg); color: var(--code-ink); border-radius: 10px; padding: 16px;
    overflow: auto; font-size: 13px; line-height: 1.5; max-height: 320px; margin: 0; }

/* tabs */
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin: 14px 0 12px; border-bottom: 1px solid var(--border); }
.tab { background: none; border: none; padding: 9px 14px; font-size: 14px; font-weight: 600;
    color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; }
.tab:hover { color: var(--ink); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.tabpane { display: none; }
.tabpane.active { display: block; }

/* code snippets */
.snippet { position: relative; }
.snippet pre { background: var(--code-bg); color: var(--code-ink); border-radius: 10px;
    padding: 18px; overflow: auto; font-size: 13px; line-height: 1.55; margin: 0; }
.snippet .copy, .baseurl .copy { position: absolute; top: 10px; right: 10px; }
.copy { background: rgba(255,255,255,.12); color: #fff; border: 1px solid rgba(255,255,255,.25);
    border-radius: 7px; padding: 5px 10px; font-size: 12px; cursor: pointer; font-weight: 600; }
.baseurl .copy { position: static; }
.copy:hover { background: rgba(255,255,255,.24); }
.copy.done { background: var(--accent); border-color: var(--accent); }

/* endpoints */
table.endpoints { width: 100%; border-collapse: collapse; margin-top: 8px; }
table.endpoints td { padding: 9px 8px; border-bottom: 1px solid var(--border); font-size: 14px; vertical-align: top; }
table.endpoints td:first-child { white-space: nowrap; }
.method { display: inline-block; background: #ecfdf5; color: #047857; font-weight: 700; font-size: 11px;
    padding: 2px 7px; border-radius: 5px; margin-right: 6px; }
table.endpoints code { background: #f1f5f9; padding: 1px 6px; border-radius: 5px; font-size: 13px; }

/* downloads */
.downloads { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; margin: 14px 0; }
.dl { display: flex; flex-direction: column; gap: 3px; padding: 14px 16px; border: 1px solid var(--border);
    border-radius: 11px; background: #fff; transition: all .15s; }
.dl:hover { border-color: var(--primary); text-decoration: none; box-shadow: 0 4px 14px rgba(37,99,235,.12); }
.dl strong { color: var(--primary); font-size: 15px; }
.dl span { color: var(--muted); font-size: 12px; }

footer { text-align: center; color: var(--muted); font-size: 13px; padding: 28px; border-top: 1px solid var(--border); background: #fff; }

.table-scroll { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* ---------- Mobile ---------- */
@media (max-width: 760px) {
    /* Clip at the root so no wide child (code blocks, tables) can push the page
       wider than the viewport and shove the sticky top bar's hamburger off-screen. */
    html, body { overflow-x: clip; max-width: 100%; }
    .hero h1, .hero p { overflow-wrap: break-word; max-width: 100%; }
    .container, .card, .snippet, .tabpane, .demo, .baseurl { min-width: 0; max-width: 100%; }
    /* Wrap code on mobile (no intrinsic width to blow out the layout viewport). */
    .snippet pre, pre.json { max-width: 100%; white-space: pre-wrap; word-break: break-word; overflow-wrap: anywhere; }
    .tabs { flex-wrap: wrap; }

    /* Brand left, hamburger right; nav drops down below the bar when opened. */
    .topbar { justify-content: space-between; padding: 12px 16px; }
    .nav-toggle { display: flex; }
    .topbar nav { display: none; position: absolute; top: 100%; left: 0; right: 0;
        flex-direction: column; align-items: stretch; gap: 0; background: #fff;
        border-bottom: 1px solid var(--border); padding: 6px 16px 14px;
        box-shadow: 0 10px 24px rgba(15,23,42,.10); }
    .topbar nav.open { display: flex; }
    .topbar nav a { margin-left: 0; padding: 12px 2px; border-bottom: 1px solid var(--border); font-size: 15px; }
    .lang { margin: 12px 0 2px; align-self: flex-start; }
    .lang button { padding: 8px 16px; font-size: 13px; }

    .hero { padding: 40px 18px 30px; }
    .hero h1 { font-size: 23px; }
    .hero p { font-size: 15px; }
    .baseurl { flex-wrap: wrap; max-width: 100%; }
    .baseurl code { font-size: 13px; word-break: break-all; }

    .container { margin: -20px auto 36px; padding: 0 14px; }
    .card { padding: 18px 15px; border-radius: 12px; }
    .card h2 { font-size: 18px; }

    .demo-controls { flex-direction: column; gap: 12px; }
    .demo-controls label { min-width: 0; }

    .tabs { gap: 2px; }
    .tab { padding: 8px 10px; font-size: 13px; }
    .snippet pre, pre.json { font-size: 12px; padding: 14px; }

    /* Let the endpoints table wrap instead of forcing 520px (which would expand the
       whole layout viewport and push the sticky top bar off-screen). */
    table.endpoints { min-width: 0; }
    table.endpoints td:first-child { white-space: normal; overflow-wrap: anywhere; }
    .downloads { grid-template-columns: 1fr; }
}

@media (max-width: 400px) {
    .hero h1 { font-size: 22px; }
    .topbar .brand { font-size: 18px; }
}
