<!-- SOLIDABILITY-WORLD · part 30 -->
8px;">These are opportunities, not defects. Old syntax works unless proven otherwise.</p>';

      const catOrder = ['risk', 'maintainability', 'stylistic'];
      const catLabels = { risk: 'Potential Risk', maintainability: 'Maintainability', stylistic: 'Stylistic' };
      catOrder.forEach(cat => {
        const items = byCat[cat];
        if (!items || !items.length) return;
        html += `<p style="font-size:12px;color:${items[0].category_color || '#888'};font-weight:bold;margin:8px 0 4px 0;">${catLabels[cat]} (${items.length})</p>`;
        items.forEach(p => {
          html += `<div class="pattern-item" style="margin-bottom:8px;background:rgba(255,255,255,0.03);border-radius:8px;padding:10px;">`;
          html += `<p style="margin:0 0 4px 0;font-size:13px;"><strong>${escapeHtml(p.title)}</strong> <span style="color:#666;font-size:11px;">line ${p.line}</span></p>`;
          html += `<p style="font-size:11px;color:#666;font-family:monospace;margin:4px 0;">${escapeHtml(p.code)}</p>`;
          html += `<p style="font-size:12px;color:#bbb;margin:4px 0;">${escapeHtml(p.suggestion)}</p>`;
          if (p.category_note) {
            html += `<p style="font-size:11px;color:#888;font-style:italic;margin:4px 0;">${escapeHtml(p.category_note)}</p>`;
          }
          html += `</div>`;
        });
      });
      html += '</div>';
    }

    // Branch connections: function tree with verified call relationships
    // Per GPT-6: distinguish verified calls from inferred connections
    const branchFuncs = room.functions || [];
    if (branchFuncs.length > 0 && branchFuncs.length <= 20) {
      html += '<div class="branch-section" style="margin-top:12px;">';
      html += '<h4 style="color:#aaa;margin:0 0 8px 0;">🔀 Code Branches</h4>';
      html += '<p style="font-size:11px;color:#666;margin-bottom:8px;">';
      html += '<span style="color:#00ffcc;">→</span> verified call &nbsp;';
      html += '<span style="color:#888;">⇢</span> dependency &nbsp;';
      html += '<span style="color:#666;">?</span> unresolved</p>';
      html += '<div class="branch-list">';
      branchFuncs.slice(0, 12).forEach((fn) => {
        const calls = fn.calls || [];
        const callers = fn.called_by || [];
        html += `<div class="branch-node" style="margin:6px 0;font-size:12px;">`;
        html += `<div style="display:flex;align-items:center;gap:8px;">`;
        html += `<span style="color:#00ffcc;">●</span>`;
        html += `<span style="color:#ddd;font-family:monospace;">${escapeHtml(fn.name)}()</span>`;
        html += `<span style="color:#666;">line ${fn.line}</span>`;
        html += `</div>`;
        if (calls.length > 0) {
          html += `<div style="margin-left:20px;font-size:11px;color:#888;">`;
          html += `<span style="color:#00ffcc;">→</span> calls: ${calls.slice(0, 5).map(c => `<code style="color:#aaffee;">${escapeHtml(c)}()</code>`).join(', ')}`;
          if (calls.length > 5) html += ` <span style="color:#666;">+${calls.length - 5}</span>`;
          html += `</div>`;
        }
        if (callers.length > 0 && callers.length <= 3) {
          html += `<div style="margin-left:20px;font-size:11px;color:#666;">`;
          html += `called by: ${callers.map(c => escapeHtml(c)).join(', ')}`;
          html += `</div>`;
        }
        html += `</div>`;
      });
      if (branchFuncs.length > 12) {
        html += `<p style="font-size:11px;color:#666;">+ ${branchFuncs.length - 12} more functions</p>`;
      }
      // Dependencies (imports)
      const deps = room.dependencies || [];
      if (deps.length > 0) {
        html += `<p style="font-size:11px;color:#888;margin-top:8px;"><span style="color:#888;">⇢</span> ${deps.length} external dependencies (imports)</p>`;
      }
      // Routes
      const routes = room.routes || [];
      if (routes.length > 0) {
        html += `<p style="font-size:11px;color:#888;"><span style="color:#00ffcc;">→</span> ${routes.length} route handlers</p>`;
      }
      html += '</div></div>';
    }

    html += `<p style="color:#666;font-size:11px;margin-top:8px;">
      Analysis: structural only. Runtime behavior (async order, error paths)
      requires execution tracing — not inferred.</p></div>`;

    return html;
  }

  // Explain why a building has its dimensions (deterministic calculation)
  function geometryExplanation(room) {
    if (!room.filePath) return '';
    const deps = (room.dependencies || []).length;
    const funcs = (room.functions || []).length;
    const routes = (room.routes || []).length;
    // Reconstruct branching from complexity
    const branching = Math.max(0, (room.complexity || 0) - deps * 2 - funcs - routes * 3);
    return `Width ${room.size.width.toFixed(1)}m = 4 + complexity×0.15. ` +
      `Height ${room.size.height.toFixed(1)}m = 3 + complexity×0.2. ` +
      `Complexity ${room.complexity} = ${deps} dependencies×2 + ${branching} branches + ` +
      `${funcs} functions + ${routes} ro