How does one place content relative to the page margin?

You can’t do this excessively, because only text can do this. This is the preferred way, because inline it’s much more readable to do #text(12pt)[word] or #text(red)[word] or both, rather than adding size: and fill: .

See arguments, https://typst.app/docs/reference/text/text/#example, and How does one place content relative to the page margin? - #11 by bluss.

Look at indentations:

#let QDecorate(open, close, body, lang) = context {
  let QScale = 1.1818
  let llap(Text, Size, Color, Lower) = {
    show: box.with(width: 0pt)
    show: align.with(right)
    text(baseline: Lower, size: Size, fill: Color)[#Text]
  }
  let rlap(Text, Size, Color, Lower) = {
    show: box.with(width: 0pt)
    show: align.with(left)
    text(baseline: Lower, size: Size, fill: Color)[#Text]
  }
  let adjust = (text.size * QScale - text.size) / 4
  set text(lang: lang) if lang != none
  set par(first-line-indent: 0pt)
  llap([#open#sym.space], QScale * text.size, QGray, adjust)
  body
  rlap([#sym.wj#sym.space.nobreak#close], QScale * text.size, QGray, adjust)
}

#let QDecorate(Open, Close, Text, lang) = {
  let QScale = 1.1818
  let llap(Text, Size, Color, Lower) = {
    show: box.with(width: 0pt)
    show: align.with(right)
    text(baseline: Lower, size: Size, fill: Color)[#Text]
  }
  let rlap(Text, Size, Color, Lower) = {
    show: box.with(width: 0pt)
    show: align.with(left)
    text(baseline: Lower, size: Size, fill: Color)[#Text]
  }
  context{
    let Adjust = (( (text.size)*QScale - (text.size))/4)
    set text(lang: lang) if lang != none
    set par(first-line-indent: 0pt)
    llap([#Open#sym.space],QScale*text.size,QGray,Adjust)
    Text
    rlap([#sym.wj#sym.space.nobreak#Close],QScale*text.size,QGray,Adjust)
  }
}

Since output is content either way, and it’s not a global show rule, and no other state is changed/fetched above, so to simplify the code flow I moved it. Indentations are bad, when they accumulate. Maybe you’ve heard about Linux source code and that 3 indentations is really bad. I try to follow this when possible. It makes the code easier to read and maintain.

I just tried something, and it didn’t work, at least for the closing symbol. I think that there should be something better than box(width: 0pt), as it’s (currently) behaving strangely.