<!-- SOLIDABILITY-WORLD · part 48 -->
eturn;
    if (!investigating) {
      btn.style.borderColor = ''; btn.style.background = '';
    } else if (paused) {
      btn.style.borderColor = '#ffaa44'; btn.style.background = 'rgba(255,170,68,0.3)';
    } else {
      btn.style.borderColor = '#ffaa44'; btn.style.background = 'rgba(255,170,68,0.2)';
    }
  }

  function isInvestigating() { return investigating; }
  function isPaused() { return paused; }
  function getCurrentCase() { return currentCase; }
  function getQueueLength() { return investigationQueue.length; }
  function getMemory() { return { ...investigationMemory }; }
  function clearMemory() { investigationMemory = {}; saveMemory(); }

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

  return {
    startInvestigation, stop, toggle, pause, resume,
    isInvestigating, isPaused, getCurrentCase, getQueueLength,
    getMemory, clearMemory,
  };
})();


===== FILE: public/solidability-world/js/sw-layout.js =====
// Solidability World — Layout Engine
// Converts code structure into deterministic 3D coordinates.
// Same code revision → same layout. Different code → visibly different layout.

const SWLayout = (() => {
  // Deterministic hash for stable positioning
  function hashStr(s) {
    let h = 0;
    for (let i = 0; i < s.length; i++) {
      h = ((h << 5) - h + s.charCodeAt(i)) | 0;
    }
    return Math.abs(h);
  }

  // Complexity score: drives room size (not line count)
  function complexityScore(room) {
    const routes = room.routes || [];
    let score = routes.length * 2; // base: number of endpoints
    // Bonus for auth/security (high coupling)
    if (room.key === 'auth') score += 15;
    if (room.key === 'ai') score += 20; // AI systems are architecturally significant
    if (room.key === 'legal') score += 5;
    return Math.max(score, 8); // minimum room size
  }

  // Generate layout for the prototype world
  function generateLayout(worldData) {    const layout = {
      building: { width: 60, depth: 40, floors: 2, floorHeight: 8 },
      doors: [],
      rooms: [],
      hallways: [],
      lights: []
    };

    const roomKeys = Object.keys(worldData.rooms);
    const roomsPerFloor = Math.ceil(roomKeys.length / layout.building.floors);

    roomKeys.forEach((key, idx) => {
      const room = worldData.rooms[key];
      const floor = Math.floor(idx / roomsPerFloor); // 0 or 1
      const posInFloor = idx % roomsPerFloor;

      const complexity = complexityScore({ ...room, key });
      // Room size from complexity: 8x8 base, scaling up
      const roomSize = 8 + Math.min(complexity * 0.4, 12);

      // Position: spread across floor, no overlap
      const x = -20 + (posInFloor * 25);
      const z = 0;
      const y = floor * layout.building.floorHeight;

      const roomLayout = {
        key,
        stable_id: stableId(`epistles:server.js:room:${key}`),
        component_id: `epistles:server.js:room:${key}`,
        label: room.label,
        floor,
        position: { x, y, z },
        size: { width: roomSize, depth: roomSize, height: 6 },
        routes: room.routes,
        verification: worldData.verification[key]
      };

      layout.rooms.push(roomLayout);

      // Alarm light: positioned at room CORNER (not center — was blocking labels)
      const cornerX = x + roomSize / 2 - 1;
      const cornerZ = z + roomSize / 2 - 1;
      layout.lights.push({
        roomKey: key,
        position: { x: cornerX, y: y + 7, z: cornerZ },
        status: verificationToLight(worldData.verification[key].status)
      });

      // Door: at building entrance for floor 0, at stairwell for floor 1
      if (floor === 0) {
        layout.doors.push({
          label: `${room.label} →`,
          target: key,
          position: { x, y: 0, z: -18 }
        });
      }
    });

    // Hallways: connect doors to rooms on each floor
    layout.hallways.push({
      floor: 0,
      from: { x: -25, z: -18 },
      to: { x: 25, z: -18 },
      label: "Main Corridor — server.js routes 1–200"
    });
    layout.hallways.push({
      floor: 1,
      from: { x: -25, z: -18 },
      to: { x: 25, z: -18 },
      label: "Upper Corridor — server.js routes 201–467"
    });

    // Staircase and elevator: placed in open floor space on the right side
    // (x=22-26), clear of all rooms. Bottom landing opens into hallway.
    // Stairs run from z=-10 (bottom, y=0) to z=-17 (top, y=8).
    layout.stairs = { position: { x: 22, y: 0, z: -10 } };
    layout.elevator = { position: { x: 26, y: 0, z: -10 } };

    return layout;
  }

  // Alarm light mapping:
  // OFF = no detected issue OR untested (unknown is not a malfunction)
  // BLINKING = actually running rough / abnormal behavior detected
  // SOLID = confirmed problem
  function verificationToLight(status) {
    switch (status) {
      case 'verified': return 'off';