// Isometric mini-diorama rooms. Viewbox 300x200.
// Uses volumetric Box3D helpers so furniture reads as real volume.

function RoomFrame({ children, tint = "#4FD8FF", floorTint = "#1a3550", wallTint = "#152a44", accent2 = "#7AE0FF" }) {
  const id = React.useMemo(() => "rf" + Math.random().toString(36).slice(2, 7), []);
  return (
    <svg viewBox="0 0 300 200" width="100%" height="100%" preserveAspectRatio="xMidYMid slice" style={{ display: "block" }}>
      <defs>
        <linearGradient id={`wall-${id}`} x1="0" x2="0" y1="0" y2="1">
          <stop offset="0" stopColor={wallTint} stopOpacity="1" />
          <stop offset="1" stopColor="#040812" stopOpacity="1" />
        </linearGradient>
        <linearGradient id={`wallL-${id}`} x1="0" x2="1" y1="0.5" y2="0.5">
          <stop offset="0" stopColor="#020509" stopOpacity="1" />
          <stop offset="1" stopColor={wallTint} stopOpacity="0.9" />
        </linearGradient>
        <linearGradient id={`wallR-${id}`} x1="1" x2="0" y1="0.5" y2="0.5">
          <stop offset="0" stopColor="#020509" stopOpacity="1" />
          <stop offset="1" stopColor={wallTint} stopOpacity="0.9" />
        </linearGradient>
        <linearGradient id={`floor-${id}`} x1="0.5" x2="0.5" y1="0" y2="1">
          <stop offset="0" stopColor={floorTint} stopOpacity="1" />
          <stop offset="0.4" stopColor="#05101c" />
          <stop offset="1" stopColor="#020509" />
        </linearGradient>
        <radialGradient id={`amb-${id}`} cx="0.5" cy="0.35" r="0.75">
          <stop offset="0" stopColor={tint} stopOpacity="0.32" />
          <stop offset="0.6" stopColor={tint} stopOpacity="0.08" />
          <stop offset="1" stopColor={tint} stopOpacity="0" />
        </radialGradient>
        <radialGradient id={`floorGlow-${id}`} cx="0.5" cy="0.8" r="0.55">
          <stop offset="0" stopColor={tint} stopOpacity="0.35" />
          <stop offset="1" stopColor={tint} stopOpacity="0" />
        </radialGradient>
        <linearGradient id={`topLight-${id}`} x1="0" x2="0" y1="0" y2="1">
          <stop offset="0" stopColor={accent2} stopOpacity="0.22" />
          <stop offset="1" stopColor={tint} stopOpacity="0" />
        </linearGradient>
        <pattern id={`grid-${id}`} width="24" height="20" patternUnits="userSpaceOnUse">
          <path d="M24 0 L0 0 0 20" fill="none" stroke={tint} strokeWidth="0.4" opacity="0.14" />
        </pattern>
        <linearGradient id={`refl-${id}`} x1="0" x2="0" y1="0" y2="1">
          <stop offset="0" stopColor={tint} stopOpacity="0.08" />
          <stop offset="1" stopColor={tint} stopOpacity="0" />
        </linearGradient>
      </defs>

      <rect x="0" y="0" width="300" height="200" fill="#02060c" />

      {/* ===== ROOM SHELL — isometric box ===== */}
      <polygon points="30,10 270,10 270,128 30,128" fill={`url(#wall-${id})`} />
      <polygon points="30,10 270,10 270,128 30,128" fill={`url(#grid-${id})`} />
      <polygon points="0,0 30,10 30,128 0,140" fill={`url(#wallL-${id})`} />
      <polygon points="270,10 300,0 300,140 270,128" fill={`url(#wallR-${id})`} />
      <polygon points="0,0 300,0 270,10 30,10" fill="#010306" opacity="0.95" />
      <line x1="0" y1="0" x2="30" y2="10" stroke={tint} strokeWidth="0.4" opacity="0.3" />
      <line x1="300" y1="0" x2="270" y2="10" stroke={tint} strokeWidth="0.4" opacity="0.3" />

      {/* ceiling light strip */}
      <rect x="40" y="6" width="220" height="2" fill={accent2} opacity="0.55" />
      <rect x="40" y="6" width="220" height="7" fill={`url(#topLight-${id})`} opacity="0.7" />

      {/* wall-floor seam */}
      <polygon points="0,140 30,128 270,128 300,140" fill={tint} opacity="0.22" />
      <line x1="30" y1="128" x2="270" y2="128" stroke={accent2} strokeWidth="0.7" opacity="0.75" />

      {/* floor */}
      <polygon points="0,140 300,140 300,200 0,200" fill={`url(#floor-${id})`} />
      <g opacity="0.3" stroke={tint} strokeWidth="0.4" fill="none">
        <line x1="30" y1="128" x2="0" y2="200" />
        <line x1="80" y1="128" x2="70" y2="200" />
        <line x1="150" y1="128" x2="150" y2="200" />
        <line x1="220" y1="128" x2="230" y2="200" />
        <line x1="270" y1="128" x2="300" y2="200" />
        <line x1="0" y1="160" x2="300" y2="160" opacity="0.5" />
        <line x1="0" y1="178" x2="300" y2="178" opacity="0.5" />
      </g>
      <rect x="0" y="140" width="300" height="60" fill={`url(#floorGlow-${id})`} />
      <rect x="0" y="0" width="300" height="200" fill={`url(#amb-${id})`} />

      {children}

      <rect x="0" y="140" width="300" height="30" fill={`url(#refl-${id})`} pointerEvents="none" />
      <rect x="0" y="0" width="300" height="200" fill="url(#vignette)" pointerEvents="none" />
    </svg>
  );
}

function SharedDefs() {
  return (
    <svg width="0" height="0" style={{ position: "absolute" }}>
      <defs>
        <radialGradient id="vignette" cx="0.5" cy="0.5" r="0.75">
          <stop offset="0.6" stopColor="#000" stopOpacity="0" />
          <stop offset="1" stopColor="#000" stopOpacity="0.55" />
        </radialGradient>
      </defs>
    </svg>
  );
}

// ============================================================
// VOLUMETRIC HELPERS
// ============================================================

// Box3D — true isometric box with top, front, and right-side faces.
// (cx, baseY) is center of the front-bottom edge; depth pushes back-up.
function Box3D({ cx, baseY, w, h, depth = 10, color = "#4FD8FF", dark = "#0a1628", top, children }) {
  const x0 = cx - w / 2;
  const x1 = cx + w / 2;
  const y0 = baseY;            // front-bottom
  const y1 = baseY - h;        // front-top
  const dx = depth * 0.9;
  const dy = depth * 0.45;
  const tx0 = x0 + dx, tx1 = x1 + dx, ty = y1 - dy;
  // ground shadow
  return (
    <g>
      <ellipse cx={cx + 1} cy={y0 + 2} rx={w / 2 + 2} ry={2.5} fill="#000" opacity="0.45" />
      {/* right face */}
      <polygon points={`${x1},${y0} ${tx1},${y0 - dy} ${tx1},${ty} ${x1},${y1}`} fill={dark} stroke={color} strokeWidth="0.35" opacity="0.95" />
      {/* front face */}
      <polygon points={`${x0},${y0} ${x1},${y0} ${x1},${y1} ${x0},${y1}`} fill={dark} stroke={color} strokeWidth="0.45" />
      {/* top face */}
      <polygon points={`${x0},${y1} ${x1},${y1} ${tx1},${ty} ${tx0},${ty}`} fill={top || dark} stroke={color} strokeWidth="0.4" opacity="0.98" />
      {/* front top highlight */}
      <line x1={x0} y1={y1} x2={x1} y2={y1} stroke={color} strokeWidth="0.45" opacity="0.8" />
      {/* right edge highlight */}
      <line x1={x1} y1={y1} x2={tx1} y2={ty} stroke={color} strokeWidth="0.3" opacity="0.5" />
      {children && <g transform={`translate(${x0},${y1})`}>{children({ w, h })}</g>}
    </g>
  );
}

// Pillar — vertical column with subtle front highlight.
function Pillar({ x, top, bottom, w = 4, color = "#4FD8FF", dark = "#0a1628" }) {
  return (
    <g>
      <rect x={x - w / 2} y={top} width={w} height={bottom - top} fill={dark} stroke={color} strokeWidth="0.3" />
      <rect x={x - w / 2 + 0.4} y={top} width={0.6} height={bottom - top} fill={color} opacity="0.45" />
    </g>
  );
}

// WallPanel — recessed paneling with rim light, lives flat on back wall.
function WallPanel({ x, y, w, h, color = "#4FD8FF", children }) {
  return (
    <g>
      <rect x={x} y={y} width={w} height={h} fill="#050c18" stroke={color} strokeWidth="0.4" opacity="0.9" />
      <rect x={x + 0.6} y={y + 0.6} width={w - 1.2} height="0.5" fill={color} opacity="0.55" />
      {children}
    </g>
  );
}

// Screen — premium bezel with inner glass gradient.
function Screen({ x, y, w, h, color = "#4FD8FF", children }) {
  const id = React.useMemo(() => "sc" + Math.random().toString(36).slice(2, 7), []);
  return (
    <g transform={`translate(${x},${y})`}>
      <defs>
        <linearGradient id={`bezel-${id}`} x1="0" y1="0" x2="0" y2="1">
          <stop offset="0" stopColor="#1a2740" />
          <stop offset="1" stopColor="#050a14" />
        </linearGradient>
        <linearGradient id={`glass-${id}`} x1="0" y1="0" x2="0" y2="1">
          <stop offset="0" stopColor={color} stopOpacity="0.22" />
          <stop offset="0.3" stopColor="#050d18" stopOpacity="1" />
          <stop offset="1" stopColor="#02060c" stopOpacity="1" />
        </linearGradient>
      </defs>
      <rect x="-1.2" y="-1.2" width={w + 2.4} height={h + 2.4} rx="2.4" fill={`url(#bezel-${id})`} />
      <rect x="0" y="0" width={w} height={h} rx="1.8" fill="#050d18" stroke={color} strokeWidth="0.55" />
      <rect x="0.5" y="0.5" width={w - 1} height={h - 1} rx="1.5" fill={`url(#glass-${id})`} />
      <rect x="2" y="1.6" width={w - 4} height="0.5" fill={color} opacity="0.5" />
      {children}
      <path d={`M 1 1 L ${w * 0.35} 1 L ${w * 0.25} ${h - 1} L 1 ${h - 1} Z`} fill="#fff" opacity="0.03" />
    </g>
  );
}

