# Prompt Version 5: UML State Diagram Element Ordering Delta

Use this as a delta over `state-uml-recreated.prompt.md` after the fourth
rendered SVG/draw.io pass.

## Append Lines

- Validate element ordering and z-index after rendering.
- Draw large containers and state shapes first, then draw the connector lines
  that connect them, then draw labels and annotations that must stay readable.
- A connector must not be hidden behind the element it connects. If the
  arrowhead or endpoint disappears under the target element, reorder the element
  layers or move the endpoint to the visible boundary.
- Preserve diagrams that already passed visual QA. When regenerating all
  diagrams, do not regress previously accepted sections such as the v4
  concurrent state diagram.
- Re-render the full SVG after z-order corrections and inspect every diagram,
  not just the section that changed.

## Modify Lines

- Change `final resizing, label clearance, and visual balance pass after each
render-correction cycle` to `final resizing, label clearance, z-order, and
visual balance pass after each render-correction cycle`.
- Change `Visual endpoint QA for every connector in the rendered screenshot` to
  `Visual endpoint and z-order QA for every connector in the rendered
screenshot`.

## Validation Additions

- Check every arrowhead against the target element boundary.
- Check every line segment that enters a connected element; it must remain
  visible until the intended boundary point.
- If a shape overlaps a connector, decide whether the overlap is intentional. If
  not intentional, fix the layer order, bend points, or endpoint.
