/* Owner-requested guideline/article pairs; sticky within their reading region.
   Loaded only for eligible GAM pages; physical-Russia Yandex keeps its layout. */
.home-redesign .home-rails-side,
.blog-rail-ad { display:none!important; }

/* Keep the pre-existing content width whenever no eligible rail pair is visible. */
@media (min-width:1281px) {
    .home-redesign .home-rails-region>section,
    .home-redesign .home-rails-region>.homepage-latest-blog,
    .home-redesign .home-rails-region>.kbt-store-banner {
        padding-left:0!important;padding-right:0!important;
    }
    .home-redesign .home-rails-side:has([data-gam-rail="1"]),
    .post-layout--with-rails>.blog-rail-ad:has([data-gam-rail="1"]) {
        display:block!important;
    }
    .home-redesign .home-rails-region:has([data-gam-rail="1"])>section,
    .home-redesign .home-rails-region:has([data-gam-rail="1"])>.homepage-latest-blog,
    .home-redesign .home-rails-region:has([data-gam-rail="1"])>.kbt-store-banner {
        padding-left:220px!important;padding-right:220px!important;
    }
}
.home-redesign .home-rails-side__sticky:has([data-gam-rail="1"]),
.blog-rail-ad-inner:has([data-gam-rail="1"]),
.home-redesign .kbt-ad-slot[data-gam-rail="1"] {
    position:static!important;top:auto!important;
}
/* Stick only the existing outer wrapper, never the creative itself.
   Tall windows leave room below the complete creative for the native anchor. */
@media (min-width:1281px) and (min-height:860px) {
    .home-redesign .home-rails-side__sticky:has([data-gam-rail="1"]),
    .blog-rail-ad-inner:has([data-gam-rail="1"]) {
        position:sticky!important;top:88px!important;
    }
}
/* Short, wide desktop windows can fit the same 160x600 ad beside the anchor.
   Remove guide padding and use the available height below the fixed header.
   Below 690px, keep natural scrolling rather than crop or scale the creative. */
@media (min-width:1480px) and (min-height:690px) and (max-height:859.98px) {
    .home-redesign .home-rails-side__sticky:has([data-gam-rail="1"]) {
        padding-block:0;
    }
    .home-redesign .home-rails-side__sticky:has([data-gam-rail="1"]),
    .blog-rail-ad-inner:has([data-gam-rail="1"]) {
        position:sticky!important;top:min(88px,calc(100vh - 616px))!important;
    }
    /* Keep the 900px article centred; move the rails into the outer gutters
       so the native bottom anchor has horizontal clearance on both sides. */
    .post-layout--with-rails:has([data-gam-rail="1"]) {
        max-width:none;
        padding-inline:16px;
        justify-content:space-between;
    }
}
/* Place the navigation control clear of the rails and native anchor.
   The shared script hides it while an inline creative needs the same space. */
@media (min-width:1281px) {
    /* Older cached HTML lacks the collision-aware script. */
    body:has(.kbt-ad-slot[data-gam-rail="1"]) #back-to-top:not([data-kbt-ad-aware="1"]) {
        display:none!important;
    }
    body:has(.kbt-ad-slot[data-gam-rail="1"]) #back-to-top[data-kbt-ad-aware="1"] {
        --kbt-back-to-top-gap:155px;
        transition-property:background-color;
        right:max(232px,calc((100% - 900px)/2 + 32px))!important;
    }
    body:has(.kbt-ad-slot[data-gam-rail="1"]) #back-to-top[data-kbt-ad-aware="1"]:not(.is-docked) {
        bottom:155px!important;
    }
}
.kbt-ad-slot[data-gam-rail="1"] {
    width:160px!important;max-width:160px!important;margin-inline:auto!important;
    padding:0!important;
}
.kbt-ad-slot[data-gam-rail="1"]>.kbt-ad-slot-inner {
    box-sizing:content-box!important;width:160px!important;height:600px!important;
    min-height:600px!important;max-height:600px!important;
    border:0!important;box-shadow:none!important;background:transparent!important;
    border-radius:0!important;padding:0!important;
}
.kbt-ad-slot[data-gam-rail="1"] .kbt-gam-ad {
    width:160px;height:600px;min-height:600px;max-width:160px;
    align-items:center;justify-content:center;
}