// Plant — small potted plant used as set-dressing.
function Plant({ x, y, color = "#52b788", potColor = "#1a2a3a", ring = "#4FD8FF" }) {
  return (
    <g transform={`translate(${x},${y})`}>
      <path d="M-3 4 L3 4 L2.4 10 L-2.4 10 Z" fill={potColor} stroke={ring} strokeWidth="0.35" />
      <rect x="-3.2" y="3" width="6.4" height="1.3" fill={ring} opacity="0.35" />
      <path d="M0 4 Q -6 -4 -4 -10 M0 4 Q 6 -4 4 -10 M0 4 Q 0 -6 0 -12 M0 4 Q -4 -2 -3 -8 M0 4 Q 4 -2 3 -8"
        stroke={color} strokeWidth="1.35" fill="none" strokeLinecap="round" />
    </g>
  );
}

// Trim — baseboard strip on back wall.
function Baseboard({ color = "#4FD8FF", opacity = 0.4 }) {
  return (
    <g>
      <rect x="30" y="124" width="240" height="2.2" fill={color} opacity={opacity} />
      <rect x="30" y="124" width="240" height="0.5" fill={color} opacity={Math.min(1, opacity + 0.3)} />
    </g>
  );
}

// ------------------------------------------------------------
// EMPTY ROOM LABEL — shown in any room when no agents are assigned.
// Same visual across all rooms, tinted by the caller's palette.
// ------------------------------------------------------------
function EmptyRoomLabel({ tint, label = "ESPERANDO ASIGNACIÓN" }) {
  const w = Math.max(100, label.length * 3.3 + 22);
  return (
    <g transform="translate(150, 176)" style={{ pointerEvents: "none" }}>
      <rect
        x={-w / 2} y={-7} width={w} height={14} rx={7}
        fill="rgba(4, 10, 20, 0.78)"
        stroke={tint} strokeWidth="0.45" opacity="0.88"
      />
      <circle cx={-w / 2 + 8} cy={0} r={1.8} fill={tint}>
        <animate attributeName="opacity" values="0.3;1;0.3" dur="2.4s" repeatCount="indefinite" />
      </circle>
      <text
        x={4} y={1.9} textAnchor="middle" fontSize="4.6"
        fill="#C5E4F4" fontFamily="Inter, sans-serif"
        fontWeight="700" letterSpacing="1.4"
      >
        {label}
      </text>
    </g>
  );
}

// ============ GENERIC ROOM (user-created) ============
// Clean but premium shell for rooms created dynamically by the operator.
// Uses the RoomFrame base + a minimal prop set in the back wall + an empty
// state label when no agents are assigned. Colour comes from the caller's
// tint so each generic room keeps its identity.
function GenericRoom({ agents, tint, title }) {
  const T = tint || "#7EE8FF";
  const A = "#BEF2FF";
  return (
    <RoomFrame tint={T} floorTint="#0e2a48" wallTint="#152a44" accent2={A}>
      {/* Back wall: 3 subtle screens */}
      <rect x="60"  y="22" width="52" height="36" fill="#060f1b" stroke={T} strokeWidth="0.6" opacity="0.85" />
      <rect x="124" y="22" width="52" height="36" fill="#060f1b" stroke={T} strokeWidth="0.8" opacity="0.95" />
      <rect x="188" y="22" width="52" height="36" fill="#060f1b" stroke={T} strokeWidth="0.6" opacity="0.85" />
      <rect x="62"  y="26" width="48" height="28" fill={T} opacity="0.06" />
      <rect x="126" y="26" width="48" height="28" fill={T} opacity="0.1" />
      <rect x="190" y="26" width="48" height="28" fill={T} opacity="0.06" />

      {/* Floor accent — subtle platform */}
      <ellipse cx="150" cy="150" rx="66" ry="12" fill="none" stroke={T} strokeWidth="0.5" opacity="0.35" />
      <ellipse cx="150" cy="150" rx="46" ry="8"  fill="none" stroke={T} strokeWidth="0.5" opacity="0.45" />
      <circle  cx="150" cy="150" r="3"  fill={T} opacity="0.85" />

      {/* Side desks (volumetric) */}
      <Box3D cx={48}  baseY={148} w={26} h={10} depth={7} color={T} dark="#091a2e" top="#143055" />
      <Box3D cx={252} baseY={148} w={26} h={10} depth={7} color={T} dark="#091a2e" top="#143055" />

      {/* Plants in corners */}
      <Plant x="22"  y="162" color="#52b788" ring={T} />
      <Plant x="278" y="162" color="#52b788" ring={T} />

      <Baseboard color={T} opacity={0.35} />

      {(agents || []).map((a, i) => {
        const positions = [{x: 104, y: 160}, {x: 196, y: 160}, {x: 150, y: 180}];
        const pos = positions[i % 3];
        return (
          <RoomBot key={a.id} color={a.color} name={a.name} activity={a.activity}
            x={pos.x} y={pos.y} size={26} idx={i}
            facing={i === 1 ? "right" : "front"} />
        );
      })}
      {(!agents || agents.length === 0) && <EmptyRoomLabel tint={T} />}
    </RoomFrame>
  );
}

// ============ ROOM 1: JARVIS OFFICE ============
function JarvisOffice({ agents }) {
  const T = "#4FD8FF", A = "#7AE0FF";
  return (
    <RoomFrame tint={T} floorTint="#0e2a48" wallTint="#0f2544" accent2={A}>
      {/* ceiling lights — recessed */}
      <g opacity="0.85">
        <rect x="60" y="4" width="40" height="3" rx="1" fill={A} opacity="0.5" />
        <rect x="130" y="4" width="40" height="3" rx="1" fill={A} opacity="0.65" />
        <rect x="200" y="4" width="40" height="3" rx="1" fill={A} opacity="0.5" />
      </g>

      {/* giant subtle "JARVIS" on back wall */}
      <text x="150" y="90" textAnchor="middle" fontFamily="Inter, sans-serif" fontWeight="900" fontSize="24" fill={T} opacity="0.05" letterSpacing="8">JARVIS</text>

      {/* back wall — triptych in paneled frame */}
      <WallPanel x="28" y="16" w="244" h="62" color={T}>
        <line x1="28" y1="76" x2="272" y2="76" stroke={T} strokeWidth="0.4" opacity="0.45" />
      </WallPanel>

      <Screen x="36" y="22" w={70} h={50} color={T}>
        <text x="4" y="8" fontSize="3.2" fill={T} fontFamily="monospace" opacity="0.85">NET · 99.8%</text>
        <g stroke={T} strokeWidth="0.5" fill="none">
          <path d="M4 34 L14 24 L24 30 L34 18 L44 26 L54 16 L64 22" />
          <circle cx="64" cy="22" r="1.5" fill={T} />
        </g>
        <path d="M4 34 L14 24 L24 30 L34 18 L44 26 L54 16 L64 22 L64 46 L4 46 Z" fill={T} opacity="0.18" />
        <rect x="4" y="40" width="22" height="2" fill={T} opacity="0.7" />
        <rect x="4" y="43" width="32" height="0.8" fill={T} opacity="0.35" />
      </Screen>
      <Screen x="115" y="17" w={70} h={55} color={A}>
        <text x="4" y="8" fontSize="3.2" fill={A} fontFamily="monospace" opacity="0.85">MAINFRAME · JARVIS</text>
        <circle cx="35" cy="30" r="17" fill="none" stroke={A} strokeWidth="0.55" />
        <circle cx="35" cy="30" r="12" fill="none" stroke={A} strokeWidth="0.4" opacity="0.65" />
        <circle cx="35" cy="30" r="7" fill={A} opacity="0.35" />
        <circle cx="35" cy="30" r="2.5" fill="#fff" />
        <g stroke={A} strokeWidth="0.3" opacity="0.6">
          <line x1="35" y1="13" x2="35" y2="18" />
          <line x1="35" y1="42" x2="35" y2="47" />
          <line x1="18" y1="30" x2="23" y2="30" />
          <line x1="47" y1="30" x2="52" y2="30" />
        </g>
        <text x="35" y="52" textAnchor="middle" fontSize="3.2" fill={A} fontFamily="monospace" letterSpacing="1">CORE ACTIVE</text>
      </Screen>
      <Screen x="194" y="22" w={70} h={50} color={T}>
        <text x="4" y="8" fontSize="3.2" fill={T} fontFamily="monospace" opacity="0.85">OPS · 24h</text>
        <g fill={T} opacity="0.9">
          {[10,18,14,22,12,24,16].map((v, i) => (
            <rect key={i} x={4 + i * 7} y={46 - v} width="4" height={v} />
          ))}
        </g>
        <rect x="54" y="12" width="14" height="10" fill="none" stroke={T} strokeWidth="0.4" />
        <circle cx="61" cy="17" r="2" fill={T} />
        <rect x="4" y="40" width="60" height="0.8" fill={T} opacity="0.3" />
      </Screen>

      {/* server rack pillars behind desk */}
      <Pillar x="20" top={30} bottom={128} w={10} color={T} />
      <g>
        {[0,1,2,3,4,5].map(i => (
          <rect key={i} x={16} y={40 + i * 14} width="8" height="2.5" fill={A} opacity={0.35 + (i % 2) * 0.3} />
        ))}
        <circle cx="20" cy="42" r="0.6" fill="#4FE08A" />
        <circle cx="20" cy="70" r="0.6" fill="#4FE08A" />
      </g>
      <Pillar x="280" top={30} bottom={128} w={10} color={T} />
      <g>
        {[0,1,2,3,4,5].map(i => (
          <rect key={i} x={276} y={40 + i * 14} width="8" height="2.5" fill={A} opacity={0.35 + (i % 2) * 0.3} />
        ))}
        <circle cx="280" cy="56" r="0.6" fill="#FFD170" />
        <circle cx="280" cy="84" r="0.6" fill="#4FE08A" />
      </g>

      <Baseboard color={T} opacity={0.5} />

      {/* curved command desk — with volume */}
      <path d="M 32 128 Q 150 108 268 128 L 268 140 Q 150 120 32 140 Z" fill="#0a1a2e" stroke={T} strokeWidth="0.6" />
      <path d="M 32 128 Q 150 108 268 128" stroke={A} strokeWidth="0.5" fill="none" opacity="0.65" />
      {/* desk front lip */}
      <path d="M 32 140 Q 150 120 268 140 L 268 143 Q 150 123 32 143 Z" fill="#050c18" opacity="0.9" />
      {/* console slabs on desk — volumetric */}
      <Box3D cx={62} baseY={128} w={30} h={6} depth={8} color={T} dark="#102440" top="#16355a" />
      <g transform="translate(47 119)">
        <circle cx="0" cy="0" r="0.9" fill="#FF7ABF" />
        <circle cx="3.5" cy="0" r="0.9" fill="#FFD170" />
        <circle cx="7" cy="0" r="0.9" fill="#4FE08A" />
        <rect x="11" y="-1.5" width="16" height="3" fill={T} opacity="0.55" />
      </g>
      <Box3D cx={238} baseY={128} w={30} h={6} depth={8} color={T} dark="#102440" top="#16355a" />
      <g transform="translate(223 119)">
        <rect x="0" y="-1.5" width="16" height="3" fill={T} opacity="0.55" />
        <circle cx="21" cy="0" r="0.9" fill="#4FE08A" />
        <circle cx="24.5" cy="0" r="0.9" fill="#FFD170" />
        <circle cx="28" cy="0" r="0.9" fill="#FF7ABF" />
      </g>
      {/* center desk keyboard slab */}
      <Box3D cx={150} baseY={126} w={48} h={4} depth={6} color={T} dark="#0a1a2e" top="#12294a" />
      <g transform="translate(126 118)">
        {[0,1,2,3,4,5,6,7].map(i => (
          <rect key={i} x={i * 6} y="0" width="4.5" height="2.5" fill={T} opacity="0.4" />
        ))}
      </g>

      {/* ======= central holo platform — layered ======= */}
      <ellipse cx="150" cy="180" rx="58" ry="13" fill="#000" opacity="0.6" />
      {/* base ring with volume */}
      <ellipse cx="150" cy="178" rx="55" ry="12" fill="#071528" stroke={T} strokeWidth="0.5" />
      <path d="M 95 178 A 55 12 0 0 0 205 178 L 203 184 A 53 12 0 0 1 97 184 Z" fill="#050d1a" />
      <ellipse cx="150" cy="176" rx="50" ry="10.5" fill="#0a1e38" stroke={T} strokeWidth="0.5" />
      <ellipse cx="150" cy="174" rx="44" ry="9" fill="none" stroke={A} strokeWidth="0.5" />
      <ellipse cx="150" cy="172" rx="36" ry="7.5" fill="none" stroke={A} strokeWidth="0.35" opacity="0.65" />
      <ellipse cx="150" cy="170" rx="26" ry="5.5" fill={T} opacity="0.28" />
      <ellipse cx="150" cy="168" rx="16" ry="3.8" fill={A} opacity="0.55" />
      {/* arc light segments */}
      <g stroke={A} strokeWidth="0.8" fill="none" opacity="0.8">
        <path d="M 110 176 A 44 9 0 0 1 130 170" />
        <path d="M 170 170 A 44 9 0 0 1 190 176" />
      </g>
      {/* holo beam */}
      <path d="M 150 168 L 136 140 L 164 140 Z" fill={A} opacity="0.18" />
      <path d="M 150 168 L 143 145 L 157 145 Z" fill={A} opacity="0.32" />
      <g transform="translate(150 140)">
        <circle r="2.8" fill="#fff" />
        <circle r="5.5" fill={A} opacity="0.55" />
        <circle r="10" fill={T} opacity="0.22" />
        {/* rotating orbit hint */}
        <ellipse rx="9" ry="3.5" fill="none" stroke={A} strokeWidth="0.4" opacity="0.7" />
      </g>

      {/* foreground corner consoles */}
      <Box3D cx={22} baseY={152} w={16} h={8} depth={7} color={T} dark="#091a2e" top="#143055" />
      <rect x="15" y="140" width="14" height="3" fill={T} opacity="0.55" />
      <Box3D cx={278} baseY={152} w={16} h={8} depth={7} color={T} dark="#091a2e" top="#143055" />
      <rect x="271" y="140" width="14" height="3" fill={T} opacity="0.55" />

      <Plant x="22" y="158" color="#52b788" ring={T} />
      <Plant x="278" y="158" color="#52b788" ring={T} />

      {(agents || []).map((a, i) => {
        // index 0 sits on the central platform — a solo agent (JARVIS) reads as the protagonist
        const positions = [{x: 150, y: 172}, {x: 88, y: 156}, {x: 212, y: 156}];
        const pos = positions[i % 3];
        return (
          <RoomBot key={a.id} color={a.color} name={a.name} activity={a.activity}
            x={pos.x} y={pos.y} size={32} idx={i}
            facing={i === 2 ? "right" : "front"} />
        );
      })}
      {(!agents || agents.length === 0) && <EmptyRoomLabel tint={T} />}
    </RoomFrame>
  );
}

