Hi,
In the file below (not minimal, sorry!) I am using commands from Wolfgang in different threads. We can see that the top frame overflows into the text: how to correct this ?
I would also like the top and bottom stroke to be adjusted to the width of the paper.
Thanks
Fabrice

\useMPlibrary[dum]

\setuplayout
   [topspace=1cm,
    backspace=3cm,
    cutspace=3cm,
    leftmargin=.75cm,
    leftmargindistance=.5cm,
    rightmargin=1.25cm,
    rightmargindistance=1cm,
    header=20mm,
    headerdistance=1cm,
    footer=20mm,
    footerdistance=1cm,
    width=middle,
    height=middle,
    location=middle]
 
\setupbodyfont
   [newcomputermodern-book,11pt]

\definefont
   [TextStyle]
   [SansBold*default sa 1.2]


\defineframed
  [headerframed]
  [frame=off,
   height=fit,
   width=fit,
  ]

\setupbackgrounds [header] [text]
   [frame=off,bottomframe=on,width=\widthpaper,
    framecolor=darkred,rulethickness=1pt]

\setupbackgrounds [footer] [text]
   [frame=off,bottomframe=on,width=max,
   framecolor=darkred,rulethickness=1pt]

 \setupfootertexts
  [margin]
  []
  [{\offset[y=\strutdp]{\externalfigure[dum][factor=max]}}]
  []
  [{\offset[y=\strutdp]{\externalfigure[dum][factor=max]}}]

\startsetups [headertext]

    \setupheadertexts
        [{
            \startframed [headerframed] [foregroundstyle=TextStyle,align=middle]
                \getvariable{headertext}{location}\\
                 Spécialité mathématiques\\
                \getvariable{headertext}{title} n\high{\tfxx \bf o}\,\getvariable{headertext}{number}
            \stopframed
        }]

    \setupheadertexts
        [{
            \startframed [headerframed] [align=flushleft,foregroundstyle=\ssx]
                Lycée LA SALLE\\
                Durée : \getvariable{headertext}{time}\\
                \date[d=\getvariable{headertext}{day},m=\getvariable{headertext}{month},y=\getvariable{headertext}{year}]
            \stopframed
        }]
        [{
            \startframed [headerframed] [align=flushright,foregroundstyle=\ssx]
              \externalfigure[dum] [factor=max]          
            \stopframed
        }]

\stopsetups

\setvariable{headertext}{set}{\directsetup{headertext}}


\setvariables
  [headertext]
  [title={Devoir maison},
   number={2},
   day={22},
   month={08},
   year={2021},
   location={Terminale},
   time={2 heures}]


\starttext
\samplefile{lorem}
\stoptext