I am trying to create a line style that consists of 2 lines. The first line (red) is actual border and the second line is a thick transparent line that should align it's bottom edge to the first line. When I zoom enough in QGIS, these lines render correctly, but when zoomed out, you can see that thick line is not rendered correctly. Problem is present even when I export map to PDF. Is there any solution for this?
If you can change your layer to a polygon layer, you can use the "shapeburst fill" to reach this result. It is usually based on a gradient, but if you want a clear boundary like in your example, you can set up a gradient with a second stop colored like the initial value and a last value completely transparent. It can be applied to the inside of the polygon (by default) or the outside, using the "inverted polygon" rendering:
You may want to try a single-sided buffer. Because it is a static layer it is not affected by our zooming in or out.
There are several tools in QGIS for single-sided buffer, e.g.
[OGR] Single sided buffers (and offset lines) for lines,
Virtual Layer: st_singlesidedbuffer(),...
One drawback is that you may not be able to make it much thicker. If the buffer size is too big, output gets funny. (Especially at around corners, kinks and narrow corridors).