#144 ui dark mobile: high Developer & Code

Split-Pane API Docs + Playground

Dark-mode OpenAPI reference paired with an interactive Try-It request builder, live simulated JSON responses, and Docs/Try-It mobile tabs.

Inspired by Scalar ↗

Download .html
Fullscreen ↗

WHY THIS AESTHETIC IS UNIQUE

Eliminates context switching between static API docs and external REST clients by pairing parameter schemas directly beside an executable request runner with cURL/JS/Python codegen.

BEST FOR

Public REST and GraphQL API portalsInternal microservice documentation hubsWebhook and SDK onboarding sandboxesAI model inference playgrounds

TAGS

COLOR PALETTE (CLICK TO COPY HEX)

TYPOGRAPHY

Display
Inter
Body
Inter
Mono
JetBrains Mono
Scale
11px color-coded HTTP method badges (GET/POST/DELETE), 14px schema docs, 12.5px mono request/response JSON.

Google Fonts Stylesheet ↗

ARCHITECTURE & MOBILE NOTES

LAYOUT

Endpoint selector + 2-column Docs / Try-It Playground split on desktop; clean segmented Docs / Playground tabs on <=860px mobile.

INTERACTION

Switching endpoints updates parameter inputs, JSON body templates, and cURL/JS/Python snippets; clicking Send Request runs a realistic simulated response with HTTP status code and latency badge.

MOBILE

Replaces side-by-side split panes with a sticky Docs / Try-It segmented tab bar and horizontal endpoint pills so developers can inspect and test endpoints cleanly at 390px.

AI AGENT GUARDRAILS

DO

  • Color-code HTTP methods consistently (GET emerald, POST indigo/violet, DELETE rose) with readable contrast.
  • Sync parameter input edits live into the generated cURL/JS/Python code snippets.
  • Split Docs and Try-It into explicit tabs on viewports below 860px.

DON'T

  • Never let long JSON response lines break mobile viewport width; wrap or scroll inside the code block.
  • Avoid hiding the Send Request button below the fold on mobile playground views.