// ============ ROOM 2: STRATEGY ROOM ============
function StrategyRoom({ agents }) {
  const T = "#4FE0A8", A = "#7EF0C4";
  return (
    <RoomFrame tint={T} floorTint="#0e3a30" wallTint="#0f2d28" accent2={A}>
      {/* hanging pendant lights */}
      <g>
        <line x1="110" y1="8" x2="110" y2="20" stroke={T} strokeWidth="0.4" opacity="0.5" />
        <ellipse cx="110" cy="22" rx="6" ry="1.6" fill={A} opacity="0.85" />
        <ellipse cx="110" cy="22" rx="10" ry="3" fill={A} opacity="0.25" />
        <line x1="190" y1="8" x2="190" y2="20" stroke={T} strokeWidth="0.4" opacity="0.5" />
        <ellipse cx="190" cy="22" rx="6" ry="1.6" fill={A} opacity="0.85" />
        <ellipse cx="190" cy="22" rx="10" ry="3" fill={A} opacity="0.25" />
      </g>

      {/* wall section: briefing + center tactical map + KPI */}
      <Screen x="20" y="16" w={58} h={50} color={T}>
        <text x="4" y="8" fontSize="3.2" fill={T} fontFamily="monospace" opacity="0.85">OKR · Q2</text>
        {["Growth","Product","Ops","Comms"].map((l, i) => (
          <g key={l} transform={`translate(4 ${14 + i * 8})`}>
            <text fontSize="3" fill={T} fontFamily="monospace" opacity="0.85">{l}</text>
            <rect x="20" y="-2.5" width="30" height="2.5" fill="#0a1a18" stroke={T} strokeWidth="0.25" />
            <rect x="20" y="-2.5" width={[22, 18, 26, 14][i]} height="2.5" fill={T} opacity={0.8 - i * 0.1} />
            <text x="52" y="-0.5" fontSize="2.4" fill={T} fontFamily="monospace">{[73,60,87,47][i]}%</text>
          </g>
        ))}
      </Screen>

      {/* center map panel with frame */}
      <WallPanel x="84" y="14" w="132" h="54" color={T}>
        <rect x="88" y="18" width="124" height="46" fill="none" stroke={T} strokeWidth="0.3" opacity="0.5" />
        <text x="92" y="22" fontSize="2.8" fill={T} fontFamily="monospace" opacity="0.7" letterSpacing="1">STRATEGY MAP · Q2</text>
        <g transform="translate(96 30)">
          <path d="M2 4 Q 10 0 18 4 Q 24 2 32 5 L 44 3 Q 56 4 68 6 Q 84 3 100 7 Q 106 10 104 14 Q 90 12 76 14 L 60 13 Q 40 16 24 14 Q 10 16 2 12 Z"
                fill={T} opacity="0.25" stroke={T} strokeWidth="0.35" />
          <circle cx="20" cy="8" r="2" fill="#FF7ABF" />
          <circle cx="20" cy="8" r="4" fill="#FF7ABF" opacity="0.3" />
          <circle cx="55" cy="10" r="2" fill="#FFD170" />
          <circle cx="55" cy="10" r="4" fill="#FFD170" opacity="0.3" />
          <circle cx="85" cy="9" r="2" fill="#4FD8FF" />
          <circle cx="85" cy="9" r="4" fill="#4FD8FF" opacity="0.3" />
          <text x="50" y="30" textAnchor="middle" fontSize="2.6" fill={A} fontFamily="monospace" opacity="0.6">3 ACTIVE FRONTS</text>
        </g>
      </WallPanel>

      <Screen x="222" y="16" w={58} h={50} color={T}>
        <text x="4" y="8" fontSize="3.2" fill={T} fontFamily="monospace" opacity="0.85">TARGET · Q2</text>
        <circle cx="28" cy="26" r="14" fill="none" stroke={T} strokeWidth="0.5" />
        <circle cx="28" cy="26" r="10" fill="none" stroke={T} strokeWidth="0.4" opacity="0.65" />
        <circle cx="28" cy="26" r="5.5" fill={T} opacity="0.45" />
        <circle cx="28" cy="26" r="1.8" fill="#fff" />
        <line x1="12" y1="26" x2="44" y2="26" stroke={T} strokeWidth="0.3" opacity="0.6" />
        <line x1="28" y1="10" x2="28" y2="42" stroke={T} strokeWidth="0.3" opacity="0.6" />
        <text x="28" y="47" textAnchor="middle" fontSize="2.8" fill={A} fontFamily="monospace">LOCKED · 92%</text>
      </Screen>

      <Baseboard color={T} opacity={0.45} />

      {/* side benches (volumetric) */}
      <Box3D cx={36} baseY={134} w={28} h={5} depth={7} color={T} dark="#0a201c" top="#153b34" />
      <rect x="26" y="125" width="20" height="5" rx="0.8" fill="#0a201c" stroke={T} strokeWidth="0.35" />
      <circle cx="30" cy="127.5" r="0.9" fill={T} opacity="0.7" />
      <Box3D cx={264} baseY={134} w={28} h={5} depth={7} color={T} dark="#0a201c" top="#153b34" />
      <rect x="254" y="125" width="20" height="5" rx="0.8" fill="#0a201c" stroke={T} strokeWidth="0.35" />
      <rect x="258" y="126.5" width="12" height="2" fill={T} opacity="0.6" />

      {/* ======= tactical holo table — true volume ======= */}
      {/* shadow + trapezoidal base */}
      <ellipse cx="150" cy="180" rx="78" ry="14" fill="#000" opacity="0.5" />
      <polygon points="112,182 188,182 176,168 124,168" fill="#071c18" stroke={T} strokeWidth="0.45" />
      <polygon points="112,182 188,182 185,187 115,187" fill="#050d0c" />
      {/* table top slab */}
      <ellipse cx="150" cy="162" rx="64" ry="14" fill="#0a2620" stroke={T} strokeWidth="0.55" />
      <ellipse cx="150" cy="160" rx="60" ry="12.5" fill="#06201a" />
      <ellipse cx="150" cy="158" rx="54" ry="10.5" fill="#082a22" stroke={T} strokeWidth="0.35" opacity="0.75" />
      {/* hologram surface */}
      <ellipse cx="150" cy="156" rx="46" ry="8.5" fill={T} opacity="0.2" />
      <ellipse cx="150" cy="154" rx="40" ry="7" fill="none" stroke={A} strokeWidth="0.45" />
      <ellipse cx="150" cy="154" rx="28" ry="5" fill="none" stroke={A} strokeWidth="0.4" opacity="0.7" />
      <path d="M114 155 Q 135 149 150 154 Q 165 149 186 155" stroke={A} strokeWidth="0.7" fill="none" />
      <path d="M120 157 Q 140 152 155 155 Q 170 151 180 157" stroke={A} strokeWidth="0.5" fill="none" opacity="0.7" />
      {/* pulsing target markers */}
      <g>
        <circle cx="130" cy="153" r="2" fill="#FF7ABF" />
        <circle cx="130" cy="153" r="4" fill="#FF7ABF" opacity="0.3">
          <animate attributeName="r" values="3;6;3" dur="2.4s" repeatCount="indefinite" />
          <animate attributeName="opacity" values="0.4;0;0.4" dur="2.4s" repeatCount="indefinite" />
        </circle>
        <circle cx="150" cy="150" r="2" fill="#FFD170" />
        <circle cx="150" cy="150" r="4" fill="#FFD170" opacity="0.3">
          <animate attributeName="r" values="3;6;3" dur="2s" repeatCount="indefinite" />
          <animate attributeName="opacity" values="0.4;0;0.4" dur="2s" repeatCount="indefinite" />
        </circle>
        <circle cx="172" cy="154" r="2" fill="#4FD8FF" />
        <circle cx="172" cy="154" r="4" fill="#4FD8FF" opacity="0.3">
          <animate attributeName="r" values="3;6;3" dur="2.8s" repeatCount="indefinite" />
          <animate attributeName="opacity" values="0.4;0;0.4" dur="2.8s" repeatCount="indefinite" />
        </circle>
      </g>
      {/* table under-glow */}
      <ellipse cx="150" cy="168" rx="48" ry="5" fill={T} opacity="0.35" />
      <ellipse cx="150" cy="168" rx="36" ry="3.5" fill={A} opacity="0.4" />

      <Plant x="22" y="150" color="#52b788" ring={T} />
      <Plant x="278" y="150" color="#52b788" ring={T} />

      {(agents || []).map((a, i) => {
        const positions = [{x: 88, y: 178}, {x: 212, y: 178}, {x: 150, y: 190}, {x: 60, y: 188}];
        const pos = positions[i % 4];
        return (
          <RoomBot key={a.id} color={a.color} name={a.name} activity={a.activity}
            x={pos.x} y={pos.y} size={24} idx={i}
            facing={i % 2 === 0 ? "right" : "front"} />
        );
      })}
      {(!agents || agents.length === 0) && <EmptyRoomLabel tint={T} />}
    </RoomFrame>
  );
}

