/* ---------- Recently Viewed ---------- */

/* ============================================================
   Recently Viewed — STYLES
   Keep page/component styles in logical sections below.
   ============================================================ */

/* =========================================================
   APEMART — RECENTLY VIEWED PAGE
   Full advertisement details, polished responsive layout
========================================================= */

.recent-page {
    width: 100%;
    flex: 1 0 auto;
    padding: 34px 20px 72px;
    background:
        radial-gradient(circle at 8% 0%, rgba(255,107,0,.08), transparent 32%),
        radial-gradient(circle at 92% 18%, rgba(52,199,89,.07), transparent 28%),
        #f5f7fb;
}

.recent-wrap {
    max-width: 1180px;
    margin: 0 auto;
}

.recent-hero {
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 28px;
    padding: 30px 34px;
    margin-bottom: 26px;
    border: 1px solid rgba(255,107,0,.12);
    border-radius: 24px;
    background: linear-gradient(135deg, #ffffff 0%, #fffaf6 100%);
    box-shadow: 0 14px 40px rgba(31,41,55,.08);
}

.recent-hero::after {
    content: "";
    position: absolute;
    width: 210px;
    height: 210px;
    right: -75px;
    top: -105px;
    border-radius: 50%;
    background: rgba(255,107,0,.08);
}

.recent-heading { position: relative; z-index: 1; }

.recent-kicker {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 9px;
    color: #ff6b00;
    font-size: 13px;
    font-weight: 800;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.recent-hero h1 {
    margin: 0 0 8px;
    color: #172033;
    font-size: clamp(28px, 4vw, 40px);
    line-height: 1.12;
    font-weight: 800;
}

.recent-hero p {
    margin: 0;
    max-width: 650px;
    color: #687386;
    font-size: 16px;
    line-height: 1.65;
}

.recent-action { position: relative; z-index: 1; flex: 0 0 auto; }

.recent-browse-btn,
.recent-open-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    min-height: 46px;
    padding: 0 20px;
    border-radius: 12px;
    background: #ff6b00;
    color: #fff;
    text-decoration: none;
    font-weight: 800;
    box-shadow: 0 9px 20px rgba(255,107,0,.22);
    transition: transform .2s ease, box-shadow .2s ease, background .2s ease;
}

.recent-browse-btn:hover,
.recent-open-btn:hover {
    transform: translateY(-2px);
    background: #ed5f00;
    box-shadow: 0 12px 24px rgba(255,107,0,.28);
}

.recent-content { min-height: 330px; }

.recent-content .products {
    width: 100%;
    max-width: none;
    margin: 0;
}

/* Full ad presentation */
.recent-ad-card {
    display: grid;
    grid-template-columns: minmax(360px, 46%) minmax(0, 1fr);
    overflow: hidden;
    margin-bottom: 24px;
    border: 1px solid #e4e8ef;
    border-radius: 22px;
    background: rgba(255,255,255,.96);
    box-shadow: 0 12px 34px rgba(31,41,55,.08);
    transition: transform .2s ease, box-shadow .2s ease;
}

.recent-ad-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 18px 42px rgba(31,41,55,.12);
}

.recent-ad-visual {
    position: relative;
    min-height: 430px;
    background: #eef1f5;
}

.recent-main-image-link,
.recent-main-image {
    display: block;
    width: 100%;
    height: 100%;
}

.recent-main-image {
    min-height: 430px;
    object-fit: cover;
}

.recent-type-badge {
    position: absolute;
    left: 18px;
    top: 18px;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 9px 13px;
    border-radius: 999px;
    background: rgba(255,255,255,.95);
    color: #253044;
    font-size: 13px;
    font-weight: 800;
    box-shadow: 0 8px 18px rgba(0,0,0,.12);
    backdrop-filter: blur(8px);
}

