You’re code is all good, it’s just that you’ve encountered a small Observable-specific glitch. As far as I understand it, due to the way the user’s coding is embedded in an iframe, the use of webworkers, and some design decision on URL’s, Observable has a ‘bug’ that makes it less easy to reference urls inside SVG.
See this forum discussion: Url() references within SVGs.
All is not lost, you just need to use the DOM.uid
library helper.
Here’s a working version of your code, with the simple patch applied: