If it helps, you can use the sort option on the cell mark instead of computing the y-scale’s domain manually as sort: {y: "fill", reverse: true, reduce: "sum"}. (Thanks for sharing your notebook!)
https://observablehq.com/plot/features/scales#sort-mark-option