STANDALONE SOURCE · demos/split-api-playground.html (23.1 KB)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Vortex API — Split-Pane Docs &amp; Live Try-It Playground</title>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500;600&display=swap" rel="stylesheet">
<style>
  :root {
    --bg: #0b0b12;
    --panel: #12121d;
    --panel-2: #181828;
    --border: #26263d;
    --ink: #f3f4ff;
    --muted: #9497b8;
    --violet: #8b5cf6;
    --violet-hi: #a78bfa;
    --violet-soft: rgba(139, 92, 246, 0.16);
    --get: #34d399;
    --post: #60a5fa;
    --delete: #f87171;
    --patch: #fbbf24;
  }
  * { box-sizing: border-box; margin: 0; padding: 0; }
  html, body { overflow-x: hidden; }
  body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--ink);
    min-height: 100vh;
  }
  .mono { font-family: 'JetBrains Mono', ui-monospace, monospace; }

  header.nav {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 20px;
    background: var(--panel);
    border-bottom: 1px solid var(--border);
  }
  .brand {
    display: flex;
    align-items: center;
    gap: 10px;
  }
  .brand-orb {
    width: 34px;
    height: 34px;
    border-radius: 9px;
    background: linear-gradient(135deg, #8b5cf6, #ec4899);
    display: grid;
    place-items: center;
    font-weight: 700;
    font-size: 15px;
  }
  .brand h1 { font-size: 16px; font-weight: 700; }
  .brand span { font-size: 12px; color: var(--muted); }
  .server-pill {
    font-size: 12px;
    color: var(--violet-hi);
    background: var(--violet-soft);
    border: 1px solid rgba(139, 92, 246, 0.35);
    padding: 6px 11px;
    border-radius: 99px;
  }

  /* Mobile Docs / Playground Tab Switcher */
  .mobile-tabs {
    display: none;
    grid-template-columns: 1fr 1fr;
    background: var(--panel);
    border-bottom: 1px solid var(--border);
    padding: 8px 12px;
    gap: 8px;
  }
  .m-tab {
    min-height: 44px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--panel-2);
    color: var(--muted);
    font: inherit;
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
  }
  .m-tab.active {
    background: var(--violet);
    border-color: var(--violet);
    color: #fff;
  }

  .split {
    max-width: 1320px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: 240px minmax(0, 1fr) minmax(0, 1.05fr);
    min-height: calc(100vh - 60px);
  }

  /* Left Endpoint Sidebar */
  aside.endpoints {
    border-right: 1px solid var(--border);
    padding: 14px 12px;
    background: #0e0e18;
    display: flex;
    flex-direction: column;
    gap: 6px;
  }
  .ep-group-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
    padding: 6px 8px 4px;
  }
  .ep-btn {
    min-height: 46px;
    width: 100%;
    text-align: left;
    padding: 8px 10px;
    border-radius: 9px;
    border: 1px solid transparent;
    background: transparent;
    color: var(--ink);
    font: inherit;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background 0.14s, border-color 0.14s;
  }
  .ep-btn:hover { background: var(--panel-2); }
  .ep-btn.active {
    background: var(--violet-soft);
    border-color: rgba(139, 92, 246, 0.45);
  }
  .meth {
    font-size: 10px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 5px;
    min-width: 44px;
    text-align: center;
    flex-shrink: 0;
  }
  .m-GET { background: rgba(52, 211, 153, 0.16); color: var(--get); }
  .m-POST { background: rgba(96, 165, 250, 0.16); color: var(--post); }
  .m-PATCH { background: rgba(251, 191, 36, 0.16); color: var(--patch); }
  .m-DELETE { background: rgba(248, 113, 113, 0.16); color: var(--delete); }
  .ep-name { font-size: 13px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

  /* Middle Docs Pane */
  section.docs-pane {
    padding: 22px 24px;
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 18px;
  }
  .ep-header {
    display: flex;
    flex-direction: column;
    gap: 8px;
  }
  .ep-header h2 { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; }
  .ep-path {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--panel-2);
    border: 1px solid var(--border);
    border-radius: 9px;
    padding: 8px 12px;
    font-size: 13px;
    overflow-x: auto;
  }
  .ep-desc { font-size: 14px; color: var(--muted); line-height: 1.6; }

  .schema-card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 14px 16px;
  }
  .schema-card h3 {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
    margin-bottom: 10px;
  }
  .param-row {
    padding: 10px 0;
    border-bottom: 1px solid #1f1f33;
    display: flex;
    flex-direction: column;
    gap: 4px;
  }
  .param-row:last-child { border-bottom: none; padding-bottom: 0; }
  .param-top {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
  }
  .param-name { font-size: 13px; font-weight: 600; color: var(--violet-hi); }
  .param-type { font-size: 11px; color: var(--muted); background: var(--panel-2); padding: 2px 6px; border-radius: 5px; }
  .param-req { font-size: 10.5px; color: var(--delete); font-weight: 600; }
  .param-desc { font-size: 12.5px; color: var(--muted); }

  /* Right Playground Pane */
  section.play-pane {
    padding: 22px 24px;
    background: #0d0d17;
    display: flex;
    flex-direction: column;
    gap: 16px;
  }
  .play-card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
  }
  .play-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
  }
  .play-head h3 { font-size: 14px; font-weight: 600; }
  .btn-send {
    min-height: 44px;
    padding: 0 18px;
    border-radius: 10px;
    border: none;
    background: linear-gradient(135deg, var(--violet), #6d28d9);
    color: #fff;
    font: inherit;
    font-size: 13.5px;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
  }
  .btn-send:hover { filter: brightness(1.1); }

  .input-grid {
    display: flex;
    flex-direction: column;
    gap: 10px;
  }
  .inp-row {
    display: flex;
    flex-direction: column;
    gap: 5px;
  }
  .inp-row label { font-size: 12px; color: var(--muted); }
  .inp-row input, .inp-row textarea {
    width: 100%;
    min-height: 42px;
    padding: 9px 12px;
    border-radius: 9px;
    border: 1px solid var(--border);
    background: #0a0a12;
    color: var(--ink);
    font-size: 13px;
  }
  .inp-row textarea { min-height: 112px; resize: vertical; line-height: 1.5; }

  .code-tabs {
    display: flex;
    gap: 6px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 8px;
  }
  .code-tab {
    min-height: 36px;
    padding: 0 12px;
    border-radius: 8px;
    border: 1px solid transparent;
    background: transparent;
    color: var(--muted);
    font: inherit;
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
  }
  .code-tab.active {
    background: var(--violet-soft);
    border-color: rgba(139, 92, 246, 0.4);
    color: var(--violet-hi);
  }
  pre.code-block {
    background: #090910;
    border: 1px solid #1e1e30;
    border-radius: 10px;
    padding: 12px 14px;
    font-size: 12px;
    line-height: 1.55;
    color: #d8dcff;
    overflow-x: auto;
    white-space: pre;
  }

  .resp-badges {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
  }
  .status-pill {
    font-size: 12px;
    font-weight: 700;
    padding: 4px 9px;
    border-radius: 6px;
  }
  .st-2xx { background: rgba(52, 211, 153, 0.18); color: var(--get); }
  .st-4xx { background: rgba(248, 113, 113, 0.18); color: var(--delete); }
  .latency-pill { font-size: 12px; color: var(--muted); }

  /* Mobile endpoint selector */
  .mobile-ep-bar {
    display: none;
    padding: 10px 12px 0;
    background: var(--bg);
  }
  .mobile-ep-bar select {
    width: 100%;
    min-height: 44px;
    padding: 0 12px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--panel);
    color: var(--ink);
    font: inherit;
    font-size: 13.5px;
  }

  @media (max-width: 960px) {
    .mobile-tabs { display: grid; }
    .mobile-ep-bar { display: block; }
    .split { grid-template-columns: 1fr; }
    aside.endpoints { display: none; }
    section.docs-pane, section.play-pane { padding: 16px 14px; border-right: none; }
    section.docs-pane.m-hidden, section.play-pane.m-hidden { display: none; }
  }
