.recently-viewed-section[hidden] {
    display: none !important;
}

.recently-viewed-section {
    --recent-ink: #1f2428;
    --recent-muted: #697077;
    --recent-line: rgba(31, 36, 40, 0.1);
    --recent-gold: #a77b3e;
    padding: 76px 0 82px;
    background: #f4f0e9;
    color: var(--recent-ink);
}

.recently-viewed-heading {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 32px;
    margin-bottom: 30px;
}

.recently-viewed-heading .section-kicker {
    display: block;
    margin-bottom: 9px;
    color: var(--recent-gold);
    font-size: 0.69rem;
    font-weight: 600;
    letter-spacing: 0.2em;
}

.recently-viewed-heading h2 {
    margin: 0;
    color: var(--recent-ink);
    font-family: "Noto Serif SC", "Songti SC", serif;
    font-size: clamp(2rem, 3vw, 2.8rem);
    font-weight: 500;
    letter-spacing: -0.03em;
    line-height: 1.16;
}

.recently-viewed-heading p {
    margin: 10px 0 0;
    color: var(--recent-muted);
    font-size: 0.94rem;
    line-height: 1.7;
}

.recently-viewed-clear {
    display: inline-flex;
    min-height: 42px;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 0 17px;
    border: 1px solid rgba(31, 36, 40, 0.2);
    border-radius: 999px;
    background: transparent;
    color: #41474c;
    font-size: 0.82rem;
    transition: border-color 180ms ease, background-color 180ms ease, color 180ms ease;
}

.recently-viewed-clear:hover,
.recently-viewed-clear:focus-visible {
    border-color: var(--recent-ink);
    background: var(--recent-ink);
    color: #fff;
}

.recently-viewed-list {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(245px, 292px);
    gap: 18px;
    padding: 2px 2px 16px;
    overflow-x: auto;
    overscroll-behavior-inline: contain;
    scroll-padding-inline: 2px;
    scroll-snap-type: inline mandatory;
    scrollbar-color: rgba(31, 36, 40, 0.28) transparent;
    scrollbar-width: thin;
}

.recently-viewed-list::-webkit-scrollbar {
    height: 5px;
}

.recently-viewed-list::-webkit-scrollbar-thumb {
    border-radius: 99px;
    background: rgba(31, 36, 40, 0.24);
}

.recently-viewed-card {
    min-width: 0;
    overflow: hidden;
    border: 1px solid var(--recent-line);
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.9);
    box-shadow: 0 14px 34px -28px rgba(24, 28, 31, 0.4);
    scroll-snap-align: start;
}

.recently-viewed-card__image {
    position: relative;
    display: block;
    aspect-ratio: 4 / 3;
    overflow: hidden;
    background: #e7e3dc;
}

.recently-viewed-card__image img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 700ms cubic-bezier(0.16, 1, 0.3, 1);
}

.recently-viewed-card:hover .recently-viewed-card__image img {
    transform: scale(1.035);
}

.recently-viewed-card__price {
    position: absolute;
    right: 12px;
    bottom: 12px;
    max-width: calc(100% - 24px);
    padding: 7px 11px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.32);
    border-radius: 2px;
    background: rgba(24, 28, 31, 0.84);
    color: #fff;
    font-family: "Inter", "PingFang SC", sans-serif;
    font-size: 0.82rem;
    font-weight: 600;
    text-overflow: ellipsis;
    white-space: nowrap;
    backdrop-filter: blur(8px);
}

.recently-viewed-card__checking {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    background: rgba(24, 28, 31, 0.45);
    color: #fff;
    font-size: 1.45rem;
    opacity: 0;
    pointer-events: none;
    transition: opacity 160ms ease;
}

.recently-viewed-card.is-checking .recently-viewed-card__checking {
    opacity: 1;
}

.recently-viewed-card.is-checking .recently-viewed-card__checking i {
    animation: recently-viewed-spin 800ms linear infinite;
}

@keyframes recently-viewed-spin {
    to { transform: rotate(360deg); }
}

.recently-viewed-card__copy {
    min-height: 178px;
    padding: 20px 19px 18px;
}

.recently-viewed-card__copy small {
    display: block;
    margin-bottom: 9px;
    overflow: hidden;
    color: var(--recent-gold);
    font-size: 0.64rem;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-overflow: ellipsis;
    text-transform: uppercase;
    white-space: nowrap;
}

.recently-viewed-card__copy h3 {
    display: -webkit-box;
    min-height: 2.8em;
    margin: 0 0 8px;
    overflow: hidden;
    font-family: "Noto Serif SC", "Songti SC", serif;
    font-size: 1.03rem;
    font-weight: 500;
    line-height: 1.4;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}

.recently-viewed-card__copy h3 a {
    color: var(--recent-ink);
    text-decoration: none;
}

.recently-viewed-card__copy h3 a:hover,
.recently-viewed-card__copy h3 a:focus-visible {
    color: var(--recent-gold);
}

.recently-viewed-card__copy p {
    margin: 0 0 13px;
    overflow: hidden;
    color: var(--recent-muted);
    font-size: 0.78rem;
    line-height: 1.5;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.recently-viewed-card__copy time {
    color: #858b90;
    font-size: 0.7rem;
}

.recently-viewed-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    min-height: 26px;
    margin-top: 13px;
    color: #777e84;
    font-size: 0.7rem;
    line-height: 1.6;
}

.recently-viewed-footer p {
    margin: 0;
}

.recently-viewed-status {
    color: #895d27;
    font-weight: 500;
    text-align: right;
}

@media (max-width: 767.98px) {
    .recently-viewed-section {
        padding: 48px 0 52px;
    }

    .recently-viewed-heading {
        align-items: flex-start;
        gap: 18px;
        margin-bottom: 22px;
    }

    .recently-viewed-heading h2 {
        font-size: 1.9rem;
    }

    .recently-viewed-heading p {
        max-width: 235px;
        margin-top: 7px;
        font-size: 0.82rem;
        line-height: 1.6;
    }

    .recently-viewed-clear {
        min-height: 38px;
        flex: 0 0 auto;
        padding: 0 12px;
        font-size: 0.72rem;
    }

    .recently-viewed-clear i {
        display: none;
    }

    .recently-viewed-list {
        grid-auto-columns: minmax(74vw, 74vw);
        gap: 13px;
        margin-right: calc(var(--bs-gutter-x, 1.5rem) * -0.5);
        padding-bottom: 12px;
    }

    .recently-viewed-card__copy {
        min-height: 162px;
        padding: 17px 16px 15px;
    }

    .recently-viewed-card__copy h3 {
        font-size: 0.96rem;
    }

    .recently-viewed-footer {
        display: block;
        margin-top: 10px;
    }

    .recently-viewed-status {
        margin-top: 5px !important;
        text-align: left;
    }
}

@media (max-width: 374px) {
    .recently-viewed-heading {
        display: block;
    }

    .recently-viewed-clear {
        margin-top: 15px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .recently-viewed-card__image img,
    .recently-viewed-card__checking,
    .recently-viewed-clear {
        transition: none;
    }
}
