document.addEventListener("DOMContentLoaded", function () { var rail = document.querySelector(".right-rail"); if (!rail) return; var header = document.querySelector("header"); if (!header) return; function updateTop() { if (getComputedStyle(rail).position !== "fixed") { rail.style.top = ""; return; } var rect = header.getBoundingClientRect(); rail.style.top = Math.max(8, rect.bottom + 8) + "px"; } window.addEventListener("scroll", updateTop, { passive: true }); window.addEventListener("resize", updateTop); updateTop(); });