<!-- SOLIDABILITY-WORLD · part 31 -->
utes×3. ` +
      `Position: ${room.district} district, arranged by complexity rank.`;
  }

  function hide() {
    if (panel) panel.classList.remove('visible');
  }

  // Test syntax: read-only check via server (node --check, never executes)
  async function testSyntax(roomKey) {
    const layout = SWWorld.getLayout();
    const room = layout.rooms.find(r => r.key === roomKey);
    if (!room || !room.filePath) return;

    const resultDiv = document.getElementById(`syntax-result-${roomKey}`);
    if (!resultDiv) return;
    resultDiv.innerHTML = '<p style="color:#888;">Running syntax check...</p>';

    try {
      const resp = await fetch(
        `/api/solidability-world/syntax-check?file=${encodeURIComponent(room.filePath)}`,
        { credentials: 'same-origin' }
      );
      const data = await resp.json();
      if (data.ok) {
        resultDiv.innerHTML =
          `<p class="test-pass">✓ Syntax valid — ${escapeHtml(data.file)} parses cleanly.</p>` +
          `<div class="verification-depth" style="margin-top:8px;font-size:11px;color:#888;line-height:1.6;">` +
          `<p style="margin:4px 0;"><strong style="color:#66ff99;">Verified:</strong> JavaScript syntax is valid (node --check passed).</p>` +
          `<p style="margin:4px 0;"><strong style="color:#888;">Not verified:</strong> Runtime behavior, logic correctness, async ordering, error handling, type safety.</p>` +
          `<p style="margin:4px 0;"><strong style="color:#ffaa44;">Compatibility:</strong> Check Node version, dependency APIs, and browser support for modern syntax.</p>` +
          `</div>`;
      } else {
        resultDiv.innerHTML =
          `<p class="test-fail">✗ Syntax error in ${escapeHtml(data.file || room.filePath)}:</p>` +
          `<pre class="test-error">${escapeHtml(data.error || 'Unknown error')}</pre>`;
      }
    } catch (e) {
      resultDiv.innerHTML = `<p class="test-fail">✗ Check failed: ${escapeHtml(e.message)}</p>`;
    }
  }

  function describeRoom(room) {
    const descriptions = {
      'auth': 'Handles user authentication: login, logout, sessions, and access control. Guards the gates between anonymous and authorized areas.',
      'forum': 'Powers the discussion boards: threads, posts, categories. The social heart of Epistles.',
      'ai': 'AI system integrations: Solid chat, SABLE, PROVOLTA. Includes abuse scanning and rate limiting (DEF-001 verified).',
      'legal': 'Legal Center: terms, privacy, compliance pages. 8 routes serving legal documents.'
    };
    return descriptions[room.key] || `Component group containing ${room.routes.length} routes from server.js.`;
  }

  function inferDependencies(room) {
    const depMap = {
      'auth': 'Session store, password hashing, database (users table)',
      'forum': 'Database (threads, posts), authentication middleware',
      'ai': 'abuseGuard, rateLimit, SABLE API key pool, session',
      'legal': 'Static content renderer, no database dependencies'
    };
    return depMap[room.key] || 'Dependencies inferred from route patterns. Full analysis in Phase 2.';
  }

  function escapeHtml(s) {
    return String(s).replace(/&/g,'&amp;').replace(/</g,'&lt;')
                    .replace(/>/g,'&gt;').replace(/"/g,'&quot;');
  }

  // Navigation: search + back
  function search(query) {
    if (!SWWorld.getLayout()) return;
    const q = query.toLowerCase();
    const match = SWWorld.getLayout().rooms.find(r =>
      r.label.toLowerCase().includes(q) ||
      r.routes.some(rt => rt.name.toLowerCase().includes(q))
    );
    if (match) {
      // Push current to back stack
      const player = SWEngine.getPlayer();
      backStack.push({ x: player.position.x, y: player.position.y, z: player.position.z });
      // Teleport
      player.position.set(match.position.x, match.position.y + 1, match.position.z + match.size.depth);
      show(match);
    }
    return match;
  }

  function goBack() {
    const prev = backStack.pop();
    if (prev) {
      const player = SWEngine.getPlayer();
      player.position.set(prev.x, prev.y, prev.z);
    }
  }

  // Load source code for a room's routes from Source Window API
  // Load real source code for a file (authenticated, redacted server-side)
  async function loadSource(roomKey) {
    const layout = SWWorld.getLayout();
    const room = layout.rooms.find(r => r.key === roomKey);
    if (!room) return;

    // Open the code inspection panel
    openCodePanel(room);
  }

  // Full code inspection panel — shows real source with line numbers
  async function openCodePanel(room) {
    let codePanel = document.getElementById('code-inspector');
    if (!codePanel) {
      codePanel = document.createElement('div');
      codePanel.id = 'code-inspector';
      document.getElementById('app').appendChild(codePanel);
    }

    const filePath = room.filePath || 'server.js';
    codePanel.innerHTML = `
      <div class="code-header">
        <h3>📄 ${escapeHtml(room.label)}</h3>
    