Mermaid supports a different layout engine which supports slightly more complex diagrams, called the Eclipse Layout Kernel (ELK). Trilium has support for these as well, but it's not enabled by default.

In order to activate ELK for any diagram, insert the following YAML frontmatter right at the beginning of the diagram:

    ---
    config:
      layout: elk
    ---

With ELK off | With ELK on
--- | ---