CSS for showing heading levels in gutter

OK, so here’s a CSS snippet I came up with that works in all 3 viewing modes (and hides when editing the header), although I haven’t tested it on mobile but should work just fine (preview images below):

:root {
  --hh-gutter-margin: 0;
  --hh-marker-size: 65 / 100;
}

h1:before, .HyperMD-header-1:not(.cm-active):before {
  content: "H1 ";
  font-size: calc(var(--h1-size) * var(--hh-marker-size));
  margin-left: var(--hh-gutter-margin);
}
h2:before, .HyperMD-header-2:not(.cm-active):before {
  content: "H2 ";
  font-size: calc(var(--h2-size) * var(--hh-marker-size));
  margin-left: var(--hh-gutter-margin);
}
h3:before, .HyperMD-header-3:not(.cm-active):before {
  content: "H3 ";
  font-size: calc(var(--h3-size) * var(--hh-marker-size));
  margin-left: var(--hh-gutter-margin);
}
h4:before, .HyperMD-header-4:not(.cm-active):before {
  content: "H4 ";
  font-size: calc(var(--h4-size) * var(--hh-marker-size));
  margin-left: var(--hh-gutter-margin);
}
h5:before, .HyperMD-header-5:not(.cm-active):before {
  content: "H5 ";
  font-size: calc(var(--h5-size) * var(--hh-marker-size));
  margin-left: var(--hh-gutter-margin);
}
h6:before, .HyperMD-header-6:not(.cm-active):before {
  content: "H6 ";
  font-size: calc(var(--h6-size) * var(--hh-marker-size));
  margin-left: var(--hh-gutter-margin);
}

Result with --hh-gutter-margin: -20px (that is, the heading markers are slightly offset to the left of the main content):

Screenshot-01_12_2023-03.10.05

Result with --hh-gutter-margin: 0 (that is, no offset so heading markers are inline with the main content):

Screenshot-01_12_2023-03.10.15

NOTE: you can also adjust the size of the marker with --hh-marker-size, which is a percentage as you may have noticed and as @holroy realized was a better way of achieving this than using random divisions as I initially did.