// ============ ROOM 3: RESEARCH LAB ============
function ResearchLab({ agents }) {
  const T = "#B78BFF", A = "#C8B0FF";
  return (
    <RoomFrame tint={T} floorTint="#2a2550" wallTint="#1f1d42" accent2={A}>
      {/* ceiling grid of panel lights */}
      <g opacity="0.85">
        <rect x="45" y="4" width="58" height="3" rx="1" fill={A} opacity="0.45" />
        <rect x="120" y="4" width="60" height="3" rx="1" fill={A} opacity="0.5" />
        <rect x="197" y="4" width="58" height="3" rx="1" fill={A} opacity="0.45" />
      </g>

      {/* ====== back wall — equipment bay ====== */}
      {/* vertical rack on left */}
      <rect x="16" y="18" width="22" height="100" fill="#14102e" stroke={T} strokeWidth="0.5" />
      <rect x="16" y="18" width="22" height="3" fill={T} opacity="0.55" />
      {[0,1,2,3,4,5].map(i => (
        <g key={i} transform={`translate(18 ${26 + i * 14})`}>
          <rect width="18" height="10" fill="#0a0620" stroke={T} strokeWidth="0.3" />
          <rect y="0" width="18" height="1" fill={T} opacity="0.4" />
          <circle cx="3" cy="4" r="0.8" fill="#4FE08A" />
          <circle cx="6" cy="4" r="0.8" fill="#FFD170" opacity={i%2 ? 0.9 : 0.3} />
          <rect x="9" y="3" width="7" height="3" fill={T} opacity={0.3 + (i % 3) * 0.2} />
        </g>
      ))}

      {/* monitor cluster */}
      <Screen x="44" y="20" w={56} h={40} color={T}>
        <text x="4" y="8" fontSize="3" fill={T} fontFamily="monospace" opacity="0.85">GENOME</text>
        <g stroke={T} strokeWidth="0.4" fill="none">
          <path d="M12 4 Q 22 12 12 20 Q 2 28 12 34" />
          <path d="M32 4 Q 22 12 32 20 Q 42 28 32 34" />
          {[6,12,18,24,30].map(y => <line key={y} x1="12" y1={y} x2="32" y2={y} opacity="0.7" />)}
        </g>
      </Screen>
      <Screen x="106" y="16" w={64} h={44} color={A}>
        <text x="4" y="8" fontSize="3" fill={A} fontFamily="monospace" opacity="0.85">MOLECULE · 3D</text>
        <g stroke={A} strokeWidth="0.5" fill="none">
          <circle cx="32" cy="24" r="3.5" fill={A} />
          <circle cx="14" cy="14" r="2.5" fill="#4FD8FF" />
          <circle cx="50" cy="14" r="2.5" fill="#FF7ABF" />
          <circle cx="14" cy="34" r="2.5" fill="#4FE08A" />
          <circle cx="50" cy="34" r="2.5" fill="#FFD170" />
          <line x1="32" y1="24" x2="14" y2="14" />
          <line x1="32" y1="24" x2="50" y2="14" />
          <line x1="32" y1="24" x2="14" y2="34" />
          <line x1="32" y1="24" x2="50" y2="34" />
        </g>
      </Screen>
      <Screen x="176" y="20" w={48} h={40} color={T}>
        <text x="2" y="8" fontSize="3" fill={T} fontFamily="monospace" opacity="0.85">EKG · LIVE</text>
        <g stroke={T} strokeWidth="0.6" fill="none">
          <path d="M2 22 L10 22 L13 12 L16 32 L19 16 L22 22 L44 22" />
        </g>
        <rect x="2" y="28" width="28" height="0.8" fill={T} opacity="0.45" />
        <rect x="2" y="31" width="34" height="0.8" fill={T} opacity="0.3" />
      </Screen>

      {/* vertical rack on right */}
      <rect x="230" y="18" width="54" height="40" fill="#14102e" stroke={T} strokeWidth="0.5" />
      <rect x="230" y="18" width="54" height="3" fill={T} opacity="0.55" />
      <g transform="translate(234 24)">
        <circle cx="12" cy="14" r="10" fill="none" stroke={T} strokeWidth="0.5" />
        <path d="M4 14 L12 6 L20 14 L12 22 Z" fill="none" stroke={T} strokeWidth="0.4" />
        <circle cx="12" cy="14" r="3" fill={T} opacity="0.6" />
        <circle cx="12" cy="14" r="1" fill="#fff" />
        <text x="26" y="6" fontSize="2.5" fill={T} fontFamily="monospace" opacity="0.85">SCAN</text>
        <rect x="26" y="8" width="20" height="2" fill={T} opacity="0.55" />
        <rect x="26" y="12" width="16" height="1.2" fill={T} opacity="0.35" />
        <rect x="26" y="15" width="18" height="1.2" fill={T} opacity="0.35" />
      </g>

      {/* storage cabinets under right rack */}
      <Box3D cx={254} baseY={118} w={54} h={12} depth={7} color={T} dark="#140e30" top="#241a50" />
      <g>
        <rect x="230" y="108" width="22" height="8" fill="#0a0620" stroke={T} strokeWidth="0.3" />
        <line x1="241" y1="108" x2="241" y2="116" stroke={T} strokeWidth="0.25" opacity="0.5" />
        <circle cx="237" cy="112" r="0.5" fill={T} opacity="0.7" />
        <circle cx="245" cy="112" r="0.5" fill={T} opacity="0.7" />
        <rect x="254" y="108" width="26" height="8" fill="#0a0620" stroke={T} strokeWidth="0.3" />
        <rect x="256" y="110" width="22" height="4" fill={T} opacity="0.25" />
      </g>

      <Baseboard color={T} opacity={0.45} />

      {/* ====== lab benches — volumetric ====== */}
      <Box3D cx={68} baseY={134} w={90} h={7} depth={9} color={T} dark="#14102e" top="#2a1f5e" />
      {/* bench top accessories */}
      <g>
        {/* beaker cluster */}
        <g transform="translate(36 116)">
          <rect x="-3" y="0" width="6" height="12" rx="0.8" fill="#4FD8FF" opacity="0.5" stroke={T} strokeWidth="0.3" />
          <rect x="-3" y="6" width="6" height="6" fill="#4FD8FF" opacity="0.9" />
          <rect x="-2" y="-2" width="4" height="2" fill={T} />
          <path d="M-0.5 5 Q 0 3 0.5 5" stroke="#fff" strokeWidth="0.3" fill="none" opacity="0.6" />
        </g>
        <g transform="translate(52 114)">
          <path d="M-4 0 L-4 5 L-7 14 L7 14 L4 5 L4 0 Z" fill="#FF7ABF" opacity="0.55" stroke={T} strokeWidth="0.3" />
          <rect x="-4" y="-2" width="8" height="2" fill={T} />
          <ellipse cx="0" cy="9" rx="5" ry="1" fill="#FF7ABF" opacity="0.8" />
        </g>
        <g transform="translate(70 115)">
          <rect x="-2" y="0" width="4" height="13" rx="0.5" fill="#4FE08A" opacity="0.6" stroke={T} strokeWidth="0.3" />
          <rect x="-2" y="6" width="4" height="7" fill="#4FE08A" opacity="0.95" />
        </g>
        <g transform="translate(86 116)">
          <circle cx="0" cy="6" r="5.5" fill="#FFD170" opacity="0.55" stroke={T} strokeWidth="0.3" />
          <rect x="-1.5" y="-2" width="3" height="6" fill={T} opacity="0.6" />
        </g>
        {/* centrifuge */}
        <g transform="translate(108 115)">
          <rect x="-7" y="0" width="14" height="10" rx="1.2" fill="#0a0620" stroke={T} strokeWidth="0.4" />
          <circle cx="0" cy="5" r="3.5" fill="none" stroke={T} strokeWidth="0.35" />
          <circle cx="0" cy="5" r="1" fill={T} />
          <rect x="-6" y="8.5" width="3" height="1" fill="#4FE08A" />
          <rect x="3" y="8.5" width="3" height="1" fill="#FFD170" />
        </g>
      </g>

      <Box3D cx={232} baseY={134} w={90} h={7} depth={9} color={T} dark="#14102e" top="#2a1f5e" />
      {/* right bench: microscope + workstation */}
      <g transform="translate(214 112)">
        <rect x="-9" y="14" width="18" height="3" rx="0.5" fill={T} opacity="0.85" />
        <rect x="-2.5" y="4" width="5" height="10" fill={A} stroke={T} strokeWidth="0.3" />
        <circle cx="0" cy="2" r="3.5" fill="#0a0620" stroke={T} strokeWidth="0.4" />
        <circle cx="0" cy="2" r="1.6" fill={T} opacity="0.8" />
        <rect x="-6" y="0" width="3.5" height="3.5" fill={T} />
        <rect x="2.5" y="0" width="3.5" height="3.5" fill={T} opacity="0.7" />
        <circle cx="0" cy="11" r="1.4" fill={A} opacity="0.8" />
      </g>
      {/* monitor + keyboard */}
      <g transform="translate(256 112)">
        <rect x="-15" y="-2" width="30" height="18" rx="1.2" fill="#0a0620" stroke={T} strokeWidth="0.4" />
        <rect x="-14" y="-1" width="28" height="16" fill="#14082a" />
        <path d="M-12 9 L-8 4 L-4 7 L0 0 L5 5 L10 2 L14 6" stroke={T} strokeWidth="0.55" fill="none" />
        <circle cx="0" cy="0" r="0.8" fill="#fff" />
        <rect x="-6" y="18" width="12" height="1.8" rx="0.4" fill="#2a1f5e" />
      </g>

      {/* center analysis pedestal with holo sample */}
      <ellipse cx="150" cy="172" rx="22" ry="5" fill="#000" opacity="0.5" />
      <polygon points="134,172 166,172 162,180 138,180" fill="#0a0620" stroke={T} strokeWidth="0.45" />
      <ellipse cx="150" cy="170" rx="18" ry="4" fill="#14102e" stroke={T} strokeWidth="0.5" />
      <ellipse cx="150" cy="168" rx="14" ry="3" fill="none" stroke={A} strokeWidth="0.4" />
      {/* floating dna */}
      <g transform="translate(150 156)">
        <path d="M-6 -10 Q 0 -6 6 -10 M-6 -4 Q 0 0 6 -4 M-6 2 Q 0 6 6 2 M-6 8 Q 0 12 6 8"
              stroke={A} strokeWidth="0.6" fill="none" />
        <path d="M-6 -10 Q 0 -14 6 -10 M-6 -4 Q 0 -8 6 -4 M-6 2 Q 0 -2 6 2 M-6 8 Q 0 4 6 8"
              stroke={T} strokeWidth="0.6" fill="none" opacity="0.7" />
        {[-10,-4,2,8].map(y => <circle key={y} cx="-6" cy={y} r="0.9" fill={A} />)}
        {[-10,-4,2,8].map(y => <circle key={y+100} cx="6" cy={y} r="0.9" fill="#FF7ABF" />)}
      </g>
      <path d="M 150 170 L 142 158 L 158 158 Z" fill={A} opacity="0.18" />

      <Plant x="22" y="150" color="#52b788" ring={T} />

      {(agents || []).map((a, i) => {
        const positions = [{x: 70, y: 158}, {x: 150, y: 184}, {x: 228, y: 158}];
        const pos = positions[i % 3];
        return (
          <RoomBot key={a.id} color={a.color} name={a.name} activity={a.activity}
            x={pos.x} y={pos.y} size={26} idx={i}
            facing={i === 0 ? "right" : "front"} />
        );
      })}
      {(!agents || agents.length === 0) && <EmptyRoomLabel tint={T} />}
    </RoomFrame>
  );
}