.recent-type-badge.fixed i { color: #ff6b00; }
.recent-type-badge.auction i { color: #7558d8; }
.recent-type-badge.donate i { color: #e04d76; }

.recent-gallery {
    position: absolute;
    left: 14px;
    right: 14px;
    bottom: 14px;
    display: flex;
    gap: 8px;
    padding: 8px;
    border-radius: 14px;
    background: rgba(20,26,38,.56);
    backdrop-filter: blur(8px);
}

.recent-gallery-thumb {
    width: 58px;
    height: 48px;
    object-fit: cover;
    border: 2px solid transparent;
    border-radius: 9px;
    cursor: pointer;
    opacity: .8;
    transition: opacity .2s ease, border-color .2s ease, transform .2s ease;
}

.recent-gallery-thumb:hover { opacity: 1; transform: translateY(-1px); }
.recent-gallery-thumb.active { opacity: 1; border-color: #fff; }

.recent-ad-body {
    display: flex;
    flex-direction: column;
    padding: 28px 30px 26px;
}

.recent-ad-topline {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.recent-viewed-label {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    color: #ff6b00;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: .04em;
    text-transform: uppercase;
}

.recent-view-date { color: #8a94a5; font-size: 12px; }

.recent-ad-title { margin: 0 0 8px; }

.recent-ad-title a {
    color: #172033;
    font-size: clamp(25px, 3vw, 34px);
    line-height: 1.2;
    text-decoration: none;
}

.recent-ad-title a:hover { color: #ff6b00; }

.recent-ad-price {
    margin-bottom: 22px;
    color: #ff6b00;
    font-size: 25px;
    font-weight: 900;
}

.recent-detail-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px 12px;
}

.recent-detail-row {
    min-width: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 11px 12px;
    border: 1px solid #edf0f4;
    border-radius: 12px;
    background: #fafbfc;
}

.recent-detail-row span {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    min-width: 0;
    color: #778196;
    font-size: 12px;
}

.recent-detail-row span i { width: 14px; text-align: center; color: #ff6b00; }

.recent-detail-row strong {
    max-width: 58%;
    overflow: hidden;
    color: #263044;
    font-size: 13px;
    text-align: right;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.recent-description {
    margin-top: 18px;
    padding: 17px 18px;
    border-radius: 15px;
    background: #f7f8fa;
}

.recent-description h3 {
    margin: 0 0 7px;
    color: #263044;
    font-size: 14px;
}

.recent-description h3 i { margin-right: 6px; color: #ff6b00; }

.recent-description p {
    margin: 0;
    color: #687386;
    font-size: 14px;
    line-height: 1.65;
}

.recent-card-actions { margin-top: auto; padding-top: 20px; }
.recent-open-btn { width: 100%; min-height: 48px; }

.recent-empty {
    min-height: 360px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 36px 20px;
}

.recent-empty-card {
    width: min(620px, 100%);
    padding: 46px 34px;
    text-align: center;
    border: 1px solid #e6eaf0;
    border-radius: 24px;
    background: rgba(255,255,255,.94);
    box-shadow: 0 14px 40px rgba(31,41,55,.08);
}

.recent-empty-icon {
    width: 82px;
    height: 82px;
    display: grid;
    place-items: center;
    margin: 0 auto 22px;
    border-radius: 50%;
    background: linear-gradient(135deg, #fff1e7, #fff8f2);
    color: #ff6b00;
    font-size: 38px;
    box-shadow: inset 0 0 0 1px rgba(255,107,0,.08);
}

.recent-empty-card h2 { margin: 0 0 10px; color: #1f2937; font-size: 25px; line-height: 1.25; }
.recent-empty-card p { max-width: 470px; margin: 0 auto 24px; color: #778196; font-size: 15px; line-height: 1.7; }
.recent-empty-card .recent-browse-btn { min-width: 170px; }

.recent-loading,
.recent-error {
    min-height: 300px;
    display: grid;
    place-items: center;
    text-align: center;
    color: #687386;
    font-size: 15px;
}

.recent-loading span { display: block; margin-bottom: 8px; font-size: 28px; }

body.dark-mode .recent-page {
    background:
        radial-gradient(circle at 8% 0%, rgba(255,107,0,.09), transparent 32%),
        #111827;
}

body.dark-mode .recent-hero,
body.dark-mode .recent-empty-card,
body.dark-mode .recent-ad-card {
    background: linear-gradient(135deg, #1f2937 0%, #202b3a 100%);
    border-color: #374151;
    box-shadow: 0 14px 40px rgba(0,0,0,.22);
}

body.dark-mode .recent-hero h1,
body.dark-mode .recent-empty-card h2,
body.dark-mode .recent-ad-title a,
body.dark-mode .recent-detail-row strong,
body.dark-mode .recent-description h3 { color: #f3f4f6; }

body.dark-mode .recent-hero p,
body.dark-mode .recent-empty-card p,
body.dark-mode .recent-detail-row span,
body.dark-mode .recent-description p { color: #aeb8c7; }

body.dark-mode .recent-detail-row,
body.dark-mode .recent-description { background: #172130; border-color: #344052; }

@media (max-width: 900px) {
    .recent-ad-card { grid-template-columns: 1fr; }
    .recent-ad-visual, .recent-main-image { min-height: 360px; height: 360px; }
}

@media (max-width: 700px) {
    .recent-page { padding: 22px 14px 52px; }

    .recent-hero {
        align-items: flex-start;
        flex-direction: column;
        padding: 24px 22px;
        border-radius: 20px;
    }

    .recent-action, .recent-browse-btn { width: 100%; }
    .recent-browse-btn { min-height: 44px; }

    .recent-ad-card { border-radius: 18px; margin-bottom: 18px; }
    .recent-ad-visual, .recent-main-image { min-height: 260px; height: 260px; }
    .recent-ad-body { padding: 21px 18px 20px; }
    .recent-ad-title a { font-size: 25px; }
    .recent-ad-price { font-size: 22px; margin-bottom: 17px; }
    .recent-detail-grid { grid-template-columns: 1fr; gap: 8px; }
    .recent-detail-row { padding: 10px 11px; }
    .recent-detail-row strong { max-width: 62%; }
    .recent-gallery-thumb { width: 48px; height: 42px; }
    .recent-description { padding: 14px; }
}

.recent-breadcrumb {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 0 12px 4px;
    color: #8a94a5;
    font-size: 13px;
    font-weight: 600;
}

.recent-breadcrumb a {
    color: #687386;
    text-decoration: none;
}

.recent-breadcrumb a:hover { color: #ff6b00; }
.recent-breadcrumb span:last-child { color: #ff6b00; }

body.dark-mode .recent-breadcrumb a { color: #aeb8c7; }
body.dark-mode .recent-breadcrumb span:last-child { color: #ff914d; }

/* =========================================================
   RECENTLY VIEWED — MATCH THE STANDARD APEMART AD CARD
   Image on top, ALL advertisement information underneath.
   Do not use a side-by-side two-column card here.
========================================================= */
.recent-content .products {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 22px;
    align-items: stretch;
}

.recent-ad-card {
    display: flex;
    flex-direction: column;
    width: 100%;
    min-width: 0;
    margin: 0;
    border: 1px solid #e6e9ee;
    border-radius: 18px;
    background: #fff;
    overflow: hidden;
    box-shadow: 0 8px 24px rgba(15,23,42,.07);
}

.recent-ad-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 14px 30px rgba(15,23,42,.11);
}

.recent-ad-visual {
    position: relative;
    width: 100%;
    height: 225px;
    min-height: 225px;
    background: #f3f4f6;
    overflow: hidden;
}

.recent-main-image-link,
.recent-main-image {
    width: 100%;
    height: 100%;
}

.recent-main-image {
    display: block;
    object-fit: cover;
}

.recent-ad-body {
    display: flex;
    flex-direction: column;
    flex: 1;
    padding: 15px 16px 16px;
    min-width: 0;
}

/* Title must sit immediately below the photo. */
.recent-ad-title {
    order: 1;
    margin: 0 0 7px;
}

.recent-ad-title a {
    display: -webkit-box;
    overflow: hidden;
    color: #18212f;
    font-size: 18px;
    line-height: 1.35;
    font-weight: 800;
    text-decoration: none;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}

.recent-ad-price {
    order: 2;
    margin: 0 0 8px;
    color: #ff6b00;
    font-size: 20px;
    line-height: 1.3;
    font-weight: 900;
}

.recent-detail-grid {
    order: 3;
    display: flex;
    flex-direction: column;
    gap: 0;
}

/* Keep the information visible, but remove the nested mini-card look. */
.recent-detail-row {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
    padding: 5px 0;
    border: 0;
    border-radius: 0;
    background: transparent;
}

.recent-detail-row span {
    flex: 0 0 auto;
    color: #697586;
    font-size: 12px;
}

.recent-detail-row strong {
    max-width: none;
    overflow: hidden;
    color: #344054;
    font-size: 12px;
    text-align: left;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.recent-description {
    order: 4;
    margin-top: 9px;
    padding: 11px 12px;
    border-radius: 12px;
    background: #f7f8fa;
}

.recent-description p {
    display: -webkit-box;
    overflow: hidden;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
}

.recent-ad-topline {
    order: 5;
    margin: 9px 0 0;
    justify-content: space-between;
}

.recent-card-actions {
    order: 6;
    padding-top: 10px;
}

.recent-open-btn {
    width: 100%;
    min-height: 40px;
    border-radius: 10px;
    font-size: 13px;
}

@media (max-width: 1000px) {
    .recent-content .products {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 650px) {
    .recent-content .products {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .recent-ad-card {
        max-width: 420px;
        margin: 0 auto;
    }

    .recent-ad-visual {
        height: 220px;
        min-height: 220px;
    }
}

@media (max-width: 430px) {
    .recent-ad-visual {
        height: 210px;
        min-height: 210px;
    }
}

/* Dark mode */
body.dark-mode .recent-ad-card {
    background: #1f2937;
    border-color: #374151;
}

body.dark-mode .recent-ad-title a,
body.dark-mode .recent-detail-row strong {
    color: #f3f4f6;
}

body.dark-mode .recent-detail-row span,
body.dark-mode .recent-view-date {
    color: #aab4c2;
}

body.dark-mode .recent-description {
    background: #151b23;
}

/* =========================================================
   FINAL RECENTLY VIEWED CARD — MATCH THE USER'S SAMPLE
   Photo first, then title/details directly underneath.
   Keep all advertisement information; no side-by-side layout.
========================================================= */
.recent-content .products {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 340px));
    gap: 22px;
    max-width: 1080px;
    margin: 0 auto;
    justify-content: start;
    align-items: start;
}

.recent-content .recent-ad-card {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 340px;
    margin: 0;
    padding: 0;
    overflow: hidden;
    border: 1px solid #e6e9ee;
    border-radius: 16px;
    background: #fff;
    box-shadow: 0 7px 22px rgba(20,30,40,.07);
    transform: none;
}

.recent-content .recent-ad-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 13px 30px rgba(20,30,40,.11);
}

.recent-content .recent-ad-visual {
    position: relative;
    width: 100%;
    height: 190px;
    min-height: 190px;
    background: #f3f5f7;
    overflow: hidden;
}

.recent-content .recent-main-image-link,
.recent-content .recent-main-image {
    display: block;
    width: 100%;
    height: 100%;
}

.recent-content .recent-main-image {
    object-fit: cover;
    object-position: center;
}

.recent-content .recent-ad-body {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
    padding: 14px 16px 16px;
}

.recent-content .recent-ad-title {
    order: 1;
    margin: 0 0 5px;
}

.recent-content .recent-ad-title a {
    display: -webkit-box;
    overflow: hidden;
    color: #18212f;
    font-size: 19px;
    line-height: 1.35;
    font-weight: 800;
    text-decoration: none;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}

.recent-content .recent-ad-price {
    order: 2;
    margin: 0 0 7px;
    color: #ff6b00;
    font-size: 22px;
    line-height: 1.3;
    font-weight: 900;
}

.recent-content .recent-detail-grid {
    order: 3;
    display: flex;
    flex-direction: column;
    gap: 0;
}

.recent-content .recent-detail-row {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
    min-width: 0;
    padding: 4px 0;
    border: 0;
    border-radius: 0;
    background: transparent;
}

.recent-content .recent-detail-row span {
    flex: 0 0 auto;
    min-width: 0;
    color: #697586;
    font-size: 12px;
}

.recent-content .recent-detail-row strong {
    max-width: none;
    min-width: 0;
    overflow: hidden;
    color: #344054;
    font-size: 12px;
    font-weight: 600;
    text-align: left;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.recent-content .recent-description {
    order: 4;
    margin-top: 8px;
    padding: 10px 12px;
    border-radius: 11px;
    background: #f7f8fa;
}

.recent-content .recent-description h3 {
    margin: 0 0 5px;
    color: #263044;
    font-size: 13px;
}

.recent-content .recent-description p {
    display: -webkit-box;
    overflow: hidden;
    margin: 0;
    color: #687386;
    font-size: 12px;
    line-height: 1.55;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
}

.recent-content .recent-ad-topline {
    order: 5;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin: 10px 0 0;
}

.recent-content .recent-viewed-label,
.recent-content .recent-view-date {
    font-size: 11px;
}

.recent-content .recent-card-actions {
    order: 6;
    margin-top: 0;
    padding-top: 9px;
}

.recent-content .recent-open-btn {
    width: 100%;
    min-height: 42px;
    padding: 0 14px;
    border-radius: 10px;
    font-size: 13px;
}

@media (max-width: 1100px) {
    .recent-content .products {
        grid-template-columns: repeat(2, minmax(0, 340px));
        justify-content: center;
    }
}

@media (max-width: 720px) {
    .recent-content .products {
        grid-template-columns: minmax(0, 1fr);
        max-width: 390px;
        gap: 18px;
        justify-content: center;
    }

    .recent-content .recent-ad-card {
        max-width: 390px;
    }

    .recent-content .recent-ad-visual {
        height: 210px;
        min-height: 210px;
    }
}

body.dark-mode .recent-content .recent-ad-card {
    background: #1f2937;
    border-color: #374151;
}

body.dark-mode .recent-content .recent-ad-title a,
body.dark-mode .recent-content .recent-detail-row strong,
body.dark-mode .recent-content .recent-description h3 {
    color: #f3f4f6;
}

body.dark-mode .recent-content .recent-detail-row span,
body.dark-mode .recent-content .recent-description p {
    color: #aab4c2;
}

body.dark-mode .recent-content .recent-description {
    background: #151b23;
}

/* =========================================================
   RECENTLY VIEWED — SAME AD CARD AS THE HOME PAGE
   The page header/frame remains unchanged; ad cards use the
   exact Home card dimensions, spacing and information order.
========================================================= */
.recent-content .products{
    width:100%;
    max-width:none;
    margin:0;
    display:grid;
    grid-template-columns:repeat(4,minmax(0,1fr));
    gap:17px;
    align-items:stretch;
}
.recent-content .home-ad-card{
    background:#fff!important;
    border:1px solid #e7ecf1!important;
    border-radius:17px!important;
    overflow:hidden!important;
    box-shadow:0 6px 22px rgba(15,23,42,.055)!important;
    display:flex!important;
    flex-direction:column!important;
    min-width:0;
    width:100%;
    max-width:none;
    margin:0;
    color:inherit;
    text-decoration:none;
    cursor:pointer;
    transition:.2s;
}
.recent-content .home-ad-card:hover{
    transform:translateY(-3px);
    box-shadow:0 13px 30px rgba(15,23,42,.10)!important;
}
.recent-content .home-ad-image{
    height:205px!important;
    position:relative;
    overflow:hidden;
    background:#f1f3f5;
}
.recent-content .home-ad-image img{width:100%;height:100%;object-fit:cover;display:block}
.recent-content .home-ad-body{padding:14px 15px 15px;display:flex;flex-direction:column;flex:1}
.recent-content .home-ad-title{font-size:15px!important;line-height:1.35!important;color:#202938!important;margin:0 0 8px!important;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}
.recent-content .home-ad-price{font-size:18px;font-weight:900;color:#ff6b00;margin-bottom:8px}
.recent-content .home-ad-detail{display:flex;align-items:center;gap:7px;color:#7b8492;font-size:11px;margin:3px 0}
.recent-content .home-ad-detail i{width:12px;flex:0 0 12px;text-align:center;color:#9aa3ae}
.recent-content .home-ad-distance{color:#5c6877}
.recent-content .home-ad-meta{display:flex;justify-content:space-between;gap:8px;color:#9aa3ae;font-size:10px;margin-top:0;padding:10px 0;order:3}
.recent-content .home-ad-type-row{margin:8px 0 6px;order:4}
.recent-content .home-ad-type{display:inline-flex;align-items:center;gap:5px;border-radius:999px;padding:5px 8px;font-size:10px;font-weight:900;background:#f4f6f8;color:#586272}
.recent-content .home-ad-type.fixed{background:#fff4e9;color:#e45d00}
.recent-content .home-ad-type.auction{background:#f2efff;color:#6847b9}
.recent-content .home-ad-type.donate{background:#fff0f1;color:#d43b4a}
.recent-content .promotion-badge{position:absolute;top:10px;left:10px;z-index:3;display:inline-flex;align-items:center;gap:5px;padding:6px 10px;border-radius:999px;font-size:11px;font-weight:800;letter-spacing:.3px;background:rgba(255,255,255,.96);box-shadow:0 5px 14px rgba(0,0,0,.14)}

@media(max-width:1100px){
    .recent-content .products{grid-template-columns:repeat(2,minmax(0,1fr));}
}
@media(max-width:700px){
    .recent-content .products{grid-template-columns:repeat(2,minmax(0,1fr));gap:10px}
    .recent-content .home-ad-image{height:145px!important}
    .recent-content .home-ad-body{padding:11px}
    .recent-content .home-ad-title{font-size:12px!important}
    .recent-content .home-ad-price{font-size:15px}
    .recent-content .home-ad-detail{font-size:9px}
    .recent-content .home-ad-type{font-size:8px;padding:4px 6px}
    .recent-content .home-ad-meta{font-size:8px}
}
@media(max-width:420px){
    .recent-content .products{grid-template-columns:1fr;gap:8px}
    .recent-content .home-ad-image{height:130px!important}
}

/* Delivery method badge — matched to the Home ad-card badge style. */
.recent-content .home-ad-type-row{display:flex;align-items:center;flex-wrap:wrap;gap:6px}
.recent-content .home-ad-type.delivery{background:#eef8f1;color:#2f7d46}

/* =========================================================
   MOBILE — TWO AD CARDS PER ROW
   Match the compact Search/standard marketplace card layout.
   Keep all existing advertisement details visible.
========================================================= */
@media (max-width: 650px) {
    .recent-content .products {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 14px;
        width: 100%;
        max-width: none;
        margin: 0;
    }

    .recent-content .recent-ad-card {
        width: 100%;
        max-width: none;
        margin: 0;
        border-radius: 14px;
    }

    .recent-content .recent-ad-visual {
        height: auto;
        min-height: 0;
        aspect-ratio: 1 / .78;
    }

    .recent-content .recent-ad-body {
        padding: 11px 11px 12px;
    }

    .recent-content .recent-ad-title {
        margin-bottom: 5px;
    }

    .recent-content .recent-ad-title a {
        font-size: 14px;
        line-height: 1.3;
        -webkit-line-clamp: 2;
    }

    .recent-content .recent-ad-price {
        margin-bottom: 6px;
        font-size: 16px;
    }

    .recent-content .recent-detail-row {
        gap: 5px;
        padding: 3px 0;
    }

    .recent-content .recent-detail-row span,
    .recent-content .recent-detail-row strong {
        font-size: 10.5px;
    }

    .recent-content .recent-detail-row strong {
        min-width: 0;
    }

    .recent-content .recent-ad-topline,
    .recent-content .recent-description,
    .recent-content .recent-card-actions {
        display: none;
    }

    .recent-content .recent-gallery {
        left: 7px;
        right: 7px;
        bottom: 7px;
        gap: 5px;
        padding: 5px;
    }

    .recent-content .recent-gallery-thumb {
        width: 34px;
        height: 30px;
        border-radius: 6px;
    }
}

@media (max-width: 430px) {
    .recent-content .products {
        gap: 10px;
    }

    .recent-content .recent-ad-card {
        border-radius: 13px;
    }

    .recent-content .recent-ad-body {
        padding: 10px 9px 11px;
    }

    .recent-content .recent-ad-title a {
        font-size: 13px;
    }

    .recent-content .recent-ad-price {
        font-size: 15px;
    }

    .recent-content .recent-detail-row span,
    .recent-content .recent-detail-row strong {
        font-size: 10px;
    }
}

/* =========================================================
   RECENTLY VIEWED — FINAL MOBILE 2-COLUMN CARD FIX
   Match the compact marketplace/Search card size on phones.
   Keep two cards per row even on screens <= 420px.
========================================================= */
@media (max-width: 650px) {
    .recent-content .products {
        display: grid !important;
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 10px !important;
        width: 100% !important;
        max-width: none !important;
        margin: 0 !important;
    }

    .recent-content .home-ad-card {
        width: 100% !important;
        max-width: none !important;
        min-width: 0 !important;
        margin: 0 !important;
        border-radius: 13px !important;
        overflow: hidden !important;
        box-shadow: 0 4px 15px rgba(15,23,42,.06) !important;
    }

    .recent-content .home-ad-image {
        height: 128px !important;
        min-height: 128px !important;
        aspect-ratio: auto !important;
    }

    .recent-content .home-ad-body {
        padding: 9px 9px 10px !important;
    }

    .recent-content .home-ad-title {
        font-size: 12px !important;
        line-height: 1.3 !important;
        margin: 0 0 5px !important;
        -webkit-line-clamp: 2 !important;
    }

    .recent-content .home-ad-price {
        font-size: 15px !important;
        line-height: 1.25 !important;
        margin: 0 0 6px !important;
    }

    .recent-content .home-ad-detail {
        display: flex !important;
        gap: 5px !important;
        font-size: 8.5px !important;
        line-height: 1.25 !important;
        margin: 2px 0 !important;
        min-width: 0 !important;
    }

    .recent-content .home-ad-detail i {
        width: 10px !important;
        flex: 0 0 10px !important;
    }

    .recent-content .home-ad-detail span {
        min-width: 0 !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        white-space: nowrap !important;
    }

    .recent-content .home-ad-meta {
        display: flex !important;
        gap: 5px !important;
        font-size: 8px !important;
        line-height: 1.25 !important;
        padding: 7px 0 4px !important;
    }

    .recent-content .home-ad-type-row {
        display: flex !important;
        flex-wrap: wrap !important;
        gap: 4px !important;
        margin: 5px 0 0 !important;
    }

    .recent-content .home-ad-type {
        font-size: 8px !important;
        line-height: 1 !important;
        padding: 4px 6px !important;
        gap: 3px !important;
    }
}

@media (max-width: 430px) {
    /* Keep the two-card layout on small phones — never collapse to one. */
    .recent-content .products {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 8px !important;
    }

    .recent-content .home-ad-card {
        border-radius: 12px !important;
    }

    .recent-content .home-ad-image {
        height: 116px !important;
        min-height: 116px !important;
    }

    .recent-content .home-ad-body {
        padding: 8px 8px 9px !important;
    }

    .recent-content .home-ad-title {
        font-size: 11.5px !important;
        margin-bottom: 4px !important;
    }

    .recent-content .home-ad-price {
        font-size: 14px !important;
        margin-bottom: 5px !important;
    }

    .recent-content .home-ad-detail {
        font-size: 8px !important;
        margin: 2px 0 !important;
    }

    .recent-content .home-ad-meta {
        font-size: 7.5px !important;
        padding: 6px 0 3px !important;
    }

    .recent-content .home-ad-type {
        font-size: 7.5px !important;
        padding: 4px 5px !important;
    }
}

/* Mobile-only: compact Recently Viewed hero card.
   Keep the current desktop/tablet design and the two-column ad cards unchanged. */
@media (max-width: 700px) {
    .recent-hero {
        padding: 22px 20px 20px;
        margin-bottom: 20px;
        gap: 14px;
        border-radius: 22px;
    }

    .recent-kicker {
        margin-bottom: 6px;
        font-size: 12px;
    }

    .recent-hero h1 {
        margin-bottom: 6px;
        font-size: 34px;
        line-height: 1.12;
    }

    .recent-hero p {
        font-size: 15px;
        line-height: 1.5;
    }

    .recent-action,
    .recent-browse-btn {
        width: 100%;
    }

    .recent-browse-btn {
        min-height: 42px;
        padding: 0 16px;
        border-radius: 11px;
    }
}

@media (max-width: 430px) {
    .recent-hero {
        padding: 20px 18px 18px;
        gap: 12px;
        margin-bottom: 18px;
    }

    .recent-hero h1 {
        font-size: 32px;
    }

    .recent-hero p {
        font-size: 14px;
        line-height: 1.48;
    }

    .recent-browse-btn {
        min-height: 40px;
        font-size: 14px;
    }
}

/* =========================================================
   FINAL MOBILE POLISH — HERO + LOADING STATE
   Mobile only. Keep desktop/tablet and 2-column ad cards unchanged.
========================================================= */
@media (max-width: 700px) {
    .recent-hero {
        padding: 20px 19px 18px;
        margin-bottom: 18px;
        gap: 11px;
    }

    .recent-kicker {
        margin-bottom: 5px;
        font-size: 11.5px;
    }

    .recent-hero h1 {
        margin-bottom: 5px;
        font-size: 31px;
        line-height: 1.1;
    }

    .recent-hero p {
        font-size: 14px;
        line-height: 1.46;
    }

    .recent-browse-btn {
        min-height: 39px;
        padding: 0 15px;
        border-radius: 11px;
        font-size: 14px;
    }

    /* Loading must occupy the full content width, not one ad-card column. */
    .recent-content .recent-loading,
    .recent-content .recent-error,
    .recent-content > .recent-loading,
    .recent-content > .recent-error {
        grid-column: 1 / -1 !important;
        width: 100% !important;
        min-width: 100% !important;
        justify-self: stretch !important;
        align-self: stretch !important;
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        justify-content: center !important;
        text-align: center !important;
        margin: 0 auto !important;
        padding: 28px 16px !important;
        box-sizing: border-box !important;
    }

    .recent-content .recent-loading span {
        display: block !important;
        margin: 0 auto 12px !important;
        text-align: center !important;
    }
}

@media (max-width: 430px) {
    .recent-hero {
        padding: 18px 17px 16px;
        gap: 10px;
        margin-bottom: 16px;
        border-radius: 20px;
    }

    .recent-kicker {
        font-size: 11px;
    }

    .recent-hero h1 {
        font-size: 29px;
    }

    .recent-hero p {
        font-size: 13.5px;
        line-height: 1.44;
    }

    .recent-browse-btn {
        min-height: 38px;
        font-size: 13.5px;
    }

    .recent-content .recent-loading,
    .recent-content .recent-error {
        padding: 26px 12px !important;
    }
}
