#054 style light mobile: high Indie Developer Tooling

Editorial Code Craft

Drafting-paper developer tool aesthetic pairing editorial serif headlines with crisp monospace buffers and latency benchmarks.

Inspired by Zed ↗

Download .html
Fullscreen ↗

WHY THIS AESTHETIC IS UNIQUE

Breaks the dark-mode-only developer tool monopoly by presenting high-performance systems software on warm drafting paper with editorial serif authority and razor-sharp code typography.

BEST FOR

Code editors, compilers, and language toolchainsHigh-performance developer infrastructure productsEngineering manifesto and benchmark showcases

TAGS

COLOR PALETTE (CLICK TO COPY HEX)

TYPOGRAPHY

Display
Newsreader
Body
Inter
Mono
JetBrains Mono
Scale
Refined editorial serif headlines (34-52px) contrasted against ultra-crisp 13px monospace code buffers and 11px benchmark labels.

Google Fonts Stylesheet ↗

ARCHITECTURE & MOBILE NOTES

LAYOUT

Architectural hairline grid framing an editorial manifesto header, an interactive multi-tab code buffer with simulated multiplayer cursors, and a frame-latency comparison strip.

INTERACTION

Switch live code buffers (Rust, TypeScript, GLSL), toggle collaborative peer cursors on/off, and inspect frame-time latency bars across editor workloads.

MOBILE

Code buffer scrolls smoothly inside its framed window while buffer tabs and benchmark comparisons stack cleanly at 390px.

AI AGENT GUARDRAILS