// ============ ROOM 4: CONTENT STUDIO ============
function ContentStudio({ agents }) {
  const T = "#4FE08A", A = "#7EF0A8";
  return (
    <RoomFrame tint={T} floorTint="#1a2f22" wallTint="#142420" accent2={A}>
      <defs>
        <radialGradient id="greenScreenLight" cx="0.5" cy="0.5" r="0.75">
          <stop offset="0" stopColor="#9EF7B8" stopOpacity="0.55" />
          <stop offset="1" stopColor="#2dd96b" stopOpacity="0" />
        </radialGradient>
        <linearGradient id="cycFloor" x1="0" x2="0" y1="0" y2="1">
          <stop offset="0" stopColor="#2dd96b" />
          <stop offset="1" stopColor="#1f9a4d" />
        </linearGradient>
      </defs>

      {/* track lighting */}
      <rect x="30" y="6" width="240" height="1.4" fill={T} opacity="0.5" />
      <g>
        <circle cx="100" cy="8" r="2.8" fill="#FFE89A" />
        <circle cx="100" cy="8" r="6" fill="#FFE89A" opacity="0.3" />
        <path d="M100 10 L90 24 L110 24 Z" fill="#FFE89A" opacity="0.18" />
        <circle cx="200" cy="8" r="2.8" fill="#FFE89A" />
        <circle cx="200" cy="8" r="6" fill="#FFE89A" opacity="0.3" />
        <path d="M200 10 L190 24 L210 24 Z" fill="#FFE89A" opacity="0.18" />
      </g>

      {/* ===== cyclorama (green screen) with proper curve + frame ===== */}
      <rect x="82" y="16" width="146" height="108" fill="#0a1a10" stroke={T} strokeWidth="0.8" />
      <rect x="86" y="20" width="138" height="100" fill="#2dd96b" />
      {/* floor part of cyc (curved into floor) */}
      <path d="M 86 120 Q 155 135 224 120 L 224 132 Q 155 122 86 132 Z" fill="url(#cycFloor)" />
      <rect x="86" y="20" width="138" height="100" fill="url(#greenScreenLight)" />
      {/* cyc seam highlight */}
      <path d="M 90 120 Q 155 133 220 120" stroke="#9EF7B8" strokeWidth="0.6" fill="none" opacity="0.8" />
      {/* C-stand flags on edges */}
      <rect x="82" y="16" width="2" height="108" fill="#0a0a0a" />
      <rect x="226" y="16" width="2" height="108" fill="#0a0a0a" />

      {/* LIVE badge */}
      <g transform="translate(155 26)">
        <rect x="-11" y="-3.5" width="22" height="7" rx="1.2" fill="#FF3b3b" />
        <circle cx="-6.5" cy="0" r="1.4" fill="#fff">
          <animate attributeName="opacity" values="0.3;1;0.3" dur="1.4s" repeatCount="indefinite" />
        </circle>
        <text x="1" y="2.2" textAnchor="middle" fontSize="4.4" fill="#fff" fontFamily="monospace" fontWeight="900">LIVE</text>
      </g>

      {/* monitor rack on left */}
      <Screen x="18" y="22" w={58} h={48} color={T}>
        <text x="4" y="8" fontSize="3" fill={T} fontFamily="monospace" letterSpacing="0.5">MULTIVIEW · 4-UP</text>
        <g stroke={T} strokeWidth="0.4" fill="none">
          <rect x="4" y="12" width="22" height="15" />
          <rect x="30" y="12" width="22" height="15" />
          <rect x="4" y="30" width="22" height="15" />
          <rect x="30" y="30" width="22" height="15" />
          <path d="M6 22 L14 17 L22 22" />
          <circle cx="41" cy="19" r="3" fill="#FF7ABF" />
          <path d="M6 40 Q 13 34 22 38" />
          <path d="M32 42 L40 38 L50 40" />
        </g>
        <circle cx="8" cy="15.5" r="0.9" fill="#FF3b3b" />
        <circle cx="8" cy="33.5" r="0.9" fill={T} />
        <circle cx="34" cy="15.5" r="0.9" fill="#FFD170" />
        <circle cx="34" cy="33.5" r="0.9" fill={T} />
      </Screen>

      {/* mixing desk — volumetric slant */}
      <g>
        <polygon points="12,108 80,108 80,116 12,116" fill="#0c1a12" stroke={T} strokeWidth="0.5" />
        <polygon points="12,108 80,108 76,104 16,104" fill="#142a1c" stroke={T} strokeWidth="0.35" />
        <rect x="16" y="106" width="60" height="1.2" fill={T} opacity="0.55" />
        {/* faders */}
        {[0,1,2,3,4,5,6,7,8].map(i => (
          <g key={i} transform={`translate(${20 + i * 7} 108)`}>
            <rect x="-1" y="0" width="2" height="7" fill="#1a3a26" />
            <rect x="-1.2" y={1 + (i % 4) * 1.3} width="2.4" height="1.5" fill={T} />
            <circle cx="0" cy="-2" r="1.2" fill={i % 3 === 0 ? "#FFD170" : T} opacity="0.9" />
          </g>
        ))}
      </g>
      {/* chair for mixing desk */}
      <g transform="translate(50 128)">
        <ellipse cx="0" cy="5" rx="4.5" ry="1.5" fill="#000" opacity="0.5" />
        <rect x="-3" y="0" width="6" height="4" rx="1" fill="#1a3a26" stroke={T} strokeWidth="0.3" />
        <rect x="-3.5" y="-5" width="7" height="5" rx="1.5" fill="#1a3a26" stroke={T} strokeWidth="0.3" />
      </g>

      {/* camera on tripod */}
      <g transform="translate(246 100)">
        <rect x="-8" y="-11" width="17" height="12" rx="1.2" fill="#1a1a1a" stroke={T} strokeWidth="0.4" />
        <rect x="-8" y="-11" width="17" height="2" fill={T} opacity="0.5" />
        <circle cx="0" cy="-5" r="4" fill="#0a0a0a" stroke={T} strokeWidth="0.35" />
        <circle cx="0" cy="-5" r="2" fill={T} opacity="0.9" />
        <circle cx="0" cy="-5" r="0.9" fill="#fff" />
        <rect x="8" y="-9" width="3.5" height="2" fill="#FF3b3b" />
        <rect x="9.5" y="-12" width="3" height="2" fill="#1a1a1a" stroke={T} strokeWidth="0.25" />
        {/* monitor arm */}
        <rect x="-14" y="-9" width="5" height="4" fill="#0a0a0a" stroke={T} strokeWidth="0.3" />
        {/* tripod */}
        <line x1="0" y1="1" x2="-10" y2="28" stroke={T} strokeWidth="1.2" strokeLinecap="round" />
        <line x1="0" y1="1" x2="10" y2="28" stroke={T} strokeWidth="1.2" strokeLinecap="round" />
        <line x1="0" y1="1" x2="0" y2="29" stroke={T} strokeWidth="1" strokeLinecap="round" />
        {/* tripod feet */}
        <ellipse cx="-10" cy="28" rx="2" ry="0.6" fill="#000" opacity="0.5" />
        <ellipse cx="10" cy="28" rx="2" ry="0.6" fill="#000" opacity="0.5" />
      </g>

      {/* key light (softbox) on stand */}
      <g transform="translate(268 56)">
        <rect x="-7" y="-7" width="14" height="14" rx="1" fill="#1a1a1a" stroke={T} strokeWidth="0.4" />
        <rect x="-6" y="-6" width="12" height="12" fill="#FFE89A" opacity="0.9" />
        <path d="M-6 -6 L6 6 M6 -6 L-6 6" stroke="#fff" strokeWidth="0.3" opacity="0.6" />
        {/* barn doors */}
        <path d="M-7 -7 L-10 -10 M7 -7 L10 -10 M-7 7 L-10 10 M7 7 L10 10" stroke="#2a2a2a" strokeWidth="1" />
        <line x1="0" y1="7" x2="0" y2="66" stroke={T} strokeWidth="0.9" />
        <line x1="0" y1="66" x2="-9" y2="74" stroke={T} strokeWidth="0.8" />
        <line x1="0" y1="66" x2="9" y2="74" stroke={T} strokeWidth="0.8" />
      </g>
      {/* light beam onto cyc */}
      <polygon points="262,60 175,60 168,110 236,122" fill="#FFE89A" opacity="0.1" />

      {/* boom microphone hanging */}
      <g>
        <line x1="155" y1="16" x2="155" y2="40" stroke={T} strokeWidth="0.5" />
        <line x1="155" y1="40" x2="120" y2="48" stroke={T} strokeWidth="0.8" />
        <ellipse cx="118" cy="49" rx="3.8" ry="5.5" fill="#1a1a1a" stroke={T} strokeWidth="0.4" />
        <path d="M115 46 L121 46 M114.5 48 L121.5 48 M115 50 L121 50" stroke={T} strokeWidth="0.3" />
      </g>

      {/* foreground: director monitor & clapboard */}
      <g transform="translate(40 138)">
        <rect x="-8" y="-6" width="18" height="11" rx="1" fill="#0a0a0a" stroke={T} strokeWidth="0.4" />
        <rect x="-7" y="-5" width="16" height="9" fill="#14082a" />
        <rect x="-5" y="-3" width="12" height="2" fill="#FF3b3b" opacity="0.85" />
        <path d="M-5 1 L-1 -1 L3 0 L7 -2" stroke={T} strokeWidth="0.45" fill="none" />
        <line x1="0" y1="5" x2="0" y2="10" stroke={T} strokeWidth="0.8" />
      </g>
      {/* clapboard */}
      <g transform="translate(64 140)">
        <polygon points="-7,0 7,0 7,6 -7,6" fill="#0a0a0a" stroke={T} strokeWidth="0.4" />
        <polygon points="-7,-3 7,-3 5,0 -5,0" fill={T} />
        <path d="M-5 -3 L-4 0 M-2 -3 L-1 0 M1 -3 L2 0 M4 -3 L5 0" stroke="#0a0a0a" strokeWidth="0.5" />
      </g>
      {/* (removed stray red floor marks that read as an artifact) */}

      <Plant x="22" y="150" color="#52b788" ring={T} />

      {(agents || []).map((a, i) => {
        const positions = [{x: 110, y: 168}, {x: 155, y: 178}, {x: 200, y: 172}];
        const pos = positions[i % 3];
        return (
          <RoomBot key={a.id} color={a.color} name={a.name} activity={a.activity}
            x={pos.x} y={pos.y} size={24} idx={i}
            facing={i === 2 ? "right" : "front"} />
        );
      })}
      {(!agents || agents.length === 0) && <EmptyRoomLabel tint={T} />}
    </RoomFrame>
  );
}