</style>
</head>
<body>
<header class="nav">
  <div class="brand">
    <div class="brand-orb">V</div>
    <div>
      <h1>Vortex Billing API</h1>
      <span>OpenAPI 3.1 · Reference &amp; Live Sandbox</span>
    </div>
  </div>
  <div class="server-pill mono">https://api.vortex.dev/v2</div>
</header>

<div class="mobile-ep-bar">
  <select id="mobileEpSelect" aria-label="Choose API endpoint"></select>
</div>

<div class="mobile-tabs" id="mobileTabs" role="tablist">
  <button type="button" class="m-tab active" data-pane="docs" role="tab" aria-selected="true">Docs &amp; Schema</button>
  <button type="button" class="m-tab" data-pane="play" role="tab" aria-selected="false">Try-It Playground</button>
</div>

<div class="split">
  <aside class="endpoints" id="endpointList" aria-label="API Endpoints"></aside>

  <section class="docs-pane" id="docsPane">
    <div class="ep-header">
      <h2 id="docTitle"></h2>
      <div class="ep-path mono" id="docPath"></div>
      <p class="ep-desc" id="docDesc"></p>
    </div>

    <div class="schema-card">
      <h3>Parameters</h3>
      <div id="paramSchema"></div>
    </div>

    <div class="schema-card">
      <h3>Response Schema (200 / 201)</h3>
      <pre class="code-block mono" id="respSchema"></pre>
    </div>
  </section>

  <section class="play-pane m-hidden" id="playPane">
    <div class="play-card">
      <div class="play-head">
        <h3>Request Builder</h3>
        <button type="button" class="btn-send" id="sendBtn">&#9654; Send Request</button>
      </div>
      <div class="input-grid" id="paramInputs"></div>
    </div>

    <div class="play-card">
      <div class="play-head">
        <h3>Client Snippet</h3>
        <button type="button" class="code-tab" id="copyCodeBtn" style="border:1px solid var(--border)">Copy</button>
      </div>
      <div class="code-tabs" id="codeTabs">
        <button type="button" class="code-tab active" data-lang="curl">cURL</button>
        <button type="button" class="code-tab" data-lang="js">JavaScript</button>
        <button type="button" class="code-tab" data-lang="py">Python</button>
      </div>
      <pre class="code-block mono" id="snippetBox"></pre>
    </div>

    <div class="play-card">
      <div class="play-head">
        <h3>Live Response</h3>
        <div class="resp-badges">
          <span class="status-pill st-2xx mono" id="respStatus">200 OK</span>
          <span class="latency-pill mono" id="respLatency">42 ms</span>
        </div>
      </div>
      <pre class="code-block mono" id="respBody"></pre>
    </div>
  </section>
