:root {
    --accent: #f97316;
    --accent-dark: #c2410c;
    --bg: #ffffff;
    --bg-sidebar: #0f172a;
    --bg-sidebar-active: #1e293b;
    --text: #0f172a;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --code-bg: #0f172a;
    --code-text: #e2e8f0;
    --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    --font-mono: 'SF Mono', Menlo, Consolas, 'Liberation Mono', monospace;
}
* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: var(--font-sans);
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
a:focus-visible, button:focus-visible, input:focus-visible,
label.page-link:focus-within, .tab-buttons label:focus-within {
    outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px;
}

header.topbar {
    position: sticky; top: 0; z-index: 20;
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 24px;
    background: var(--bg-sidebar);
    border-bottom: 1px solid #1e293b;
}
header.topbar .brand { color: #fff; font-weight: 700; font-size: 15px; letter-spacing: 0.2px; }
header.topbar .brand span { color: var(--accent); }
header.topbar nav a { color: #cbd5e1; font-size: 13px; margin-left: 18px; }
header.topbar nav a:hover { color: #fff; text-decoration: none; }

/* Mobile sidebar toggle — a checkbox-hack, same no-JS philosophy as
   the tab groups below. #sidebar-toggle sits right before .shell so
   the ~ combinator can reach aside.sidebar from it; the <label
   for="sidebar-toggle"> that flips it lives in the header instead,
   which works regardless of DOM position since label/for is global. */
#sidebar-toggle { position: absolute; opacity: 0; width: 1px; height: 1px; overflow: hidden; }
.sidebar-toggle-btn { display: none; cursor: pointer; color: #cbd5e1; padding: 4px; }
.sidebar-toggle-btn svg { display: block; }

.shell { display: flex; min-height: calc(100vh - 53px); }

aside.sidebar {
    width: 260px; flex-shrink: 0;
    background: var(--bg-sidebar);
    color: #cbd5e1;
    padding: 24px 0;
    overflow-y: auto;
}
aside.sidebar .section-title {
    padding: 8px 24px;
    font-size: 11px; font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.6px; color: #64748b;
}
aside.sidebar a.page-link {
    display: block;
    padding: 7px 24px;
    font-size: 13.5px;
    color: #cbd5e1;
    border-left: 2px solid transparent;
}
aside.sidebar a.page-link:hover { color: #fff; text-decoration: none; background: var(--bg-sidebar-active); }
aside.sidebar a.page-link.active {
    color: #fff; font-weight: 600;
    background: var(--bg-sidebar-active);
    border-left-color: var(--accent);
}

main.content {
    flex: 1; min-width: 0;
    padding: 40px 48px;
    max-width: 1180px;
}
main.content h1, main.content h2, main.content h3 { scroll-margin-top: 76px; }
main.content h1 { font-size: 30px; margin: 0 0 6px; font-weight: 800; }
main.content h2 { font-size: 22px; margin: 36px 0 12px; border-bottom: 1px solid var(--border); padding-bottom: 8px; font-weight: 700; }
main.content h3 { font-size: 17px; margin: 28px 0 10px; font-weight: 700; }
main.content p { line-height: 1.7; color: #1e293b; }
main.content .eyebrow { color: var(--text-muted); font-size: 13px; margin-bottom: 18px; }

main.content table {
    width: 100%; border-collapse: collapse; margin: 16px 0 24px; font-size: 13.5px;
}
main.content table th, main.content table td {
    border: 1px solid var(--border); padding: 8px 12px; text-align: left;
}
main.content table th { background: #f8fafc; font-weight: 600; }
main.content code {
    background: #f1f5f9; color: #be123c; padding: 2px 5px; border-radius: 4px;
    font-size: 0.88em; font-family: var(--font-mono);
}

/* Code block: a slim header bar (language label + copy button) on
   top of the existing dark panel, rather than a redesign of it —
   highlightCodeBlocks() below adds .code-block-wrap/.code-block-bar
   around each <pre> found in main.content. */
.code-block-wrap { margin: 16px 0 24px; border-radius: 10px; overflow: hidden; background: var(--code-bg); }
.doc-row .code-block-wrap, .tab-panels .code-block-wrap { margin: 0; }
.code-block-bar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 8px 14px; background: rgba(255,255,255,0.04);
    border-bottom: 1px solid rgba(255,255,255,0.08);
}
.code-block-lang { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; color: #94a3b8; }
.code-block-copy {
    font-size: 11.5px; font-weight: 600; color: #cbd5e1; background: rgba(255,255,255,0.07);
    border: none; border-radius: 5px; padding: 4px 10px; cursor: pointer;
    display: flex; align-items: center; gap: 5px; transition: background .15s ease, color .15s ease;
}
.code-block-copy:hover { background: rgba(255,255,255,0.14); color: #fff; }
.code-block-copy.copied { background: var(--accent); color: #fff; }
.code-block-copy svg { width: 12px; height: 12px; }

main.content pre {
    background: var(--code-bg); color: var(--code-text);
    padding: 18px 20px; border-radius: 10px; overflow-x: auto;
    font-size: 13px; line-height: 1.6; margin: 16px 0 24px;
    font-family: var(--font-mono);
}
.code-block-wrap pre { border-radius: 0; margin: 0; }
main.content pre code { background: none; color: inherit; padding: 0; font-family: var(--font-mono); }
main.content blockquote {
    margin: 16px 0; padding: 10px 16px;
    border-left: 3px solid var(--accent);
    background: #fff7ed; color: #9a3412; border-radius: 0 6px 6px 0;
}
main.content ul, main.content ol { line-height: 1.8; }

/* Prism.js token colors, hand-tuned to sit on --code-bg rather than
   a stock theme, so the palette matches the rest of the site. */
.token.comment, .token.prolog, .token.doctype, .token.cdata { color: #64748b; font-style: italic; }
.token.string, .token.attr-value { color: #86efac; }
.token.keyword, .token.selector, .token.atrule { color: var(--accent); }
.token.function, .token.class-name { color: #7dd3fc; }
.token.number, .token.boolean, .token.constant { color: #fca5a5; }
.token.property, .token.tag, .token.symbol { color: #c4b5fd; }
.token.punctuation, .token.operator { color: #94a3b8; }
.token.variable { color: #fdba74; }

/* Stripe/Twilio/Africa's Talking-style row: explanation on the
   left, its code example pinned alongside it on the right. */
.doc-row {
    display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 36px; align-items: start; margin: 8px 0 28px;
}
.doc-row .doc-row-prose p:first-child { margin-top: 0; }
.doc-row .doc-row-code { position: sticky; top: 16px; }
.doc-row .doc-row-code pre { margin: 0; }
.doc-full { margin: 0 0 8px; }

/* Multi-language code samples — CSS-only tabs (radio input +
   label + :nth-of-type sibling matching), no JS needed. Supports
   up to 6 tabs per group, far more than any page actually uses. */
.tab-group { position: relative; }
.tab-radio { position: absolute; opacity: 0; width: 1px; height: 1px; overflow: hidden; }
.tab-buttons { display: flex; gap: 4px; margin-bottom: 8px; flex-wrap: wrap; }
.tab-buttons label {
    padding: 5px 12px; font-size: 12px; font-weight: 600; border-radius: 6px;
    cursor: pointer; color: #94a3b8; background: rgba(255,255,255,0.07); user-select: none;
}
.tab-panels pre { margin: 0; }
.tab-panel { display: none; }
.tab-radio:nth-of-type(1):checked ~ .tab-buttons label:nth-of-type(1),
.tab-radio:nth-of-type(2):checked ~ .tab-buttons label:nth-of-type(2),
.tab-radio:nth-of-type(3):checked ~ .tab-buttons label:nth-of-type(3),
.tab-radio:nth-of-type(4):checked ~ .tab-buttons label:nth-of-type(4),
.tab-radio:nth-of-type(5):checked ~ .tab-buttons label:nth-of-type(5),
.tab-radio:nth-of-type(6):checked ~ .tab-buttons label:nth-of-type(6) {
    background: var(--accent); color: #fff;
}
.tab-radio:nth-of-type(1):checked ~ .tab-panels pre:nth-of-type(1),
.tab-radio:nth-of-type(2):checked ~ .tab-panels pre:nth-of-type(2),
.tab-radio:nth-of-type(3):checked ~ .tab-panels pre:nth-of-type(3),
.tab-radio:nth-of-type(4):checked ~ .tab-panels pre:nth-of-type(4),
.tab-radio:nth-of-type(5):checked ~ .tab-panels pre:nth-of-type(5),
.tab-radio:nth-of-type(6):checked ~ .tab-panels pre:nth-of-type(6) {
    display: block;
}

.page-nav {
    display: flex; justify-content: space-between; gap: 16px;
    margin-top: 48px; padding-top: 20px; border-top: 1px solid var(--border);
    font-size: 13px;
}
footer.site-footer {
    margin-top: 40px; padding-top: 16px; border-top: 1px solid var(--border);
    font-size: 12px; color: var(--text-muted);
}
@media (max-width: 1024px) {
    .doc-row { grid-template-columns: 1fr; gap: 12px; }
    .doc-row .doc-row-code { position: static; }
}
.sidebar-backdrop { display: none; }
@media (max-width: 860px) {
    .sidebar-toggle-btn { display: block; }
    aside.sidebar {
        display: none;
        position: fixed; top: 53px; left: 0; bottom: 0; z-index: 30;
        width: 82%; max-width: 300px;
        box-shadow: 8px 0 24px rgba(0,0,0,0.25);
    }
    #sidebar-toggle:checked ~ .shell aside.sidebar { display: block; }
    /* A full-screen <label for="sidebar-toggle">: clicking anywhere
       on it (i.e. outside the open drawer) unchecks the box and
       closes the menu — no extra JS needed. */
    #sidebar-toggle:checked ~ .sidebar-backdrop {
        display: block; position: fixed; inset: 0; top: 53px;
        background: rgba(15,23,42,0.45); z-index: 25;
    }
    main.content { padding: 28px 20px; }
}

.brand-flex { display: flex; align-items: center; gap: 10px; }
.brand-logo { height: 24px; }
header.topbar .brand span.brand-sub { color: #cbd5e1; font-weight: 500; }
aside.sidebar a.page-link.back-link { color: var(--accent); font-weight: 600; margin-bottom: 8px; }
.code-block-copy.code-block-copy-end { margin-left: auto; }