// ============ ROOM 5: AUTOMATION BAY ============
function AutomationBay({ agents }) {
  const T = "#FFA55C", A = "#FFD170";
  return (
    <RoomFrame tint={T} floorTint="#3a2410" wallTint="#2a1a0a" accent2={A}>
      {/* overhead industrial rail */}
      <rect x="30" y="8" width="240" height="3" fill="#1a0e06" stroke={T} strokeWidth="0.4" />
      <rect x="30" y="11" width="240" height="0.7" fill={T} opacity="0.7" />
      {[60, 110, 160, 210, 260].map(x => (
        <g key={x}>
          <rect x={x - 1} y="11" width="2" height="4" fill={T} opacity="0.6" />
          <circle cx={x} cy="16" r="1.2" fill={A} opacity="0.9" />
        </g>
      ))}
      {/* hanging hazard stripes */}
      <g>
        {[0,1,2,3,4,5,6,7].map(i => (
          <polygon key={i} points={`${38 + i * 28},12 ${54 + i * 28},12 ${48 + i * 28},18 ${32 + i * 28},18`} fill={i % 2 ? A : "#1a0e06"} />
        ))}
      </g>

      {/* ======= back wall control panel ======= */}
      <WallPanel x="20" y="24" w="90" h="54" color={T}>
        <Screen x={24} y={28} w={40} h={46} color={T}>
          <text x="3" y="7" fontSize="2.8" fill={T} fontFamily="monospace" opacity="0.85">STATUS</text>
          <g fill="#0a0604" stroke={T} strokeWidth="0.3">
            <rect x="3" y="10" width="34" height="8" />
            <rect x="3" y="20" width="34" height="8" />
            <rect x="3" y="30" width="34" height="8" />
          </g>
          <rect x="4" y="11" width="24" height="6" fill="#4FE08A" opacity="0.8" />
          <rect x="4" y="21" width="16" height="6" fill={A} opacity="0.8" />
          <rect x="4" y="31" width="8" height="6" fill="#FF3b3b" opacity="0.8" />
          <text x="33" y="16" fontSize="3" fill="#0a0604" fontFamily="monospace" fontWeight="700">OK</text>
          <text x="33" y="26" fontSize="3" fill="#0a0604" fontFamily="monospace" fontWeight="700">!</text>
          <text x="33" y="36" fontSize="3" fill="#fff" fontFamily="monospace" fontWeight="700">X</text>
        </Screen>
        <Screen x={68} y={28} w={40} h={46} color={A}>
          <text x="3" y="7" fontSize="2.8" fill={A} fontFamily="monospace" opacity="0.85">GAUGES</text>
          <g stroke={A} strokeWidth="0.5" fill="none">
            <path d="M8 30 A 10 10 0 0 1 28 30" />
            <line x1="18" y1="30" x2="24" y2="22" stroke={T} strokeWidth="1" />
            <circle cx="18" cy="30" r="1.2" fill={T} />
          </g>
          <text x="18" y="38" textAnchor="middle" fontSize="3" fill={A} fontFamily="monospace">PSI · 72</text>
        </Screen>
      </WallPanel>

      {/* emergency panel center */}
      <WallPanel x="116" y="16" w="72" h="44" color={T}>
        <text x="120" y="22" fontSize="3" fill={T} fontFamily="monospace" opacity="0.85" letterSpacing="1">SAFETY</text>
        <circle cx="130" cy="34" r="5" fill="#FF3b3b" />
        <circle cx="130" cy="34" r="6.5" fill="none" stroke="#FFD170" strokeWidth="0.7" />
        <text x="130" y="35.8" textAnchor="middle" fontSize="3" fill="#fff" fontWeight="900">STOP</text>
        <g fill={A}>
          <rect x="146" y="28" width="14" height="4" rx="0.5" />
          <rect x="146" y="34" width="14" height="4" rx="0.5" opacity="0.7" />
          <rect x="146" y="40" width="14" height="4" rx="0.5" opacity="0.4" />
        </g>
        <g fill="#0a0604">
          <text x="153" y="31" textAnchor="middle" fontSize="2.5" fontFamily="monospace" fontWeight="700">RUN</text>
          <text x="153" y="37" textAnchor="middle" fontSize="2.5" fontFamily="monospace" fontWeight="700">HOLD</text>
        </g>
        <rect x="166" y="28" width="18" height="18" fill="#0a0604" stroke={T} strokeWidth="0.4" />
        <text x="175" y="40" textAnchor="middle" fontSize="8" fill={A} fontFamily="Inter" fontWeight="900">4</text>
      </WallPanel>

      {/* right-side telemetry */}
      <Screen x="196" y="20" w={80} h={52} color={T}>
        <text x="4" y="8" fontSize="3" fill={T} fontFamily="monospace" opacity="0.85">THROUGHPUT · 24H</text>
        <g fill={T} opacity="0.9">
          {[10,18,14,22,12,24,16,20,14,22,12,26].map((v, i) => (
            <rect key={i} x={4 + i * 6} y={46 - v} width="4" height={v} />
          ))}
        </g>
        <path d="M4 28 L76 28" stroke={A} strokeWidth="0.35" strokeDasharray="1.5 1.5" opacity="0.7" />
        <text x="76" y="27" textAnchor="end" fontSize="2.4" fill={A} fontFamily="monospace">GOAL</text>
      </Screen>

      <Baseboard color={T} opacity={0.4} />

      {/* ======= conveyor — volumetric ======= */}
      <g>
        {/* shadow */}
        <polygon points="18,150 282,150 290,156 10,156" fill="#000" opacity="0.55" />
        {/* side of conveyor */}
        <polygon points="18,144 282,144 290,152 10,152" fill="#1a0e06" stroke={T} strokeWidth="0.5" />
        {/* top */}
        <polygon points="22,132 278,132 282,144 18,144" fill="#2a1a0a" stroke={T} strokeWidth="0.55" />
        <polygon points="22,132 278,132 282,144 18,144" fill={T} opacity="0.05" />
        {/* belt segments */}
        <g stroke={T} strokeWidth="0.35" fill="none" opacity="0.55">
          {[0,1,2,3,4,5,6,7,8,9,10,11,12].map(i => (
            <path key={i} d={`M ${26 + i * 20} 132 L ${22 + i * 20} 144`} />
          ))}
        </g>
        {/* rollers */}
        <circle cx="20" cy="138" r="6" fill="#1a0e06" stroke={T} strokeWidth="0.6" />
        <circle cx="20" cy="138" r="3" fill="none" stroke={A} strokeWidth="0.35" />
        <circle cx="20" cy="138" r="0.8" fill={A} />
        <circle cx="280" cy="138" r="6" fill="#1a0e06" stroke={T} strokeWidth="0.6" />
        <circle cx="280" cy="138" r="3" fill="none" stroke={A} strokeWidth="0.35" />
        <circle cx="280" cy="138" r="0.8" fill={A} />
        {/* support legs */}
        <rect x="50" y="144" width="3" height="14" fill="#1a0e06" stroke={T} strokeWidth="0.3" />
        <rect x="150" y="144" width="3" height="14" fill="#1a0e06" stroke={T} strokeWidth="0.3" />
        <rect x="248" y="144" width="3" height="14" fill="#1a0e06" stroke={T} strokeWidth="0.3" />
      </g>

      {/* crates on belt — volumetric */}
      <Box3D cx={72} baseY={132} w={16} h={12} depth={6} color="#5a3a1a" dark={T} top={A} />
      <text x="72" y="128" textAnchor="middle" fontSize="3" fill="#5a3a1a" fontFamily="monospace" fontWeight="900">A-21</text>
      <Box3D cx={170} baseY={132} w={14} h={10} depth={5} color="#5a3a1a" dark={A} top="#FFEAB3" />
      <text x="170" y="129" textAnchor="middle" fontSize="3.5" fill="#5a3a1a" fontFamily="monospace" fontWeight="900">02</text>
      <Box3D cx={232} baseY={132} w={14} h={10} depth={5} color="#5a3a1a" dark="#FF7A3C" top="#FFB080" />

      {/* ======= robotic arms — articulated ======= */}
      <g transform="translate(100 132)">
        {/* base plate */}
        <ellipse cx="0" cy="2" rx="9" ry="2.5" fill="#1a0e06" stroke={T} strokeWidth="0.4" />
        <rect x="-5" y="-10" width="10" height="10" rx="1.5" fill={T} stroke="#5a3a1a" strokeWidth="0.5" />
        <circle cx="0" cy="-10" r="3.5" fill="#1a0e06" stroke={A} strokeWidth="0.5" />
        {/* upper arm */}
        <rect x="-2" y="-28" width="4" height="18" rx="0.5" fill={T} stroke="#5a3a1a" strokeWidth="0.4" transform="rotate(-24 0 -10)" />
        <circle cx="-10" cy="-24" r="2.5" fill="#1a0e06" stroke={A} strokeWidth="0.5" />
        {/* forearm */}
        <rect x="-12" y="-30" width="3.4" height="11" rx="0.5" fill={T} stroke="#5a3a1a" strokeWidth="0.4" transform="rotate(40 -10 -24)" />
        {/* gripper */}
        <g transform="translate(-17 -29)">
          <path d="M-2 0 L-4 4 M2 0 L4 4" stroke={T} strokeWidth="1.2" strokeLinecap="round" />
          <circle cx="0" cy="0" r="1.2" fill={A} />
        </g>
        {/* status light */}
        <circle cx="5" cy="-9" r="0.8" fill="#4FE08A" />
      </g>
      <g transform="translate(212 132)">
        <ellipse cx="0" cy="2" rx="9" ry="2.5" fill="#1a0e06" stroke={T} strokeWidth="0.4" />
        <rect x="-5" y="-10" width="10" height="10" rx="1.5" fill={T} stroke="#5a3a1a" strokeWidth="0.5" />
        <circle cx="0" cy="-10" r="3.5" fill="#1a0e06" stroke={A} strokeWidth="0.5" />
        <rect x="-2" y="-28" width="4" height="18" rx="0.5" fill={T} stroke="#5a3a1a" strokeWidth="0.4" transform="rotate(24 0 -10)" />
        <circle cx="10" cy="-24" r="2.5" fill="#1a0e06" stroke={A} strokeWidth="0.5" />
        <rect x="8.5" y="-30" width="3.4" height="11" rx="0.5" fill={T} stroke="#5a3a1a" strokeWidth="0.4" transform="rotate(-40 10 -24)" />
        <g transform="translate(17 -29)">
          <path d="M-2 0 L-4 4 M2 0 L4 4" stroke={T} strokeWidth="1.2" strokeLinecap="round" />
          <circle cx="0" cy="0" r="1.2" fill={A} />
        </g>
        <circle cx="-5" cy="-9" r="0.8" fill={A}>
          <animate attributeName="opacity" values="0.3;1;0.3" dur="1.6s" repeatCount="indefinite" />
        </circle>
      </g>

      {/* stacked crates foreground */}
      <g transform="translate(20 162)">
        <Box3D cx={0} baseY={16} w={18} h={14} depth={6} color="#5a3a1a" dark={T} top={A} />
        <text x="2" y="12" textAnchor="middle" fontSize="4" fill="#5a3a1a" fontFamily="monospace" fontWeight="900">03</text>
      </g>
      <g transform="translate(22 144)">
        <Box3D cx={0} baseY={14} w={16} h={12} depth={5} color="#5a3a1a" dark={A} top="#FFEAB3" />
        <text x="1.5" y="10" textAnchor="middle" fontSize="3.5" fill="#5a3a1a" fontFamily="monospace" fontWeight="900">02</text>
      </g>
      <g transform="translate(282 164)">
        <Box3D cx={0} baseY={16} w={18} h={14} depth={6} color="#5a3a1a" dark="#FF7A3C" top="#FFB080" />
      </g>

      {(agents || []).map((a, i) => {
        const positions = [{x: 135, y: 178}, {x: 180, y: 184}, {x: 70, y: 182}];
        const pos = positions[i % 3];
        return (
          <RoomBot key={a.id} color={a.color} name={a.name} activity={a.activity}
            x={pos.x} y={pos.y} size={22} idx={i}
            facing={i === 0 ? "right" : "front"} />
        );
      })}
      {(!agents || agents.length === 0) && <EmptyRoomLabel tint={T} />}
    </RoomFrame>
  );
}

