:root {
    --bg: #0a1628;
    --bg-elev: #0f1f38;
    --bg-card: #122544;
    --border: #1f3358;
    --text: #e6edf7;
    --text-muted: #8aa0bf;
    --accent: #25d366;
    --accent-2: #34b7f1;
    --code-bg: #07101f;
    --code-fg: #d6e4ff;
    --shadow: 0 1px 0 rgba(255, 255, 255, 0.04) inset, 0 8px 32px rgba(0, 0, 0, 0.35);
    --radius: 14px;
    --maxw: 1180px;
    --mono: ui-monospace, "JetBrains Mono", Consolas, Menlo, "Roboto Mono", monospace;
    --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", system-ui, sans-serif;
}

@media (prefers-color-scheme: light) {
    :root {
        --bg: #f6f8fc;
        --bg-elev: #ffffff;
        --bg-card: #ffffff;
        --border: #e3e9f3;
        --text: #0d1c33;
        --text-muted: #56688a;
        --code-bg: #0a1628;
        --code-fg: #d6e4ff;
        --shadow: 0 1px 0 rgba(255, 255, 255, 0.8) inset, 0 6px 24px rgba(15, 31, 56, 0.08);
    }
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
    margin: 0;
    font-family: var(--sans);
    background: var(--bg);
    color: var(--text);
    line-height: 1.55;
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
}

.container { max-width: var(--maxw); margin: 0 auto; padding: 0 24px; }

.skip-link {
    position: absolute; left: -9999px;
    background: var(--accent); color: #002; padding: 8px 16px; border-radius: 8px;
}
.skip-link:focus { left: 16px; top: 16px; z-index: 100; }

/* Header */
.site-header {
    position: sticky; top: 0; z-index: 50;
    background: rgba(10, 22, 40, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
}
@media (prefers-color-scheme: light) {
    .site-header { background: rgba(246, 248, 252, 0.88); }
}
.nav {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 24px; gap: 24px;
}
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font-size: 17px; }
.brand strong { font-weight: 700; letter-spacing: -0.01em; }
.brand-sub { color: var(--text-muted); font-weight: 400; }
.site-header nav { display: flex; gap: 6px; flex-wrap: wrap; }
.site-header nav a {
    color: var(--text-muted); text-decoration: none; padding: 6px 12px;
    border-radius: 8px; font-size: 14px; font-weight: 500;
    transition: background 0.15s, color 0.15s;
}
.site-header nav a:hover { background: var(--bg-card); color: var(--text); }

