/* STEP88 — final responsive layout correction.
   Loaded last and intentionally uses stronger selectors than legacy ads CSS. */

/* Home hero: every element owns its row, no overlap at any width. */
html body .ads-page .ads86-hero {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) auto !important;
    grid-template-areas:
        "copy submit"
        "search search" !important;
    gap: 24px 32px !important;
    align-items: start !important;
}
html body .ads-page .ads86-hero-copy {
    grid-area: copy !important;
    min-width: 0 !important;
}
html body .ads-page .ads86-submit {
    grid-area: submit !important;
    position: static !important;
    inset: auto !important;
    z-index: auto !important;
    margin: 0 !important;
    align-self: start !important;
    white-space: nowrap !important;
}
html body .ads-page .ads86-search-form {
    grid-area: search !important;
    position: static !important;
    width: 100% !important;
    min-width: 0 !important;
    margin: 0 !important;
    clear: both !important;
}

/* Detail gallery: hard reset conflicting legacy layers. */
html body article.ad-detail-page.kf-detail .kf-detail-grid {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) 390px !important;
    gap: 20px !important;
    align-items: start !important;
    width: 100% !important;
}
html body article.ad-detail-page.kf-detail .kf-detail-media {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    order: 1 !important;
    min-width: 0 !important;
    width: 100% !important;
    padding: 18px !important;
    overflow: hidden !important;
    background: #fff !important;
}
html body article.ad-detail-page.kf-detail .kf-detail-side {
    order: 2 !important;
}
html body article.ad-detail-page.kf-detail .kf-detail-gallery {
    display: grid !important;
    grid-template-columns: 88px minmax(0, 1fr) !important;
    gap: 14px !important;
    width: 100% !important;
    min-width: 0 !important;
}
html body article.ad-detail-page.kf-detail .kf-detail-gallery.no-thumbs {
    display: block !important;
}
html body article.ad-detail-page.kf-detail .kf-detail-main-photo {
    position: relative !important;
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    width: 100% !important;
    height: clamp(430px, 55vw, 650px) !important;
    min-height: 430px !important;
    max-height: 650px !important;
    margin: 0 !important;
    padding: 0 !important;
    aspect-ratio: auto !important;
    overflow: hidden !important;
    border-radius: 8px !important;
    background: #eef1f2 !important;
}
html body article.ad-detail-page.kf-detail .kf-detail-open-photo {
    position: absolute !important;
    inset: 0 !important;
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
    align-items: center !important;
    justify-content: center !important;
    width: 100% !important;
    height: 100% !important;
    min-width: 0 !important;
    min-height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    background: transparent !important;
    overflow: hidden !important;
}
html body article.ad-detail-page.kf-detail .kf-detail-open-photo > img,
html body article.ad-detail-page.kf-detail #detailGalleryImage {
    position: static !important;
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    width: 100% !important;
    height: 100% !important;
    min-width: 0 !important;
    min-height: 0 !important;
    max-width: 100% !important;
    max-height: 100% !important;
    object-fit: contain !important;
    object-position: center !important;
    border-radius: 0 !important;
    background: transparent !important;
}

@media (max-width: 899px) {
    html body .ads-page .ads86-hero {
        display: flex !important;
        flex-direction: column !important;
        gap: 18px !important;
        padding: 22px 16px 18px !important;
    }
    html body .ads-page .ads86-hero-copy {
        order: 1 !important;
        width: 100% !important;
    }
    html body .ads-page .ads86-search-form {
        order: 2 !important;
        display: grid !important;
        grid-template-columns: 1fr !important;
        width: 100% !important;
        margin: 0 !important;
        overflow: hidden !important;
    }
    html body .ads-page .ads86-submit {
        order: 3 !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        width: 100% !important;
        min-height: 52px !important;
        margin: 0 !important;
        padding: 13px 18px !important;
    }

    html body article.ad-detail-page.kf-detail {
        width: 100% !important;
        max-width: none !important;
        margin: 0 auto 78px !important;
        padding: 0 0 86px !important;
        overflow: visible !important;
    }
    html body article.ad-detail-page.kf-detail .kf-detail-breadcrumbs {
        margin: 0 !important;
        padding: 14px 16px !important;
        white-space: nowrap !important;
        overflow-x: auto !important;
    }
    html body article.ad-detail-page.kf-detail .kf-detail-grid {
        display: flex !important;
        flex-direction: column !important;
        gap: 0 !important;
        width: 100% !important;
    }
    html body article.ad-detail-page.kf-detail .kf-detail-media {
        display: block !important;
        order: 1 !important;
        width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
        border-radius: 0 !important;
        overflow: visible !important;
    }
    html body article.ad-detail-page.kf-detail .kf-detail-side {
        display: block !important;
        order: 2 !important;
        position: static !important;
        width: 100% !important;
        margin: 0 !important;
        padding: 20px 16px !important;
        border: 0 !important;
        border-radius: 0 !important;
    }
    html body article.ad-detail-page.kf-detail .kf-detail-gallery,
    html body article.ad-detail-page.kf-detail .kf-detail-gallery.has-thumbs,
    html body article.ad-detail-page.kf-detail .kf-detail-gallery.no-thumbs {
        display: flex !important;
        flex-direction: column !important;
        gap: 0 !important;
        width: 100% !important;
    }
    html body article.ad-detail-page.kf-detail .kf-detail-main-photo {
        order: 1 !important;
        display: block !important;
        width: 100% !important;
        height: min(72vw, 470px) !important;
        min-height: 280px !important;
        max-height: 470px !important;
        border-radius: 0 !important;
        background: #eef1f2 !important;
    }
    html body article.ad-detail-page.kf-detail .kf-detail-thumbs {
        order: 2 !important;
        display: flex !important;
        flex-direction: row !important;
        gap: 8px !important;
        width: 100% !important;
        max-height: none !important;
        padding: 10px 12px !important;
        overflow-x: auto !important;
        overflow-y: hidden !important;
        background: #fff !important;
    }
    html body article.ad-detail-page.kf-detail .kf-detail-thumb {
        flex: 0 0 68px !important;
        width: 68px !important;
        height: 54px !important;
        min-width: 68px !important;
        min-height: 54px !important;
    }
    html body article.ad-detail-page.kf-detail .kf-detail-gallery-arrow {
        display: flex !important;
    }
    html body article.ad-detail-page.kf-detail .kf-detail-description,
    html body article.ad-detail-page.kf-detail .kf-ad-map-section,
    html body article.ad-detail-page.kf-detail .related-ads {
        width: auto !important;
        max-width: none !important;
        margin: 12px 16px 0 !important;
        padding: 20px !important;
    }
}

@media (max-width: 520px) {
    html body .ads-page .ads86-hero h1 {
        font-size: 30px !important;
        line-height: 1.12 !important;
    }
    html body .ads-page .ads86-stats {
        gap: 8px !important;
    }
    html body article.ad-detail-page.kf-detail .kf-detail-main-photo {
        height: 74vw !important;
        min-height: 260px !important;
        max-height: 390px !important;
    }
}