// ============ ROOM 6: ANALYTICS ============
function AnalyticsRoom({ agents }) {
  const T = "#C17AFF", A = "#E0B8FF";
  return (
    <RoomFrame tint={T} floorTint="#2e1a48" wallTint="#241436" accent2={A}>
      {/* ceiling panel */}
      <rect x="60" y="4" width="180" height="3.5" rx="1" fill={A} opacity="0.5" />

      {/* ===== big back wall dashboard ===== */}
      <rect x="16" y="12" width="268" height="62" rx="2.5" fill="#0a0416" stroke={T} strokeWidth="0.7" />
      <rect x="18" y="14" width="264" height="58" rx="1.5" fill="#14082a" />
      <rect x="18" y="14" width="264" height="3" fill={T} opacity="0.55" />
      {/* header row */}
      <text x="24" y="21" fontSize="3.2" fill={T} fontFamily="monospace" letterSpacing="1" opacity="0.95">LIVE · REALTIME · UTC 08:42:16</text>
      <circle cx="236" cy="19" r="1.2" fill="#4FE08A">
        <animate attributeName="opacity" values="0.4;1;0.4" dur="1.6s" repeatCount="indefinite" />
      </circle>
      <text x="241" y="21" fontSize="2.8" fill="#4FE08A" fontFamily="monospace">REC</text>
      <text x="260" y="21" fontSize="2.8" fill={A} fontFamily="monospace" opacity="0.7">▲</text>
      <text x="272" y="21" fontSize="2.8" fill={A} fontFamily="monospace" opacity="0.7">⚙</text>

      {/* chart grid — 4 panels */}
      <g transform="translate(24 28)">
        {/* panel 1: line + area */}
        <g>
          <rect x="0" y="0" width="60" height="40" fill="#0a0416" stroke={T} strokeWidth="0.35" opacity="0.55" rx="1" />
          <g stroke={T} strokeWidth="0.2" opacity="0.25">
            <line x1="0" y1="10" x2="60" y2="10" />
            <line x1="0" y1="20" x2="60" y2="20" />
            <line x1="0" y1="30" x2="60" y2="30" />
          </g>
          <path d="M2 34 L10 26 L18 30 L26 16 L34 20 L42 10 L50 14 L58 8" stroke={T} strokeWidth="0.85" fill="none" />
          <path d="M2 34 L10 26 L18 30 L26 16 L34 20 L42 10 L50 14 L58 8 L58 40 L2 40 Z" fill={T} opacity="0.22" />
          <circle cx="42" cy="10" r="1.3" fill="#fff" />
          <text x="2" y="-2" fontSize="2.8" fill={T} fontFamily="monospace" letterSpacing="0.5">ENGAGEMENT</text>
          <text x="58" y="-2" textAnchor="end" fontSize="2.5" fill="#4FE08A" fontFamily="monospace">+12.4%</text>
        </g>
        {/* panel 2: stacked bars */}
        <g transform="translate(66 0)">
          <rect x="0" y="0" width="60" height="40" fill="#0a0416" stroke={T} strokeWidth="0.35" opacity="0.55" rx="1" />
          <g stroke={T} strokeWidth="0.2" opacity="0.25">
            <line x1="0" y1="10" x2="60" y2="10" />
            <line x1="0" y1="20" x2="60" y2="20" />
            <line x1="0" y1="30" x2="60" y2="30" />
          </g>
          {[16, 10, 20, 6, 14, 22, 18].map((v, i) => (
            <g key={i}>
              <rect x={4 + i * 8} y={36 - v} width="5" height={v} fill={T} />
              <rect x={4 + i * 8} y={36 - v - 6} width="5" height="6" fill="#FF7ABF" opacity="0.85" />
            </g>
          ))}
          <text x="2" y="-2" fontSize="2.8" fill={T} fontFamily="monospace" letterSpacing="0.5">SESSIONS · 7D</text>
        </g>
        {/* panel 3: donut with legend */}
        <g transform="translate(132 0)">
          <rect x="0" y="0" width="58" height="40" fill="#0a0416" stroke={T} strokeWidth="0.35" opacity="0.55" rx="1" />
          <circle cx="20" cy="21" r="13" fill="none" stroke="#2a1a42" strokeWidth="4.5" />
          <path d="M 20 8 A 13 13 0 0 1 32.5 22" stroke={T} strokeWidth="4.5" fill="none" />
          <path d="M 32.5 22 A 13 13 0 0 1 24 33" stroke="#FF7ABF" strokeWidth="4.5" fill="none" />
          <path d="M 24 33 A 13 13 0 0 1 13 28" stroke={A} strokeWidth="4.5" fill="none" opacity="0.85" />
          <text x="20" y="23.5" textAnchor="middle" fontSize="5.5" fill="#fff" fontFamily="Inter" fontWeight="800">68%</text>
          <g fontSize="2.4" fontFamily="monospace" fill={T}>
            <rect x="38" y="10" width="2" height="2" fill={T} /><text x="42" y="12">Retain</text>
            <rect x="38" y="15" width="2" height="2" fill="#FF7ABF" /><text x="42" y="17">Churn</text>
            <rect x="38" y="20" width="2" height="2" fill={A} /><text x="42" y="22">New</text>
          </g>
          <text x="2" y="-2" fontSize="2.8" fill={T} fontFamily="monospace" letterSpacing="0.5">RETENTION</text>
        </g>
        {/* panel 4: KPI + sparkline */}
        <g transform="translate(196 0)">
          <rect x="0" y="0" width="56" height="40" fill="#0a0416" stroke={T} strokeWidth="0.35" opacity="0.55" rx="1" />
          <text x="28" y="20" textAnchor="middle" fontSize="10" fill="#fff" fontFamily="Inter" fontWeight="800">128K</text>
          <text x="28" y="27" textAnchor="middle" fontSize="3" fill="#4FE08A" fontFamily="monospace" fontWeight="700">▲ 12.4%</text>
          <path d="M6 34 L14 30 L22 32 L30 26 L38 28 L46 22 L50 24" stroke="#4FE08A" strokeWidth="0.7" fill="none" opacity="0.85" />
          <text x="2" y="-2" fontSize="2.8" fill={T} fontFamily="monospace" letterSpacing="0.5">EVENTS · 24H</text>
        </g>
      </g>

      {/* ===== workstations — volumetric desks ===== */}
      {/* left desk */}
      <Box3D cx={64} baseY={134} w={84} h={7} depth={9} color={T} dark="#1a0e32" top="#2a1a52" />
      {/* right desk */}
      <Box3D cx={236} baseY={134} w={84} h={7} depth={9} color={T} dark="#1a0e32" top="#2a1a52" />

      {/* left monitor pair */}
      <g transform="translate(36 88)">
        <rect x="-1" y="-1" width="32" height="22" rx="1.5" fill="#0a0416" stroke={T} strokeWidth="0.4" />
        <rect x="0" y="0" width="30" height="20" fill="#14082a" />
        <path d="M2 14 L7 10 L12 12 L18 6 L24 10 L28 8" stroke={T} strokeWidth="0.55" fill="none" />
        <path d="M2 14 L7 10 L12 12 L18 6 L24 10 L28 8 L28 20 L2 20 Z" fill={T} opacity="0.22" />
        <rect x="12" y="22" width="6" height="4" fill="#2a1a42" />
        <rect x="5" y="25" width="20" height="1.4" fill="#3a2a62" />
      </g>
      <g transform="translate(74 88)">
        <rect x="-1" y="-1" width="32" height="22" rx="1.5" fill="#0a0416" stroke={T} strokeWidth="0.4" />
        <rect x="0" y="0" width="30" height="20" fill="#14082a" />
        <g fill={T}>
          <rect x="3" y="12" width="3" height="8" />
          <rect x="9" y="8" width="3" height="12" />
          <rect x="15" y="10" width="3" height="10" />
          <rect x="21" y="4" width="3" height="16" />
          <rect x="27" y="8" width="3" height="12" fill="#FF7ABF" />
        </g>
        <rect x="12" y="22" width="6" height="4" fill="#2a1a42" />
        <rect x="5" y="25" width="20" height="1.4" fill="#3a2a62" />
      </g>
      {/* left keyboard + mouse on desk */}
      <rect x="32" y="128" width="28" height="3.5" rx="0.6" fill="#1a0e32" stroke={T} strokeWidth="0.3" />
      <rect x="66" y="128" width="28" height="3.5" rx="0.6" fill="#1a0e32" stroke={T} strokeWidth="0.3" />
      <circle cx="100" cy="130" r="1.2" fill="#1a0e32" stroke={T} strokeWidth="0.3" />

      {/* left desk accessories */}
      <g transform="translate(32 123)">
        <rect x="0" y="0" width="5" height="4" rx="0.4" fill="#1a0e32" stroke={T} strokeWidth="0.25" />
        <rect x="0.8" y="0.8" width="3.4" height="0.8" fill={T} opacity="0.8" />
      </g>
      {/* coffee cup */}
      <g transform="translate(100 126)">
        <rect x="-2" y="-4" width="4" height="5" fill="#0a0416" stroke={T} strokeWidth="0.3" />
        <path d="M2 -3 Q 4 -3 4 -1 Q 4 1 2 1" stroke={T} strokeWidth="0.3" fill="none" />
        <rect x="-2" y="-4" width="4" height="0.8" fill={T} opacity="0.6" />
      </g>

      {/* right monitor pair */}
      <g transform="translate(200 88)">
        <rect x="-1" y="-1" width="32" height="22" rx="1.5" fill="#0a0416" stroke={T} strokeWidth="0.4" />
        <rect x="0" y="0" width="30" height="20" fill="#14082a" />
        <circle cx="15" cy="11" r="7" fill="none" stroke={T} strokeWidth="0.5" />
        <circle cx="15" cy="11" r="4" fill={T} opacity="0.5" />
        <circle cx="15" cy="11" r="1" fill="#fff" />
        <rect x="12" y="22" width="6" height="4" fill="#2a1a42" />
        <rect x="5" y="25" width="20" height="1.4" fill="#3a2a62" />
      </g>
      <g transform="translate(238 88)">
        <rect x="-1" y="-1" width="32" height="22" rx="1.5" fill="#0a0416" stroke={T} strokeWidth="0.4" />
        <rect x="0" y="0" width="30" height="20" fill="#14082a" />
        <path d="M2 14 Q 10 8 17 12 Q 23 6 28 10" stroke="#FF7ABF" strokeWidth="0.55" fill="none" />
        <rect x="2" y="16" width="25" height="1" fill="#FF7ABF" opacity="0.55" />
        <rect x="2" y="18" width="18" height="1" fill="#FF7ABF" opacity="0.35" />
        <rect x="12" y="22" width="6" height="4" fill="#2a1a42" />
        <rect x="5" y="25" width="20" height="1.4" fill="#3a2a62" />
      </g>
      <rect x="196" y="128" width="28" height="3.5" rx="0.6" fill="#1a0e32" stroke={T} strokeWidth="0.3" />
      <rect x="230" y="128" width="28" height="3.5" rx="0.6" fill="#1a0e32" stroke={T} strokeWidth="0.3" />
      <circle cx="264" cy="130" r="1.2" fill="#1a0e32" stroke={T} strokeWidth="0.3" />

      {/* chairs */}
      <g transform="translate(64 146)">
        <ellipse cx="0" cy="6" rx="6" ry="1.6" fill="#000" opacity="0.5" />
        <rect x="-4" y="-2" width="8" height="5" rx="1.3" fill="#1a0e32" stroke={T} strokeWidth="0.35" />
        <rect x="-4.5" y="-9" width="9" height="7" rx="1.5" fill="#1a0e32" stroke={T} strokeWidth="0.35" />
        <rect x="-4.5" y="-9" width="9" height="1" fill={T} opacity="0.6" />
      </g>
      <g transform="translate(236 146)">
        <ellipse cx="0" cy="6" rx="6" ry="1.6" fill="#000" opacity="0.5" />
        <rect x="-4" y="-2" width="8" height="5" rx="1.3" fill="#1a0e32" stroke={T} strokeWidth="0.35" />
        <rect x="-4.5" y="-9" width="9" height="7" rx="1.5" fill="#1a0e32" stroke={T} strokeWidth="0.35" />
        <rect x="-4.5" y="-9" width="9" height="1" fill={T} opacity="0.6" />
      </g>

      {/* central data pedestal — holo sphere */}
      <ellipse cx="150" cy="170" rx="20" ry="5" fill="#000" opacity="0.5" />
      <polygon points="134,170 166,170 162,180 138,180" fill="#1a0e32" stroke={T} strokeWidth="0.5" />
      <ellipse cx="150" cy="168" rx="16" ry="3.5" fill="#2a1a42" stroke={T} strokeWidth="0.45" />
      <g transform="translate(150 156)">
        <circle cx="0" cy="0" r="9" fill={T} opacity="0.18" />
        <ellipse rx="8" ry="2.5" fill="none" stroke={A} strokeWidth="0.4" opacity="0.8" />
        <ellipse rx="8" ry="2.5" fill="none" stroke={A} strokeWidth="0.4" opacity="0.5" transform="rotate(60)" />
        <ellipse rx="8" ry="2.5" fill="none" stroke={A} strokeWidth="0.4" opacity="0.5" transform="rotate(-60)" />
        <circle cx="0" cy="0" r="3" fill={A} opacity="0.6" />
        <circle cx="0" cy="0" r="1.4" fill="#fff" />
      </g>

      <Baseboard color={T} opacity={0.4} />

      {(agents || []).map((a, i) => {
        const positions = [{x: 64, y: 158}, {x: 150, y: 182}, {x: 236, y: 158}];
        const pos = positions[i % 3];
        return (
          <RoomBot key={a.id} color={a.color} name={a.name} activity={a.activity}
            x={pos.x} y={pos.y} size={26} idx={i}
            facing={i === 0 ? "right" : "front"} />
        );
      })}
      {(!agents || agents.length === 0) && <EmptyRoomLabel tint={T} />}
    </RoomFrame>
  );
}

Object.assign(window, {
  SharedDefs, JarvisOffice, StrategyRoom, ResearchLab,
  ContentStudio, AutomationBay, AnalyticsRoom, GenericRoom
});