/* Hero */
.hero { padding: 88px 0 64px; }
.eyebrow {
    color: var(--accent); font-weight: 600; font-size: 13px;
    letter-spacing: 0.08em; text-transform: uppercase; margin: 0 0 18px;
}
h1 {
    font-size: clamp(36px, 5vw, 64px);
    line-height: 1.05; letter-spacing: -0.025em;
    margin: 0 0 22px; font-weight: 800;
}
.grad {
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
    -webkit-background-clip: text; background-clip: text; color: transparent;
}
.lede {
    font-size: 18px; color: var(--text-muted); max-width: 720px; margin: 0 0 32px;
}
.cta { display: flex; gap: 12px; flex-wrap: wrap; }
.btn {
    display: inline-flex; align-items: center; justify-content: center;
    padding: 12px 22px; border-radius: 10px; text-decoration: none;
    font-weight: 600; font-size: 15px; border: 1px solid transparent;
    transition: transform 0.1s, background 0.15s, border-color 0.15s;
}
.btn.primary { background: var(--accent); color: #022; }
.btn.primary:hover { background: #2cdf75; transform: translateY(-1px); }
.btn.ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn.ghost:hover { border-color: var(--accent); color: var(--accent); }

.kpis {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 16px; margin: 48px 0 0; padding: 0;
}
.kpis div {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow);
}
.kpis dt { color: var(--text-muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; }
.kpis dd { margin: 6px 0 0; font-size: 17px; font-weight: 600; }

/* Sections */
section { padding: 72px 0; }
section h2 {
    font-size: clamp(28px, 3.5vw, 40px); margin: 0 0 12px;
    letter-spacing: -0.02em; font-weight: 700;
}

/* Features */
.features { background: var(--bg-elev); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.features .grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px; margin-top: 36px;
}
.features article {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow);
}
.features h3 { margin: 0 0 8px; font-size: 18px; font-weight: 600; }
.features p { margin: 0; color: var(--text-muted); font-size: 15px; }

/* Demo box */
.demo-box {
    display: grid; grid-template-columns: 1fr 2fr; gap: 14px 24px;
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 18px 22px; margin: 28px 0 28px;
    box-shadow: var(--shadow);
}
@media (max-width: 720px) { .demo-box { grid-template-columns: 1fr; } }
.demo-box div { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.demo-box .lbl { color: var(--text-muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; min-width: 130px; }
.demo-box code {
    font-family: var(--mono); font-size: 13px; background: var(--code-bg);
    color: var(--code-fg); padding: 6px 10px; border-radius: 6px;
    word-break: break-all; flex: 1;
}
.copy {
    background: transparent; border: 1px solid var(--border); color: var(--text);
    padding: 6px 12px; border-radius: 6px; cursor: pointer; font-size: 13px;
    transition: border-color 0.15s, color 0.15s;
}
.copy:hover { border-color: var(--accent); color: var(--accent); }
.copy.copied { border-color: var(--accent); color: var(--accent); }

/* Tabs */
.tabs {
    display: flex; gap: 4px; border-bottom: 1px solid var(--border);
    margin: 28px 0 0; flex-wrap: wrap;
}
.tabs button {
    background: transparent; border: none; padding: 10px 18px;
    color: var(--text-muted); cursor: pointer; font-size: 14px;
    border-bottom: 2px solid transparent; font-family: inherit; font-weight: 500;
    transition: color 0.15s, border-color 0.15s;
}
.tabs button:hover { color: var(--text); }
.tabs button[aria-selected="true"] {
    color: var(--text); border-bottom-color: var(--accent);
}
.tab-panel { padding: 22px 0 0; }
.tab-panel[hidden] { display: none; }
.tab-panel h3 { margin: 0 0 14px; font-weight: 600; font-size: 16px; color: var(--text-muted); }

/* Code blocks */
pre {
    background: var(--code-bg); color: var(--code-fg);
    padding: 22px 24px; border-radius: var(--radius); overflow-x: auto;
    font-size: 13.5px; line-height: 1.6;
    border: 1px solid var(--border);
}
pre code { font-family: var(--mono); }
:not(pre) > code {
    font-family: var(--mono); font-size: 0.9em;
    background: var(--bg-card); border: 1px solid var(--border);
    padding: 1px 7px; border-radius: 5px;
}

/* Quickstart */
.steps { list-style: none; padding: 0; margin: 32px 0 0; display: grid; gap: 24px; }
.steps h3 { margin: 0 0 12px; font-size: 17px; font-weight: 600; }

/* Swagger steps */
.swagger-steps {
    counter-reset: sw-step;
    list-style: none;
    padding: 0;
    margin: 14px 0 0;
    display: grid;
    gap: 10px;
}
.swagger-steps li {
    padding: 12px 16px 12px 48px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    position: relative;
    color: var(--text);
    font-size: 14.5px;
}
.swagger-steps li::before {
    counter-increment: sw-step;
    content: counter(sw-step);
    position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
    width: 24px; height: 24px; border-radius: 50%;
    background: var(--accent); color: #022;
    font-weight: 700; font-size: 13px;
    display: flex; align-items: center; justify-content: center;
}
.swagger-steps a { color: var(--accent); text-decoration: none; }
.swagger-steps a:hover { text-decoration: underline; }
.swagger-steps .key {
    word-break: break-all;
    background: var(--code-bg); color: var(--code-fg);
}

/* Endpoints table */
.endpoints { background: var(--bg-elev); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.endpoints table {
    width: 100%; border-collapse: collapse; margin: 28px 0 12px;
    background: var(--bg-card); border-radius: var(--radius); overflow: hidden;
    border: 1px solid var(--border);
}
.endpoints th, .endpoints td { padding: 12px 18px; text-align: left; border-bottom: 1px solid var(--border); font-size: 14px; }
.endpoints th { background: var(--bg-elev); font-weight: 600; color: var(--text-muted); text-transform: uppercase; font-size: 12px; letter-spacing: 0.06em; }
.endpoints tr:last-child td { border-bottom: none; }
.endpoints td:first-child { font-family: var(--mono); color: var(--accent); font-weight: 600; }
.muted { color: var(--text-muted); font-size: 14px; }

/* Bottom CTA */
.cta-bottom { text-align: center; padding: 80px 0; }
.cta-bottom p { color: var(--text-muted); max-width: 560px; margin: 12px auto 28px; }
.cta-bottom .cta { justify-content: center; }

/* Footer */
.site-footer {
    border-top: 1px solid var(--border); padding: 32px 0;
    color: var(--text-muted); font-size: 14px;
}
.site-footer a { color: var(--text-muted); text-decoration: none; }
.site-footer a:hover { color: var(--accent); }
.site-footer p { margin: 6px 0; }

/* Section lede */
.section-lede {
    font-size: 16.5px; color: var(--text-muted);
    max-width: 760px; margin: 0 0 32px;
}

/* Architecture */
.architecture { background: var(--bg-elev); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.arch-diagram {
    margin: 28px 0 44px;
    padding: 28px 24px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    display: flex; flex-direction: column; gap: 0; align-items: center;
}
.arch-row { display: flex; gap: 24px; align-items: center; justify-content: center; flex-wrap: wrap; }
.arch-row.arch-down { gap: 60px; padding: 6px 0; }
.arch-row.arch-down.arch-split { gap: 220px; }
.arch-node {
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 14px 18px;
    min-width: 220px;
    text-align: center;
}
.arch-node strong { display: block; font-size: 14px; color: var(--text); margin-bottom: 4px; }
.arch-node span { font-size: 12.5px; color: var(--text-muted); line-height: 1.45; }
.arch-node.engine, .arch-node.wa { border-color: var(--accent); }
.arch-node.wa { background: rgba(37, 211, 102, 0.08); }
.arch-arrow, .arch-arrow-v {
    font-size: 22px; color: var(--accent); font-weight: 600; user-select: none;
}
.arch-arrow-v { line-height: 1; }

.layer-list { margin: 16px 0 32px; padding: 0; display: grid; gap: 12px; }
.layer-list > div {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: 10px; padding: 14px 18px;
    display: grid; grid-template-columns: 200px 1fr; gap: 16px; align-items: start;
}
@media (max-width: 720px) { .layer-list > div { grid-template-columns: 1fr; } }
.layer-list dt { font-family: var(--mono); color: var(--accent); font-size: 14px; font-weight: 600; }
.layer-list dd { margin: 0; color: var(--text-muted); font-size: 14.5px; }

.engine-matrix { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin: 18px 0 32px; }
@media (max-width: 720px) { .engine-matrix { grid-template-columns: 1fr; } }
.engine-matrix > div {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 20px 22px;
}
.engine-matrix h4 { margin: 0 0 10px; font-size: 16px; }
.engine-matrix .badge {
    display: inline-block; font-size: 11px; font-weight: 600;
    background: var(--bg-elev); color: var(--text-muted);
    padding: 2px 8px; border-radius: 999px; margin-left: 6px;
    text-transform: uppercase; letter-spacing: 0.04em;
}
.engine-matrix .badge.prod { background: var(--accent); color: #022; }
.engine-matrix p { margin: 0; color: var(--text-muted); font-size: 14.5px; }

.lifecycle { padding-left: 22px; margin: 14px 0 0; color: var(--text-muted); font-size: 14.5px; }
.lifecycle li { margin: 8px 0; }
.lifecycle strong { color: var(--text); }

/* Usage */
.usage-steps { list-style: none; padding: 0; margin: 28px 0 0; display: grid; gap: 36px; counter-reset: usage; }
.usage-steps > li {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 24px 26px; box-shadow: var(--shadow);
}
.usage-steps h3 { margin: 0 0 10px; font-size: 18px; font-weight: 600; }
.usage-steps .hint { color: var(--text-muted); font-size: 13.5px; margin-top: 8px; }

/* Auth */
.auth-section, .api-ref, .webhook-section, .errors-section, .deploy-section, .faq-section {
    border-top: 1px solid var(--border);
}
.auth-section h3, .webhook-section h3, .errors-section h3, .deploy-section h3, .api-ref h3 {
    margin: 28px 0 12px; font-size: 17px; font-weight: 600;
}
.role-table, .event-table, .errors-table, .endpoint-table {
    width: 100%; border-collapse: collapse; margin: 14px 0 8px;
    background: var(--bg-card); border-radius: var(--radius); overflow: hidden;
    border: 1px solid var(--border);
}
.role-table th, .role-table td,
.event-table th, .event-table td,
.errors-table th, .errors-table td,
.endpoint-table th, .endpoint-table td {
    padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--border); font-size: 14px;
}
.role-table th, .event-table th, .errors-table th, .endpoint-table th {
    background: var(--bg-elev); color: var(--text-muted);
    font-weight: 600; text-transform: uppercase; font-size: 12px; letter-spacing: 0.05em;
}
.role-table tr:last-child td, .event-table tr:last-child td,
.errors-table tr:last-child td, .endpoint-table tr:last-child td { border-bottom: none; }
.endpoint-table td:first-child { font-family: var(--mono); color: var(--accent); font-weight: 600; }
.event-table td:first-child code { color: var(--accent); }

.bullets { padding-left: 22px; color: var(--text-muted); font-size: 14.5px; }
.bullets li { margin: 6px 0; }
.bullets strong { color: var(--text); }
.endpoint-list { list-style: none; padding: 0; margin: 10px 0 0; display: grid; gap: 8px; }
.endpoint-list li { background: var(--bg-card); border: 1px solid var(--border); padding: 10px 16px; border-radius: 8px; font-size: 14px; color: var(--text-muted); }
.endpoint-list code { color: var(--accent); }

.api-group { margin: 30px 0; }
.api-group h3 { margin-bottom: 6px; }

/* FAQ */
.faq-list { margin-top: 24px; display: grid; gap: 10px; }
.faq-list details {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: 10px; padding: 14px 18px;
}
.faq-list summary {
    cursor: pointer; font-weight: 600; font-size: 15px; color: var(--text);
    list-style: none; position: relative; padding-right: 28px;
}
.faq-list summary::-webkit-details-marker { display: none; }
.faq-list summary::after {
    content: "+"; position: absolute; right: 0; top: 0;
    font-size: 20px; color: var(--accent); transition: transform 0.15s;
}
.faq-list details[open] summary::after { content: "−"; }
.faq-list p { margin: 12px 0 0; color: var(--text-muted); font-size: 14.5px; }

/* Swagger steps already exist above; keep */

/* Reduce motion */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