</div>

<script>
(() => {
  const BASE_URL = 'https://api.vortex.dev/v2';
  const ENDPOINTS = [
    {
      id: 'list-invoices',
      group: 'Invoices',
      method: 'GET',
      path: '/invoices',
      title: 'List Customer Invoices',
      desc: 'Returns a paginated ledger of finalized and open invoices filtered by status and limit.',
      params: [
        { name: 'status', in: 'query', type: 'string', req: false, def: 'paid', desc: 'Filter by invoice state: paid, open, or overdue.' },
        { name: 'limit', in: 'query', type: 'integer', req: false, def: '3', desc: 'Maximum number of invoice records to return (1–50).' }
      ],
      schema: '{\n  "object": "list",\n  "count": "integer",\n  "data": [{ "id": "string", "amount_cents": "integer", "status": "string" }]\n}',
      simulate(vals) {
        const lim = Math.max(1, Math.min(10, parseInt(vals.limit, 10) || 3));
        const st = vals.status || 'paid';
        const items = Array.from({ length: lim }, (_, i) => ({
          id: `inv_94${80 + i}`,
          customer: ['Northstar Robotics', 'Solstice Energy', 'Canopy Health', 'Vellum Press'][i % 4],
          amount_cents: (i + 1) * 420000,
          currency: 'usd',
          status: st
        }));
        return { status: 200, label: '200 OK', body: { object: 'list', count: items.length, data: items } };
      }
    },
    {
      id: 'create-sub',
      group: 'Subscriptions',
      method: 'POST',
      path: '/subscriptions',
      title: 'Create Subscription',
      desc: 'Starts a recurring billing subscription for an existing customer ID with optional trial days.',
      params: [],
      bodyDefault: JSON.stringify({ customer_id: 'cus_8821k', price_id: 'price_scale_monthly', seats: 12, trial_days: 14 }, null, 2),
      schema: '{\n  "id": "sub_...",\n  "status": "trialing | active",\n  "seats": "integer",\n  "current_period_end": "iso8601"\n}',
      simulate(vals, rawBody) {
        try {
          const parsed = JSON.parse(rawBody);
          if (!parsed.customer_id) {
            return { status: 400, label: '400 Bad Request', body: { error: { code: 'missing_field', message: 'customer_id is required' } } };
          }
          return {
            status: 201,
            label: '201 Created',
            body: {
              id: 'sub_7f3c91a2',
              customer_id: parsed.customer_id,
              price_id: parsed.price_id || 'price_scale_monthly',
              seats: parsed.seats || 1,
              status: parsed.trial_days > 0 ? 'trialing' : 'active',
              current_period_end: '2026-06-12T00:00:00Z'
            }
          };
        } catch {
          return { status: 400, label: '400 Invalid JSON', body: { error: { code: 'invalid_json', message: 'Request body must be valid JSON.' } } };
        }
      }
    },
    {
      id: 'update-seats',
      group: 'Subscriptions',
      method: 'PATCH',
      path: '/subscriptions/{sub_id}',
      title: 'Update Seat Quantity',
      desc: 'Prorates seat changes immediately and returns the updated upcoming invoice preview.',
      params: [
        { name: 'sub_id', in: 'path', type: 'string', req: true, def: 'sub_7f3c91a2', desc: 'Unique subscription identifier.' }
      ],
      bodyDefault: JSON.stringify({ seats: 25, proration_behavior: 'create_prorations' }, null, 2),
      schema: '{\n  "id": "string",\n  "seats": "integer",\n  "proration_cents": "integer"\n}',
      simulate(vals, rawBody) {
        try {
          const parsed = JSON.parse(rawBody);
          return {
            status: 200,
            label: '200 OK',
            body: {
              id: vals.sub_id || 'sub_7f3c91a2',
              seats: parsed.seats ?? 25,
              proration_cents: ((parsed.seats ?? 25) - 12) * 3500,
              updated_at: new Date().toISOString()
            }
          };
        } catch {
          return { status: 400, label: '400 Invalid JSON', body: { error: { code: 'invalid_json', message: 'Malformed JSON payload.' } } };
        }
      }
    },
    {
      id: 'revoke-key',
      group: 'Webhooks & Keys',
      method: 'DELETE',
      path: '/api-keys/{key_id}',
      title: 'Revoke API Key',
      desc: 'Immediately invalidates a scoped bearer token. Subsequent requests using this key return 401.',
      params: [
        { name: 'key_id', in: 'path', type: 'string', req: true, def: 'key_live_09x4', desc: 'Key ID to permanently revoke.' }
      ],
      schema: '{\n  "id": "string",\n  "revoked": true,\n  "revoked_at": "iso8601"\n}',
      simulate(vals) {
        return {
          status: 200,
          label: '200 OK',
          body: { id: vals.key_id || 'key_live_09x4', revoked: true, revoked_at: new Date().toISOString() }
        };
      }
    }
  ];

  let activeEp = ENDPOINTS[0];
  let activeLang = 'curl';
  let currentVals = {};
  let currentBody = '';

  const endpointList = document.getElementById('endpointList');
  const mobileEpSelect = document.getElementById('mobileEpSelect');
  const paramInputs = document.getElementById('paramInputs');
  const snippetBox = document.getElementById('snippetBox');

  function renderSidebar() {
    endpointList.innerHTML = '';
    mobileEpSelect.innerHTML = '';
    let lastGroup = '';
    ENDPOINTS.forEach(ep => {
      if (ep.group !== lastGroup) {
        const lbl = document.createElement('div');
        lbl.className = 'ep-group-label';
        lbl.textContent = ep.group;
        endpointList.appendChild(lbl);
        lastGroup = ep.group;
      }
      const btn = document.createElement('button');
      btn.type = 'button';
      btn.className = 'ep-btn' + (ep.id === activeEp.id ? ' active' : '');
      btn.innerHTML = `<span class="meth m-${ep.method} mono">${ep.method}</span><span class="ep-name">${ep.title}</span>`;
      btn.addEventListener('click', () => selectEndpoint(ep.id));
      endpointList.appendChild(btn);

      const opt = document.createElement('option');
      opt.value = ep.id;
      opt.textContent = `${ep.method} ${ep.path} — ${ep.title}`;
      if (ep.id === activeEp.id) opt.selected = true;
      mobileEpSelect.appendChild(opt);
    });
  }

  function resolvedUrl() {
    let p = activeEp.path;
    const qs = [];
    activeEp.params.forEach(pr => {
      const v = currentVals[pr.name] ?? pr.def;
      if (pr.in === 'path') p = p.replace(`{${pr.name}}`, encodeURIComponent(v || ''));
      else if (v !== '') qs.push(`${encodeURIComponent(pr.name)}=${encodeURIComponent(v)}`);
    });
    return BASE_URL + p + (qs.length ? '?' + qs.join('&') : '');
  }

  function updateSnippet() {
    const url = resolvedUrl();
    const hasBody = Boolean(activeEp.bodyDefault);
    if (activeLang === 'curl') {
      let s = `curl -X ${activeEp.method} "${url}" \\\n  -H "Authorization: Bearer vx_live_98a1..."`;
      if (hasBody) s += ` \\\n  -H "Content-Type: application/json" \\\n  -d '${currentBody.replace(/\s+/g, ' ')}'`;
      snippetBox.textContent = s;
    } else if (activeLang === 'js') {
      let s = `const res = await fetch("${url}", {\n  method: "${activeEp.method}",\n  headers: {\n    "Authorization": "Bearer vx_live_98a1..."${hasBody ? ',\n    "Content-Type": "application/json"' : ''}\n  }`;
      if (hasBody) s += `,\n  body: JSON.stringify(${currentBody.replace(/\s+/g, ' ')})`;
      s += `\n});\nconst data = await res.json();`;
      snippetBox.textContent = s;
    } else {
      let s = `import requests\n\nres = requests.${activeEp.method.toLowerCase()}(\n    "${url}",\n    headers={"Authorization": "Bearer vx_live_98a1..."}`;
      if (hasBody) s += `,\n    json=${currentBody.replace(/\s+/g, ' ')}`;
      s += `\n)\nprint(res.json())`;
      snippetBox.textContent = s;
    }
  }

  function runRequest() {
    const result = activeEp.simulate(currentVals, currentBody);
    const ms = 28 + Math.floor(Math.random() * 55);
    const stEl = document.getElementById('respStatus');
    stEl.textContent = result.label;
    stEl.className = `status-pill mono ${result.status < 300 ? 'st-2xx' : 'st-4xx'}`;
    document.getElementById('respLatency').textContent = `${ms} ms`;
    document.getElementById('respBody').textContent = JSON.stringify(result.body, null, 2);
  }

  function selectEndpoint(id) {
    activeEp = ENDPOINTS.find(e => e.id === id) || ENDPOINTS[0];
    currentVals = {};
    activeEp.params.forEach(p => { currentVals[p.name] = p.def; });
    currentBody = activeEp.bodyDefault || '';

    renderSidebar();

    document.getElementById('docTitle').textContent = activeEp.title;
    document.getElementById('docPath').innerHTML = `<span class="meth m-${activeEp.method}">${activeEp.method}</span><span>${activeEp.path}</span>`;
    document.getElementById('docDesc').textContent = activeEp.desc;
    document.getElementById('respSchema').textContent = activeEp.schema;

    const schemaEl = document.getElementById('paramSchema');
    if (!activeEp.params.length && !activeEp.bodyDefault) {
      schemaEl.innerHTML = '<div class="param-desc">No parameters required.</div>';
    } else {
      schemaEl.innerHTML = activeEp.params.map(p => `
        <div class="param-row">
          <div class="param-top">
            <span class="param-name mono">${p.name}</span>
            <span class="param-type mono">${p.in} · ${p.type}</span>
            ${p.req ? '<span class="param-req">required</span>' : ''}
          </div>
          <div class="param-desc">${p.desc}</div>
        </div>
      `).join('') + (activeEp.bodyDefault ? '<div class="param-row"><div class="param-top"><span class="param-name mono">body</span><span class="param-type mono">application/json</span><span class="param-req">required</span></div><div class="param-desc">Editable JSON payload in the Try-It playground.</div></div>' : '');
    }

    paramInputs.innerHTML = '';
    activeEp.params.forEach(p => {
      const row = document.createElement('div');
      row.className = 'inp-row';
      row.innerHTML = `<label class="mono">${p.name} (${p.in})</label><input class="mono" value="${p.def}">`;
      const inp = row.querySelector('input');
      inp.addEventListener('input', () => { currentVals[p.name] = inp.value; updateSnippet(); });
      paramInputs.appendChild(row);
    });
    if (activeEp.bodyDefault) {
      const row = document.createElement('div');
      row.className = 'inp-row';
      row.innerHTML = `<label class="mono">JSON Body</label><textarea class="mono"></textarea>`;
      const ta = row.querySelector('textarea');
      ta.value = currentBody;
      ta.addEventListener('input', () => { currentBody = ta.value; updateSnippet(); });
      paramInputs.appendChild(row);
    }

    updateSnippet();
    runRequest();
  }

  document.getElementById('sendBtn').addEventListener('click', runRequest);
  document.getElementById('codeTabs').addEventListener('click', (e) => {
    const btn = e.target.closest('.code-tab');
    if (!btn) return;
    activeLang = btn.dataset.lang;
    document.querySelectorAll('#codeTabs .code-tab').forEach(b => b.classList.toggle('active', b === btn));
    updateSnippet();
  });
  document.getElementById('copyCodeBtn').addEventListener('click', (e) => {
    if (navigator.clipboard) navigator.clipboard.writeText(snippetBox.textContent).catch(() => {});
    const b = e.currentTarget;
    b.textContent = 'Copied!';
    setTimeout(() => { b.textContent = 'Copy'; }, 1400);
  });
  mobileEpSelect.addEventListener('change', (e) => selectEndpoint(e.target.value));

  document.getElementById('mobileTabs').addEventListener('click', (e) => {
    const btn = e.target.closest('.m-tab');
    if (!btn) return;
    const pane = btn.dataset.pane;
    document.querySelectorAll('.m-tab').forEach(b => {
      const act = b === btn;
      b.classList.toggle('active', act);
      b.setAttribute('aria-selected', act ? 'true' : 'false');
    });
    document.getElementById('docsPane').classList.toggle('m-hidden', pane !== 'docs');
    document.getElementById('playPane').classList.toggle('m-hidden', pane !== 'play');
  });

  selectEndpoint(ENDPOINTS[0].id);
})();
</script>
</body>
</html>