There is an open issue, https://github.com/typst/typst/issues/6965 that requests run-in lists for footnotes and points out that such run-in lists are valuable elsewhere.
Your outline issue is exactly the problem I had in mind when I commented there.
Much too overthought! Try something built on this:
#set page(numbering: "1")
#set heading(numbering: "1.A")
#{
set outline(
title: [Table of contents],
depth: 2,
)
set par(hanging-indent: 1em)
show outline.entry.where(level: 1): it => {
v(0.5em)
it
v(-0.5em)
}
show outline.entry.where(level: 2): it => {
h(1em)
it.prefix() + sym.space.nobreak
it.body() + sym.space.nobreak
"(" + it.page() + ") "
}
outline()
}
= The first chapter
== First chapter, first section
#pagebreak()
== First chapter, second section
#pagebreak()
== First chapter, third section
#pagebreak()
== First chapter, fourth section
#pagebreak()
= The second chapter
== Second chapter, first section
#pagebreak()
== Second chapter, second section
#pagebreak()
== Second chapter, third section
#pagebreak()
== Second chapter, fourth section