[VISUAL WORLD RULES]

{visual_world_rules}

[ALL LOCATIONS]

{location_lines}

[SCENE TEXTS]

Original screenplay segments, full and untruncated. Use these as the AUTHORITY for which locations are physically connected (same building, immediate exterior, sub-room) and how characters move between them.

{scene_texts_block}

[SELECTED SHOTS BY SCENE]

Each shot line carries an authoritative location marker `(loc=Lxx)`. If a shot line has no marker, fall back to its scene's `primary_location` shown at the scene header.

{scene_blocks}

[TASK]

Decide the background generation plan for this episode. Following the building group rule, frequency rules (applied at GROUP level), order constraints, and chain_bg construction in the system instructions, produce a single JSON object that conforms to the schema.

Required output keys: rationale_summary, floor_plans, floor_plan_order, chain_bg_groups, chain_bg_order, prev_shot_only.

Reminders:
- A `building_group` covers ALL physically connected locations: interior rooms, sub-rooms (bathroom, sub-office, meeting room), the immediate exterior of the same building, and adjacent exterior the characters cross to enter.
- Frequency rules are PER GROUP: sum selected shots across every member location to get `group_shot_count`. A group with `group_shot_count` ≥ 3 AND at least one indoor member gets `floor_plan` + `chain_bg`. Otherwise fallback.
- A single location with 1 or 2 shots can still be IN a `floor_plans` entry if it is a connected member of an indoor-anchored 3+ group. It does NOT go to `prev_shot_only` in that case.
- Outdoor-only groups (no indoor member) always go to `prev_shot_only`, regardless of shot count.
- Same `building_group` floor plans should be adjacent in `floor_plan_order` if you split a building across multiple floor_plans (rare; only when the complex is too large for one plan).
- chain_bg_groups parent_id (if non-empty) must appear earlier in chain_bg_order.
- Every selected shot of every member location in a floor_plan MUST appear in exactly one chain_bg group.
- All ids snake_case ASCII; no proper nouns from any specific scenario.
- rationale_summary in Korean (1-2 sentences); per-item rationale in one short Korean sentence.

Return JSON only.