DO

  • Contrast warm drafting-paper canvas (#F6F5F1) with pure white framed code buffers
  • Use editorial serif display type paired with crisp syntax-highlighted monospace code
  • Present performance claims as concrete, comparable millisecond/FPS figures

DON'T

  • Do not default to dark neon glassmorphism for a craft developer tool
  • Do not use fake illegible code screenshots when real selectable syntax text works better
STANDALONE SOURCE · demos/editorial-code-craft.html (25.6 KB)
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>Vellum — High-Craft Collaborative Code Editor</title>
  <link rel="preconnect" href="https://fonts.googleapis.com">
  <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
  <link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&family=JetBrains+Mono:wght@400;500;600&family=Newsreader:ital,opsz,wght@0,6..72,400;0,6..72,500;1,6..72,400&display=swap" rel="stylesheet">
  <style>
    :root {
      --canvas: #F6F5F1;
      --surface: #FFFFFF;
      --surface-tint: #FBFAF7;
      --ink: #17191C;
      --ink-soft: #3B4048;
      --accent: #2563EB;
      --accent-soft: rgba(37, 99, 235, 0.10);
      --muted: #6E747E;
      --border: #E2E0D8;
      --peer-a: #D97706;
      --peer-b: #059669;
      --syn-kw: #2563EB;
      --syn-fn: #7C3AED;
      --syn-str: #047857;
      --syn-num: #B45309;
      --syn-com: #8C929C;
      --font-serif: 'Newsreader', Georgia, serif;
      --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
      --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, monospace;
    }

    *, *::before, *::after {
      box-sizing: border-box;
      margin: 0;
      padding: 0;
    }

    html, body {
      background: var(--canvas);
      color: var(--ink);
      font-family: var(--font-sans);
      -webkit-font-smoothing: antialiased;
      overflow-x: hidden;
    }

    /* Navigation */
    .topbar {
      position: sticky;
      top: 0;
      z-index: 30;
      background: rgba(246, 245, 241, 0.92);
      backdrop-filter: blur(10px);
      border-bottom: 1px solid var(--border);
    }

    .topbar-inner {
      max-width: 1140px;
      margin: 0 auto;
      padding: 0 24px;
      height: 60px;
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 16px;
    }

    .brand {
      display: inline-flex;
      align-items: center;
      gap: 10px;
      text-decoration: none;
      color: var(--ink);
      font-family: var(--font-mono);
      font-weight: 600;
      font-size: 14px;
      letter-spacing: -0.02em;
    }

    .nav-desktop {
      display: flex;
      align-items: center;
      gap: 20px;
    }

    .nav-desktop a {
      text-decoration: none;
      color: var(--muted);
      font-size: 13.5px;
      font-weight: 500;
      transition: color 0.14s ease;
    }

    .nav-desktop a:hover { color: var(--ink); }

    .btn-download {
      display: inline-flex;
      align-items: center;
      gap: 7px;
      height: 36px;
      padding: 0 14px;
      border-radius: 7px;
      background: var(--ink);
      color: #FFFFFF !important;
      font-size: 13px;
      font-weight: 500;
      text-decoration: none;
    }

    .mobile-btn {
      display: none;
      width: 44px;
      height: 44px;
      border: 1px solid var(--border);
      border-radius: 8px;
      background: var(--surface);
      color: var(--ink);
      align-items: center;
      justify-content: center;
      cursor: pointer;
    }

    .mobile-drawer {
      display: none;
      flex-direction: column;
      padding: 12px 20px 18px;
      border-top: 1px solid var(--border);
      background: var(--surface);
      gap: 4px;
    }

    .mobile-drawer.open { display: flex; }

    .mobile-drawer a {
      text-decoration: none;
      color: var(--ink);
      font-size: 15px;
      font-weight: 500;
      min-height: 44px;
      display: flex;
      align-items: center;
      padding: 0 8px;
    }

    /* Page Container */
    .page {
      max-width: 1140px;
      margin: 0 auto;
      padding: 54px 24px 88px;
    }

    /* Editorial Hero */
    .hero {
      max-width: 780px;
      margin-bottom: 40px;
    }

    .hero-meta {
      font-family: var(--font-mono);
      font-size: 12px;
      color: var(--accent);
      display: inline-flex;
      align-items: center;
      gap: 8px;
      margin-bottom: 16px;
    }

    .hero h1 {
      font-family: var(--font-serif);
      font-weight: 400;
      font-size: clamp(36px, 5.6vw, 60px);
      line-height: 1.06;
      letter-spacing: -0.025em;
      color: var(--ink);
      margin-bottom: 18px;
    }

    .hero h1 em {
      font-style: italic;
      color: var(--accent);
    }

    .hero p {
      font-size: 17px;
      line-height: 1.62;
      color: var(--muted);
      max-width: 58ch;
    }

    /* Interactive Code Workbench */
    .editor-frame {
      background: var(--surface);
      border: 1px solid var(--border);
      border-radius: 14px;
      overflow: hidden;
      box-shadow: 0 10px 34px rgba(23, 25, 28, 0.06);
      margin-bottom: 36px;
    }

    .editor-chrome {
      display: flex;
      align-items: center;
      justify-content: space-between;
      flex-wrap: wrap;
      gap: 10px;
      padding: 10px 14px;
      background: var(--surface-tint);
      border-bottom: 1px solid var(--border);
    }

    .tab-strip {
      display: flex;
      align-items: center;
      gap: 6px;
      flex-wrap: wrap;
    }

    .buffer-tab {
      display: inline-flex;
      align-items: center;
      gap: 8px;
      height: 34px;
      padding: 0 12px;
      border-radius: 7px;
      border: 1px solid transparent;
      background: transparent;
      color: var(--muted);
      font-family: var(--font-mono);
      font-size: 12.5px;
      font-weight: 500;
      cursor: pointer;
      transition: all 0.14s ease;
    }

    .buffer-tab:hover {
      color: var(--ink);
      background: rgba(23, 25, 28, 0.04);
    }

    .buffer-tab.active {
      background: var(--surface);
      color: var(--ink);
      border-color: var(--border);
      box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
    }

    .lang-dot {
      width: 7px;
      height: 7px;
      border-radius: 50%;
    }

    .collab-bar {
      display: flex;
      align-items: center;
      gap: 10px;
    }

    .peer-stack {
      display: flex;
      align-items: center;
      gap: 6px;
      font-family: var(--font-mono);
      font-size: 11.5px;
      color: var(--muted);
    }

    .peer-dot {
      width: 8px;
      height: 8px;
      border-radius: 50%;
      display: inline-block;
    }

    .collab-toggle {
      display: inline-flex;
      align-items: center;
      gap: 8px;
      height: 34px;
      padding: 0 12px;
      border-radius: 7px;
      border: 1px solid var(--border);
      background: var(--surface);
      color: var(--ink-soft);
      font-family: var(--font-sans);
      font-size: 12.5px;
      font-weight: 500;
      cursor: pointer;
      transition: all 0.15s ease;
    }

    .collab-toggle[aria-pressed="true"] {
      background: var(--accent-soft);
      border-color: rgba(37, 99, 235, 0.35);
      color: var(--accent);
    }

    .code-viewport {
      position: relative;
      overflow-x: auto;
      padding: 18px 0;
      font-family: var(--font-mono);
      font-size: 13.5px;
      line-height: 1.72;
      background: var(--surface);
    }

    .code-table {
      width: 100%;
      border-collapse: collapse;
    }

    .code-row {
      position: relative;
    }

    .code-row.active-line {
      background: rgba(37, 99, 235, 0.045);
    }

    .ln {
      width: 52px;
      padding: 0 14px;
      text-align: right;
      color: #A1A7B3;
      user-select: none;
      vertical-align: top;
      font-size: 12px;
    }

    .src {
      padding: 0 22px 0 6px;
      white-space: pre;
      color: var(--ink);
      position: relative;
    }

    .kw { color: var(--syn-kw); font-weight: 500; }
    .fn { color: var(--syn-fn); }
    .str { color: var(--syn-str); }
    .num { color: var(--syn-num); }
    .com { color: var(--syn-com); font-style: italic; }

    /* Multiplayer Cursors */
    .peer-cursor {
      position: absolute;
      width: 2px;
      height: 20px;
      pointer-events: none;
      transition: top 0.55s cubic-bezier(0.22, 1, 0.36, 1), left 0.55s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.2s ease;
      z-index: 4;
    }

    .peer-cursor::after {
      content: attr(data-name);
      position: absolute;
      top: -19px;
      left: 0;
      padding: 1px 6px;
      border-radius: 4px 4px 4px 0;
      font-family: var(--font-sans);
      font-size: 10.5px;
      font-weight: 600;
      color: #FFFFFF;
      white-space: nowrap;
      background: inherit;
    }

    .peer-cursor.hidden { opacity: 0; }

    .editor-status {
      display: flex;
      align-items: center;
      justify-content: space-between;
      flex-wrap: wrap;
      gap: 10px;
      padding: 9px 16px;
      background: var(--surface-tint);
      border-top: 1px solid var(--border);
      font-family: var(--font-mono);
      font-size: 11.5px;
      color: var(--muted);
    }

    /* Latency Benchmark & Craft Notes */
    .lower-grid {
      display: grid;
      grid-template-columns: 1.25fr 0.75fr;
      gap: 24px;
    }

    .panel {
      background: var(--surface);
      border: 1px solid var(--border);
      border-radius: 14px;
      padding: 26px;
    }

    .panel-head {
      display: flex;
      align-items: flex-start;
      justify-content: space-between;
      flex-wrap: wrap;
      gap: 12px;
      margin-bottom: 22px;
    }

    .panel-kicker {
      font-family: var(--font-mono);
      font-size: 11px;
      text-transform: uppercase;
      letter-spacing: 0.08em;
      color: var(--muted);
      margin-bottom: 6px;
    }

    .panel-title {
      font-family: var(--font-serif);
      font-size: 26px;
      font-weight: 400;
      letter-spacing: -0.02em;
    }

    .metric-switch {
      display: inline-flex;
      background: var(--canvas);
      border: 1px solid var(--border);
      border-radius: 8px;
      padding: 2px;
    }

    .metric-switch button {
      border: none;
      background: transparent;
      color: var(--muted);
      font-family: var(--font-mono);
      font-size: 11.5px;
      padding: 6px 10px;
      border-radius: 6px;
      cursor: pointer;
    }

    .metric-switch button.active {
      background: var(--surface);
      color: var(--ink);
      box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
    }

    .chart-rows {
      display: flex;
      flex-direction: column;
      gap: 14px;
    }

    .bar-row {
      display: grid;
      grid-template-columns: 148px 1fr 64px;
      align-items: center;
      gap: 12px;
    }

    .bar-name {
      font-size: 13.5px;
      font-weight: 500;
      color: var(--ink-soft);
    }

    .bar-row.highlight .bar-name {
      color: var(--ink);
      font-weight: 600;
    }

    .bar-track {
      height: 12px;
      background: var(--canvas);
      border-radius: 999px;
      overflow: hidden;
      border: 1px solid var(--border);
    }

    .bar-fill {
      height: 100%;
      border-radius: 999px;
      background: #CBD2DD;
      transition: width 0.45s cubic-bezier(0.22, 1, 0.36, 1);
    }

    .bar-row.highlight .bar-fill {
      background: var(--accent);
    }

    .bar-val {
      font-family: var(--font-mono);
      font-size: 12.5px;
      text-align: right;
      color: var(--muted);
      font-variant-numeric: tabular-nums;
    }

    .bar-row.highlight .bar-val {
      color: var(--accent);
      font-weight: 600;
    }

    .chart-footnote {
      margin-top: 18px;
      font-family: var(--font-mono);
      font-size: 11.5px;
      color: var(--muted);
      line-height: 1.5;
    }

    .principles {
      display: flex;
      flex-direction: column;
      gap: 18px;
    }

    .principle h3 {
      font-size: 15px;
      font-weight: 600;
      margin-bottom: 5px;
    }

    .principle p {
      font-size: 13.5px;
      line-height: 1.6;
      color: var(--muted);
    }

    @media (max-width: 860px) {
      .lower-grid { grid-template-columns: 1fr; }
    }

    @media (max-width: 680px) {
      .nav-desktop { display: none; }
      .mobile-btn { display: inline-flex; }

      .topbar-inner { padding: 0 16px; }
      .page { padding: 32px 16px 64px; }
      .panel { padding: 20px; }

      .buffer-tab, .collab-toggle, .metric-switch button {
        min-height: 44px;
      }

      .bar-row {
        grid-template-columns: 112px 1fr 56px;
        gap: 8px;
      }

      .code-viewport { font-size: 12.5px; }
    }
  </style>
</head>
<body>
  <header class="topbar">
    <div class="topbar-inner">
      <a href="#top" class="brand">
        <svg width="20" height="20" viewBox="0 0 20 20" fill="none">
          <rect x="2" y="2" width="16" height="16" rx="4" stroke="#17191C" stroke-width="1.8"/>
          <path d="M6.5 7L10 13.5L13.5 7" stroke="#2563EB" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"/>
        </svg>
        <span>vellum</span>
      </a>

      <nav class="nav-desktop" aria-label="Primary">
        <a href="#workbench">Workbench</a>
        <a href="#benchmarks">Latency</a>
        <a href="#architecture">Architecture</a>
        <a href="#workbench" class="btn-download">Install v0.158</a>
      </nav>

      <button type="button" class="mobile-btn" id="mobileBtn" aria-label="Toggle Menu" aria-expanded="false">
        <svg width="20" height="20" viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round">
          <line x1="3" y1="6" x2="17" y2="6"/>
          <line x1="3" y1="10" x2="17" y2="10"/>
          <line x1="3" y1="14" x2="17" y2="14"/>
        </svg>
      </button>
    </div>

    <div class="mobile-drawer" id="mobileDrawer">
      <a href="#workbench">Interactive Buffer</a>
      <a href="#benchmarks">Frame Latency</a>
      <a href="#architecture">CRDT Architecture</a>
    </div>
  </header>

  <main class="page" id="top">
    <section class="hero">
      <div class="hero-meta">
        <span>RUST + METAL / VULKAN</span>
        <span>·</span>
        <span>120 FPS GLYPH PIPELINE</span>
      </div>
      <h1>Code at the speed of <em>thought</em>, together in the same buffer.</h1>
      <p>Vellum pairs a custom GPU text renderer with conflict-free multiplayer buffers. Every keystroke lands in a single frame, whether you are editing a Rust crate solo or pairing across continents.</p>
    </section>

    <section class="editor-frame" id="workbench" aria-label="Interactive Code Buffer">
      <div class="editor-chrome">
        <div class="tab-strip" role="tablist">
          <button type="button" class="buffer-tab active" role="tab" aria-selected="true" data-lang="rust">
            <span class="lang-dot" style="background:#EA580C;"></span>gpui_scene.rs
          </button>
          <button type="button" class="buffer-tab" role="tab" aria-selected="false" data-lang="ts">
            <span class="lang-dot" style="background:#2563EB;"></span>crdt_sync.ts
          </button>
          <button type="button" class="buffer-tab" role="tab" aria-selected="false" data-lang="glsl">
            <span class="lang-dot" style="background:#7C3AED;"></span>glyph_atlas.frag
          </button>
        </div>

        <div class="collab-bar">
          <div class="peer-stack" id="peerStatus">
            <span><span class="peer-dot" style="background:var(--peer-a);"></span> Maya</span>
            <span><span class="peer-dot" style="background:var(--peer-b);"></span> Devon</span>
          </div>
          <button type="button" class="collab-toggle" id="collabToggle" aria-pressed="true">
            <span>Multiplayer Cursors</span>
          </button>
        </div>
      </div>

      <div class="code-viewport" id="codeViewport">
        <div class="peer-cursor" id="cursorA" data-name="Maya · Tokyo" style="background:var(--peer-a);top:68px;left:220px;"></div>
        <div class="peer-cursor" id="cursorB" data-name="Devon · Berlin" style="background:var(--peer-b);top:164px;left:310px;"></div>
        <table class="code-table" id="codeTable"></table>
      </div>

      <div class="editor-status">
        <span id="statusLang">Rust · UTF-8 · LF · 120 Hz</span>
        <span id="statusSync">CRDT Peer Sync: 14 ms · 2 peers active</span>
      </div>
    </section>

    <section class="lower-grid" id="benchmarks">
      <div class="panel">
        <div class="panel-head">
          <div>
            <div class="panel-kicker">BENCHMARK · APPLE M3 PRO · 120 HZ</div>
            <h2 class="panel-title">Frame Latency Comparison</h2>
          </div>
          <div class="metric-switch" role="group" aria-label="Benchmark Metric">
            <button type="button" class="active" data-metric="typing">Typing (ms)</button>
            <button type="button" data-metric="startup">Startup (ms)</button>
          </div>
        </div>

        <div class="chart-rows" id="chartRows"></div>

        <p class="chart-footnote" id="chartFootnote">
          Measured with a high-speed photodiode from keydown event to first lit glyph pixel on a 120 Hz display (lower is better; 1 frame = 8.3 ms).
        </p>
      </div>

      <div class="panel" id="architecture">
        <div class="panel-kicker">ENGINEERING NOTES</div>
        <h2 class="panel-title" style="margin-bottom:18px;">Built like a game engine</h2>
        <div class="principles">
          <div class="principle">
            <h3>Subpixel Glyph Atlas</h3>
            <p>Shaped runs are rasterized once into a shared GPU texture atlas, keeping scrolling silky across 80,000-line files.</p>
          </div>
          <div class="principle">
            <h3>SumTree Rope Buffers</h3>
            <p>Edits, soft wraps, and syntax highlights traverse balanced B-trees in O(log n) without blocking the UI thread.</p>
          </div>
          <div class="principle">
            <h3>Native CRDT Channels</h3>
            <p>Share any workspace with one click. Peers receive diffs, diagnostics, and terminal output over encrypted QUIC streams.</p>
          </div>
        </div>
      </div>
    </section>
  </main>

  <script>
    const BUFFERS = {
      rust: {
        meta: 'Rust · UTF-8 · LF · 120 Hz',
        activeLine: 5,
        lines: [
          '<span class="com">// Rasterize dirty glyph runs directly into the Metal command buffer</span>',
          '<span class="kw">pub fn</span> <span class="fn">flush_frame</span>(&amp;<span class="kw">mut</span> self, cx: &amp;<span class="kw">mut</span> GpuContext) -&gt; Result&lt;FrameStats&gt; {',
          '    <span class="kw">let</span> started = Instant::<span class="fn">now</span>();',
          '    <span class="kw">for</span> batch <span class="kw">in</span> self.scene.<span class="fn">glyph_batches</span>() {',
          '        cx.<span class="fn">bind_atlas</span>(batch.atlas_id, batch.subpixel_variant);',
          '        cx.<span class="fn">draw_instanced</span>(batch.instances.<span class="fn">as_slice</span>());',
          '    }',
          '    <span class="kw">let</span> frame_ms = started.<span class="fn">elapsed</span>().<span class="fn">as_secs_f32</span>() * <span class="num">1000.0</span>;',
          '    Ok(FrameStats { frame_ms, draw_calls: self.scene.<span class="fn">len</span>() })',
          '}'
        ]
      },
      ts: {
        meta: 'TypeScript · UTF-8 · LF · 120 Hz',
        activeLine: 4,
        lines: [
          '<span class="com">// Reconcile concurrent peer operations via Lamport clocks</span>',
          '<span class="kw">export function</span> <span class="fn">mergePeerDelta</span>(state: RopeDoc, op: PeerOp): RopeDoc {',
          '  <span class="kw">const</span> anchor = state.<span class="fn">resolveAnchor</span>(op.lamport, op.replicaId);',
          '  <span class="kw">if</span> (op.kind === <span class="str">"insert"</span>) {',
          '    <span class="kw">return</span> state.<span class="fn">splice</span>(anchor.offset, <span class="num">0</span>, op.utf8Text);',
          '  }',
          '  <span class="kw">return</span> state.<span class="fn">deleteRange</span>(anchor.offset, anchor.offset + op.len);',
          '}',
          '<span class="com">// Broadcast cursor presence at 60 Hz with delta compression</span>',
          '<span class="kw">export const</span> SYNC_INTERVAL_MS = <span class="num">16</span>;'
        ]
      },
      glsl: {
        meta: 'GLSL Fragment · Metal IR · 120 Hz',
        activeLine: 6,
        lines: [
          '<span class="com">// Subpixel LCD alpha blending for crisp monospace stems</span>',
          '<span class="kw">layout</span>(location = <span class="num">0</span>) <span class="kw">in</span> vec2 v_uv;',
          '<span class="kw">layout</span>(location = <span class="num">1</span>) <span class="kw">in</span> vec4 v_ink_color;',
          '<span class="kw">layout</span>(binding = <span class="num">0</span>) <span class="kw">uniform</span> sampler2D u_glyph_atlas;',
          '<span class="kw">layout</span>(location = <span class="num">0</span>) <span class="kw">out</span> vec4 o_color;',
          '<span class="kw">void</span> <span class="fn">main</span>() {',
          '    vec3 coverage = <span class="fn">texture</span>(u_glyph_atlas, v_uv).rgb;',
          '    <span class="kw">float</span> alpha = <span class="fn">dot</span>(coverage, vec3(<span class="num">0.3333</span>));',
          '    o_color = vec4(v_ink_color.rgb, v_ink_color.a * alpha);',
          '}'
        ]
      }
    };

    const BENCHMARKS = {
      typing: {
        max: 48,
        unit: 'ms',
        note: 'Measured with a high-speed photodiode from keydown event to first lit glyph pixel on a 120 Hz display (lower is better; 1 frame = 8.3 ms).',
        rows: [
          { name: 'Vellum (Rust/GPU)', val: 4.2, highlight: true },
          { name: 'Native Classic', val: 11.6, highlight: false },
          { name: 'Electron Editor A', val: 24.8, highlight: false },
          { name: 'Browser IDE', val: 41.5, highlight: false }
        ]
      },
      startup: {
        max: 1400,
        unit: 'ms',
        note: 'Cold launch from Finder to interactive cursor inside a 140,000-line monorepo workspace (lower is better).',
        rows: [
          { name: 'Vellum (Rust/GPU)', val: 142, highlight: true },
          { name: 'Native Classic', val: 380, highlight: false },
          { name: 'Electron Editor A', val: 940, highlight: false },
          { name: 'Browser IDE', val: 1290, highlight: false }
        ]
      }
    };

    let currentLang = 'rust';
    let collabOn = true;
    const cursorA = document.getElementById('cursorA');
    const cursorB = document.getElementById('cursorB');

    function renderBuffer(lang) {
      currentLang = lang;
      const buf = BUFFERS[lang];
      const table = document.getElementById('codeTable');
      table.innerHTML = buf.lines.map((html, idx) => `
        <tr class="code-row${idx + 1 === buf.activeLine ? ' active-line' : ''}">
          <td class="ln">${idx + 1}</td>
          <td class="src">${html}</td>
        </tr>
      `).join('');

      document.getElementById('statusLang').textContent = buf.meta;
      document.querySelectorAll('.buffer-tab').forEach(btn => {
        const active = btn.dataset.lang === lang;
        btn.classList.toggle('active', active);
        btn.setAttribute('aria-selected', String(active));
      });
    }

    function renderChart(metric) {
      const data = BENCHMARKS[metric];
      const container = document.getElementById('chartRows');
      container.innerHTML = data.rows.map(r => {
        const pct = Math.max(6, Math.round((r.val / data.max) * 100));
        return `
          <div class="bar-row${r.highlight ? ' highlight' : ''}">
            <span class="bar-name">${r.name}</span>
            <div class="bar-track"><div class="bar-fill" style="width:${pct}%"></div></div>
            <span class="bar-val">${r.val} ${data.unit}</span>
          </div>
        `;
      }).join('');
      document.getElementById('chartFootnote').textContent = data.note;

      document.querySelectorAll('.metric-switch button').forEach(btn => {
        btn.classList.toggle('active', btn.dataset.metric === metric);
      });
    }

    // Animate multiplayer cursors smoothly
    const POSITIONS_A = [
      { top: 44, left: 196 },
      { top: 92, left: 268 },
      { top: 115, left: 162 },
      { top: 68, left: 230 }
    ];
    const POSITIONS_B = [
      { top: 162, left: 280 },
      { top: 186, left: 190 },
      { top: 138, left: 245 },
      { top: 208, left: 142 }
    ];
    let step = 0;

    setInterval(() => {
      if (!collabOn) return;
      step = (step + 1) % POSITIONS_A.length;
      const a = POSITIONS_A[step];
      const b = POSITIONS_B[step];
      cursorA.style.top = a.top + 'px';
      cursorA.style.left = a.left + 'px';
      cursorB.style.top = b.top + 'px';
      cursorB.style.left = b.left + 'px';
    }, 2400);

    document.getElementById('collabToggle').addEventListener('click', function () {
      collabOn = !collabOn;
      this.setAttribute('aria-pressed', String(collabOn));
      cursorA.classList.toggle('hidden', !collabOn);
      cursorB.classList.toggle('hidden', !collabOn);
      document.getElementById('peerStatus').style.opacity = collabOn ? '1' : '0.35';
      document.getElementById('statusSync').textContent = collabOn
        ? 'CRDT Peer Sync: 14 ms · 2 peers active'
        : 'Solo Local Buffer · Offline Ready';
    });

    document.querySelectorAll('.buffer-tab').forEach(btn => {
      btn.addEventListener('click', () => renderBuffer(btn.dataset.lang));
    });

    document.querySelectorAll('.metric-switch button').forEach(btn => {
      btn.addEventListener('click', () => renderChart(btn.dataset.metric));
    });

    // Mobile drawer
    const mobileBtn = document.getElementById('mobileBtn');
    const mobileDrawer = document.getElementById('mobileDrawer');
    mobileBtn.addEventListener('click', () => {
      const open = mobileDrawer.classList.toggle('open');
      mobileBtn.setAttribute('aria-expanded', String(open));
    });
    mobileDrawer.querySelectorAll('a').forEach(a => {
      a.addEventListener('click', () => {
        mobileDrawer.classList.remove('open');
        mobileBtn.setAttribute('aria-expanded', 'false');
      });
    });

    renderBuffer('rust');
    renderChart('typing');
  </script>
</body>
</html>