<!-- SOLIDABILITY-WORLD · part 26 -->
ath.max(1, Math.min(6, Math.floor(logC) + 1));

    // Scaling limitation note (displayed in Glass per GPT-6)
    const scalingNote = complexity > 1000
      ? `Note: At complexity ${complexity}, linear scaling would cap. ` +
        `Logarithmic scaling preserves distinction but compresses range. ` +
        `Internal structure (${floors} floors) represents depth.`
      : null;

    return {
      width, depth, height, floors,
      explanation:
        `Width ${width.toFixed(1)}m = 4 + log10(${complexity})×3.2. ` +
        `Height ${height.toFixed(1)}m = 3 + log10(${complexity})×7. ` +
        `Floors: ${floors} (complexity tiers). ` +
        `Complexity ${complexity} = ${deps} deps×2 + ${branching} branches + ` +
        `${funcs} functions + ${routes} routes×3.`,
      scalingNote,
      rawComplexity: complexity,
    };
  }

  // Calculate district layout from directory analysis
  // Returns positioned districts in a spiral (most complex at center)
  // Guarantees minimum separation to prevent pad overlaps
  function layoutDistricts(directories, spacing = 80) {
    const dirs = Object.entries(directories)
      .map(([name, data]) => ({ name, ...data }))
      .sort((a, b) => b.complexity - a.complexity);

    const positioned = [];
    const goldenAngle = Math.PI * (3 - Math.sqrt(5)); // ~137.5°
    const minSeparation = 75; // pads are 70m, need 75m clearance

    dirs.forEach((dir, idx) => {
      let x, z;
      if (idx === 0) {
        x = 0; z = 0; // most complex at center
      } else {
        // Spiral outward, ensuring minimum separation from all placed districts
        let radius = spacing * 0.7 * Math.sqrt(idx);
        let theta = idx * goldenAngle;
        let attempts = 0;
        do {
          x = radius * Math.cos(theta);
          z = radius * Math.sin(theta);
          // Check distance to all placed districts
          const tooClose = positioned.some(p => {
            const dist = Math.hypot(p.position.x - x, p.position.z - z);
            return dist < minSeparation;
          });
          if (!tooClose) break;
          // Expand radius and rotate
          radius += 10;
          theta += 0.3;
          attempts++;
        } while (attempts < 50);
      }
      positioned.push({
        name: dir.name,
        position: { x: Math.round(x), z: Math.round(z) },
        fileCount: dir.file_count,
        complexity: dir.complexity,
        routeCount: dir.route_count,
      });
    });

    return positioned;
  }

  // Arrange files within a district (grid by complexity rank)
  // Dynamic spacing prevents building overlaps
  function layoutFiles(files, districtPos, maxFiles = 50) {
    const sorted = [...files]
      .sort((a, b) => b.complexity - a.complexity)
      .slice(0, maxFiles);

    // Calculate max building width to determine spacing
    const maxWidth = Math.max(...sorted.map(f => {
      const b = fileToBuilding(f);
      return b.width;
    }), 4);
    const spacing = maxWidth + 3; // 3m gap between buildings

    const cols = Math.ceil(Math.sqrt(sorted.length));

    return sorted.map((file, idx) => {
      const building = fileToBuilding(file);
      const gx = (idx % cols) - (cols - 1) / 2;
      const gz = Math.floor(idx / cols) - (Math.ceil(sorted.length / cols) - 1) / 2;

      return {
        key: 'file_' + file.path.replace(/[^a-zA-Z0-9]/g, '_'),
        label: file.name,
        filePath: file.path,
        language: file.language,
        district: null, // set by caller
        position: {
          x: districtPos.x + gx * spacing,
          y: 0,
          z: districtPos.z + gz * spacing,
        },
        size: {
          width: building.width,
          depth: building.depth,
          height: building.height,
        },
        floors: building.floors,
        geometryExplanation: building.explanation,
        scalingNote: building.scalingNote,
        rawComplexity: building.rawComplexity,
        routes: (file.routes || []).map(r => ({
          name: `${r.method} ${r.path}`,
          line: r.line,
          type: 'route',
        })),
        functions: file.functions || [],
        dependencies: file.dependencies || [],
        complexity: file.complexity,
        lines: file.lines,
        age_days: file.age_days,
        has_test: file.has_test,
        size_bytes: file.size_bytes,
        outdated_patterns: file.outdated_patterns || [],
        verification: { status: 'untested', note: 'Not yet verified' },
      };
    });
  }

  // Full world layout from architectural map
  function mapToWorld(archMap) {
    const districts = layoutDistricts(archMap.directories);
    const rooms = [];

    districts.forEach(district => {
      const dirData = archMap.directories[district.name];
      if (!dirData) return;
      const files = layoutFiles(dirData.files, district.position);
      files.forEach(f => { f.district = district.name; });
      rooms.push(...files);
    });

    return {
      building: