/* Profile-only presentation. Every declaration is desktop-gated; mobile uses native CSS.
 * Geometry matches WPCode 12732. Do not add .side-col: its icon rule affects controls.
 */
@media (min-width: 768px) {
    body.mw-profile-layout {
        --mw-profile-column: 19vw;
        --mw-profile-rail: 0px;
    }
    body.mw-profile-layout #main {
        display: block;
        width: auto;
        max-width: none;
        padding: 16px 0;
    }
    body.mw-profile-layout #main > .content,
    body.mw-profile-layout #main .post--page,
    body.mw-profile-layout #main .entry-content {
        width: 100%;
        max-width: none;
        min-width: 0;
        margin: 0;
        padding: 0;
    }
    body.mw-profile-layout .profile-wrapper {
        box-sizing: border-box;
        /* Override the UAG block and WPCode's !important tablet padding. */
        padding: 0 !important;
        margin-left: calc(92px + var(--mw-profile-column) - var(--mw-profile-rail));
        margin-right: 16px;
        width: calc(100vw - 108px - var(--mw-profile-column));
        max-width: none;
    }
    body.mw-profile-layout .profile-wrapper > .uagb-columns__inner-wrap,
    body.mw-profile-layout .profile-wrapper .uagb-block-d6aa773d,
    body.mw-profile-layout .profile-wrapper .peepso,
    body.mw-profile-layout .profile-wrapper .ps-page,
    body.mw-profile-layout .profile-wrapper .ps-profile__layout,
    body.mw-profile-layout .profile-wrapper .ps-profile__middle {
        box-sizing: border-box;
        width: 100%;
        max-width: none;
        min-width: 0;
        margin: 0;
        padding: 0;
    }
    body.mw-profile-layout .profile-wrapper .mwi-cellar-v2,
    body.mw-profile-layout .profile-wrapper .mw-profile-recipes,
    body.mw-profile-layout .profile-wrapper .mws-marketplace--profile {
        box-sizing: border-box;
        width: 100%;
        max-width: none;
        min-width: 0;
        margin-top: 0;
        margin-left: 0;
        margin-right: 0;
    }
    body.mw-profile-layout .profile-wrapper .ps-section,
    body.mw-profile-layout .profile-wrapper .mwvstore-app,
    body.mw-profile-layout .profile-wrapper .mwvstore-controls-products-wrapper > * {
        min-width: 0;
        max-width: 100%;
    }
    /* Shared focus is emitted by native sections and Cellar/Store/Recipes/Menus/Services.
     * Fixing it in place leaves each section's filters, headings and controls in flow.
     */
    body.mw-profile-layout .profile-wrapper .ps-js-focus--profile {
        box-sizing: border-box;
        position: fixed;
        top: 67px;
        left: 76px;
        right: auto;
        bottom: 16px;
        width: var(--mw-profile-column);
        height: auto;
        max-width: none;
        margin: 0;
        padding: 16px 16px 0;
        border: 1px solid #e2e6eb;
        border-radius: 10px;
        background: linear-gradient(270deg, #f5f8fc, #fff);
        box-shadow: none;
        display: flex;
        flex-direction: column;
        overflow: visible;
        z-index: 99;
        --cover-span: 0px;
        --like-span: 0px;
    }
    body.mw-profile-layout .ps-js-focus--profile .ps-focus__cover {
        flex: 0 0 auto;
        border-radius: 8px;
        padding: 0;
        /* Reserve space for the avatar and actions below the landscape image. */
        padding-top: 52%;
        background: transparent;
    }
    body.mw-profile-layout .ps-js-focus--profile .ps-focus__cover:before {
        display: none;
    }
    body.mw-profile-layout .ps-js-focus--profile .ps-focus__cover-image {
        height: auto;
        bottom: auto;
        aspect-ratio: 25 / 13;
        border-radius: 8px;
    }
    /* Keep cover-image positioning and its image's native inline styles untouched:
     * PeepSo's crop/reposition controller owns them.
     */
    body.mw-profile-layout .ps-js-focus--profile .ps-focus__cover-inner {
        position: relative;
        inset: auto;
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        padding: 0;
        background: none;
    }
    body.mw-profile-layout .ps-js-focus--profile .ps-focus__avatar {
        position: relative;
        inset: auto;
        width: 72px;
        height: 72px;
        min-width: 72px;
        margin: -24px 0 8px 8px;
        flex: 0 0 72px;
    }
    body.mw-profile-layout .ps-js-focus--profile .ps-focus__avatar img {
        width: 100%;
        height: 100%;
        object-fit: cover;
    }
    body.mw-profile-layout .ps-js-focus--profile .ps-focus__avatar-change {
        opacity: 1;
    }
    body.mw-profile-layout .ps-js-focus--profile .ps-focus__cover-actions {
        display: none;
        flex-wrap: wrap;
        gap: 6px;
        width: 100%;
    }
    /* Reuse PeepSo's existing second primary-action rendering below identity.
     * Its native handlers/refresh selectors are the same; never create copies.
     */
    body.mw-profile-layout .ps-js-focus--profile .ps-focus__mobile-actions,
    body.mw-profile-layout .ps-js-focus--profile .ps-focus__actions {
        display: contents;
    }
    body.mw-profile-layout .ps-js-focus--profile .ps-focus__options {
        opacity: 1;
        top: 8px;
        right: 8px;
    }
    body.mw-profile-layout .ps-js-focus--profile .ps-focus__options-toggle > span {
        /* Compact icon control must retain its native accessible name. */
        display: inline;
        position: absolute;
        width: 1px;
        height: 1px;
        padding: 0;
        margin: -1px;
        overflow: hidden;
        clip-path: inset(50%);
        white-space: nowrap;
        border: 0;
    }
    body.mw-profile-layout .ps-js-focus--profile .ps-focus__reposition {
        top: 8px;
        right: 8px;
    }
    body.mw-profile-layout .ps-js-focus--profile .ps-focus__footer,
    body.mw-profile-layout .ps-js-focus--profile .ps-focus__info {
        background: transparent;
        padding: 0;
        text-align: left;
    }
    body.mw-profile-layout .ps-js-focus--profile > .ps-focus__footer {
        display: flex;
        flex-direction: column;
        flex: 1 1 0;
        min-height: 0;
        min-width: 0;
        overflow: visible;
    }
    body.mw-profile-layout .ps-js-focus--profile .ps-focus__info {
        display: flex;
        flex-wrap: wrap;
        align-content: flex-start;
        align-items: center;
        flex: 0 0 auto;
        gap: 6px;
        padding: 8px 0;
    }
    body.mw-profile-layout .ps-js-focus--profile .ps-focus__title {
        flex: 0 0 100%;
        min-width: 0;
        margin: 0;
        padding: 0;
        font-size: 18px;
        overflow-wrap: anywhere;
    }
    /* Flatten only the existing presentation groups. Statistics remain first;
     * the flex break places Like/Share and all permitted action groups below them.
     * The original nodes, privacy spans and handlers remain in their native DOM.
     */
    body.mw-profile-layout .ps-js-focus--profile .ps-focus__details {
        display: contents;
    }
    body.mw-profile-layout .ps-js-focus--profile .ps-focus__details::after {
        content: "";
        order: 1;
        flex: 0 0 100%;
        height: 0;
    }
    body.mw-profile-layout .ps-js-focus--profile .ps-focus__details > .ps-focus__detail {
        margin: 0;
        min-width: 0;
        overflow-wrap: anywhere;
    }
    body.mw-profile-layout .ps-js-focus--profile .ps-focus__details > :not(.ps-focus__detail),
    body.mw-profile-layout .ps-js-focus--profile .ps-focus__mobile-actions > *,
    body.mw-profile-layout .ps-js-focus--profile .ps-focus__actions > * {
        order: 2;
        flex: 0 1 auto;
        position: static;
        float: none;
        width: auto;
        min-width: 0;
        max-width: 100%;
        margin: 0;
        text-align: left;
    }
    body.mw-profile-layout .ps-js-focus--profile .ps-focus__like,
    body.mw-profile-layout .ps-js-focus--profile .ps-focus__shared,
    body.mw-profile-layout .ps-js-focus--profile .ps-focus__mobile-actions > a,
    body.mw-profile-layout .ps-js-focus--profile .ps-focus__actions > a {
        display: inline-flex;
        align-items: center;
        gap: 4px;
        padding: 5px 8px;
        border: 1px solid #e2e6eb;
        border-radius: 6px;
        background: #fff;
        font-size: 12px;
        line-height: 1.3;
        white-space: nowrap;
    }
    body.mw-profile-layout .ps-js-focus--profile .ps-focus__like > span,
    body.mw-profile-layout .ps-js-focus--profile .ps-focus__shared > span {
        display: inline;
        margin: 0;
        font: inherit;
    }
    body.mw-profile-layout .ps-js-focus--profile .ps-focus__like > i,
    body.mw-profile-layout .ps-js-focus--profile .ps-focus__shared > i {
        flex: 0 0 auto;
        margin: 0;
    }
    body.mw-profile-layout .ps-js-focus--profile .ps-focus__cover-action {
        max-width: 100%;
        white-space: normal;
        overflow-wrap: anywhere;
    }
    body.mw-profile-layout .ps-js-focus--profile .ps-dropdown__menu {
        --width: 100%;
        box-sizing: border-box;
        min-width: 0;
        max-width: 100%;
        white-space: normal;
        left: 0;
        right: auto;
        transform: none;
    }
    /* Native rearrange() resets hidden originals then measures the last row's
     * horizontal edge. Full-width, border-box rows fit, so it exits without cloning.
     * Important display also exposes originals immediately during the native 1s
     * resize debounce. Only overflow UI is hidden, never permission-filtered items.
     */
    body.mw-profile-layout .ps-js-focus--profile .ps-focus__menu {
        flex: 1 1 0;
        min-height: 0;
        height: auto;
        overflow-y: auto;
        overflow-x: hidden;
        overscroll-behavior-y: contain;
        scroll-padding-block: 8px;
        scrollbar-width: thin;
        background: transparent;
        padding: 8px 0;
    }
    body.mw-profile-layout .ps-js-focus--profile .ps-focus__menu-inner {
        display: flex;
        flex-direction: column;
        align-items: stretch;
        width: 100%;
        height: auto;
        overflow: visible;
        gap: 4px;
    }
    body.mw-profile-layout .ps-js-focus--profile .ps-focus__menu-inner > .ps-js-item {
        box-sizing: border-box;
        display: block !important;
        flex: 0 0 auto;
        width: 100%;
        min-width: 0;
        border: 0;
        border-radius: 10px;
        white-space: normal;
        text-align: left;
    }
    body.mw-profile-layout .ps-js-focus--profile .ps-focus__menu-item-inner {
        box-sizing: border-box;
        flex-direction: row;
        justify-content: flex-start;
        height: auto;
        min-height: 44px;
        padding: 6px 8px;
        gap: 10px;
        overflow-wrap: anywhere;
    }
    body.mw-profile-layout .ps-js-focus--profile .ps-focus__menu-item-inner > i {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        flex: 0 0 35px;
        height: 35px;
        border-radius: 50%;
        background: #f5f8fc;
        color: #2f88ff;
    }
    body.mw-profile-layout .ps-js-focus--profile .ps-focus__menu-item--active,
    body.mw-profile-layout .ps-js-focus--profile .ps-focus__menu-item:hover,
    body.mw-profile-layout .ps-js-focus--profile .ps-focus__menu-item:focus-visible {
        color: #2f88ff;
        background: #fff;
        box-shadow: 0 0 10px #e2e6eb;
    }
    body.mw-profile-layout .ps-js-focus--profile .ps-focus__menu-item--active .ps-focus__menu-item-inner:after {
        display: none;
    }
    body.mw-profile-layout .ps-js-focus--profile .ps-focus__menu-more,
    body.mw-profile-layout .ps-js-focus--profile .ps-js-item-more,
    body.mw-profile-layout .ps-js-focus--profile .ps-focus__menu-shadow {
        display: none !important;
    }
    /* The desktop helper moves this one existing page block here. Its natural
     * height includes wrapped legal lines, and flex reserves that exact space.
     */
    body.mw-profile-layout .footer-custom {
        position: static;
        inset: auto;
        box-sizing: border-box;
        display: block;
        flex: 0 0 auto;
        width: 100%;
        min-width: 0;
        max-width: 100%;
        margin: 0;
        padding: 10px 0 12px;
        border-top: 1px solid #e2e6eb;
        background: transparent;
    }
    body.mw-profile-layout .footer-custom > .wp-block-column {
        min-width: 0;
    }
    body.mw-profile-layout .footer-custom .eb-socials {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
        margin: 0;
        padding: 0;
    }
    body.mw-profile-layout .footer-custom .legal-links {
        margin: 0;
        line-height: 1.4;
        overflow-wrap: anywhere;
    }

}
@media (min-width: 61.25em) {
    body.mw-profile-layout.gc-body--sidenav { --mw-profile-rail: 60px; }
}
@media (min-width: 1024px) and (max-width: 1366px) {
    body.mw-profile-layout { --mw-profile-column: 25vw; }
}

/* Compact only when vertical space is limited. Cover and avatar keep their native
 * wrappers/positioning logic; no crop styles or control nodes are removed.
 */
@media (min-width: 768px) and (max-height: 800px) {
    body.mw-profile-layout .ps-js-focus--profile .ps-focus__cover {
        padding-top: clamp(40px, 10vh, 80px);
    }
    body.mw-profile-layout .ps-js-focus--profile .ps-focus__cover-image {
        height: clamp(40px, 10vh, 80px);
        aspect-ratio: auto;
    }
    body.mw-profile-layout .ps-js-focus--profile .ps-focus__info {
        gap: 4px;
        padding: 6px 0;
    }
    body.mw-profile-layout .footer-custom {
        padding: 6px 0 8px;
    }
}
@media (min-width: 768px) and (max-height: 650px) {
    body.mw-profile-layout .profile-wrapper .ps-js-focus--profile { padding-top: 8px; }
    body.mw-profile-layout .ps-js-focus--profile .ps-focus__cover { padding-top: 40px; }
    body.mw-profile-layout .ps-js-focus--profile .ps-focus__cover-image { height: 40px; }
    body.mw-profile-layout .ps-js-focus--profile .ps-focus__avatar {
        width: 48px;
        height: 48px;
        min-width: 48px;
        flex-basis: 48px;
        margin-top: -16px;
        margin-bottom: 4px;
    }
    body.mw-profile-layout .ps-js-focus--profile .ps-focus__title { font-size: 16px; }
    body.mw-profile-layout .ps-js-focus--profile .ps-focus__detail { font-size: 11px; }
    body.mw-profile-layout .ps-js-focus--profile .ps-focus__menu-item-inner {
        min-height: 36px;
        padding-block: 4px;
    }
}

@media (min-width: 768px) {
    body.mw-profile-layout .footer-custom .eb-social-links-4tx5s .eb-socials li a {
        width: 0;
        height: 0;
        font-size: 12px;
    }
}
@media (min-width: 768px) and (max-width: 979px) and (max-height: 800px) {
    body.mw-profile-layout .ps-js-focus--profile .ps-focus__cover { padding-top: 40px; }
    body.mw-profile-layout .ps-js-focus--profile .ps-focus__cover-image { height: 40px; }
    body.mw-profile-layout .ps-js-focus--profile .ps-focus__avatar {
        width: 48px;
        height: 48px;
        min-width: 48px;
        flex-basis: 48px;
        margin-top: -16px;
        margin-bottom: 4px;
    }
    body.mw-profile-layout .ps-js-focus--profile .ps-focus__title {
        font-size: 14px;
        line-height: 1.15;
    }
    body.mw-profile-layout .ps-js-focus--profile .ps-focus__details > .ps-focus__detail {
        display: inline-flex;
        align-items: baseline;
        gap: 2px;
        font-size: 10.5px;
        line-height: 1.2;
    }
    body.mw-profile-layout .ps-js-focus--profile .ps-focus__details > .ps-focus__detail i {
        min-width: 14px;
        margin: 0;
    }
    body.mw-profile-layout .ps-js-focus--profile .ps-focus__like,
    body.mw-profile-layout .ps-js-focus--profile .ps-focus__shared,
    body.mw-profile-layout .ps-js-focus--profile .ps-focus__mobile-actions .ps-focus__cover-action,
    body.mw-profile-layout .ps-js-focus--profile .ps-focus__actions .ps-focus__cover-action {
        font-size: 11px;
        line-height: 1.2;
        padding: 3px 6px;
    }
    body.mw-profile-layout .footer-custom .legal-links {
        /* Page18 supplies inline 12px; compact only the constrained desktop case. */
        font-size: 11px !important;
        line-height: 1.25;
    }
}

/* Final approved action-row correction. PeepSo changes these native labels in
 * place. Reserve the widest English follow state (including Start following)
 * before hover/focus; do not measure only the currently visible Following text.
 */
@media (min-width: 768px) {
    body.mw-profile-layout .ps-js-focus--profile .ps-focus__mobile-actions::before {
        content: "";
        order: 3;
        flex: 0 0 100%;
        height: 0;
    }
    body.mw-profile-layout .ps-js-focus--profile .ps-focus__mobile-actions > * {
        order: 3;
    }
    body.mw-profile-layout .ps-js-focus--profile .ps-focus__mobile-actions > :is(.ps-js-friend-follow, .ps-js-friend-unfollow) {
        box-sizing: border-box;
        flex: 0 0 min(100%, calc(14ch + 14px));
        width: min(100%, calc(14ch + 14px));
        min-width: 0;
        justify-content: center;
        white-space: nowrap;
    }
    body.mw-profile-layout .ps-js-focus--profile .ps-focus__mobile-actions > :is(a[onclick*="ps_messages.new_message"], .ps-js-dropdown-toggle) {
        box-sizing: border-box;
        display: inline-flex;
        flex: 0 0 30px;
        align-items: center;
        justify-content: center;
        width: 30px;
        min-width: 30px;
        min-height: 28px;
        padding: 5px;
    }
    /* Native friend controls are rendered in the extra-action group. A full row
     * also keeps Friend/Unfriend and request states out of the compact control row.
     */
    body.mw-profile-layout .ps-js-focus--profile :is(.ps-focus__actions, .ps-focus__mobile-actions) > .pso-member__action:not(.ps-js-friend-follow):not(.ps-js-friend-unfollow) {
        box-sizing: border-box;
        order: 4;
        flex: 0 0 100%;
        width: 100%;
        white-space: normal;
        justify-content: center;
    }
    body.mw-profile-layout .footer-custom .eb-social-links-4tx5s.eb-social-links-wrapper ul.eb-socials {
        justify-content: center;
    }
}
@media (min-width: 768px) and (max-width: 1023px) {
    body.mw-profile-layout .ps-js-focus--profile .ps-focus__mobile-actions > :is(.ps-js-friend-follow, .ps-js-friend-unfollow) {
        flex-basis: 100%;
        width: 100%;
    }
}
@media (min-width: 1920px) {
    body.mw-profile-layout .ps-js-focus--profile .ps-focus__mobile-actions::before {
        display: none;
    }
    body.mw-profile-layout .ps-js-focus--profile .ps-focus__mobile-actions > * {
        order: 2;
    }
}

@media (min-width: 1920px) {
    body.mw-profile-layout .ps-js-focus--profile .ps-focus__info { gap: 4px; }
    body.mw-profile-layout .ps-js-focus--profile :is(.ps-focus__like, .ps-focus__shared) {
        padding-inline: 6px;
    }
    body.mw-profile-layout .ps-js-focus--profile :is(.ps-focus__like, .ps-focus__shared) > i {
        min-width: 12px;
        width: 12px;
    }
}

@media (min-width: 768px) {
    body.mw-profile-layout .ps-js-focus--profile :is(.ps-focus__like, .ps-focus__shared),
    body.mw-profile-layout .ps-js-focus--profile .ps-focus__mobile-actions > :is(.ps-js-friend-follow, .ps-js-friend-unfollow) {
        box-sizing: border-box;
        min-height: 28px;
    }
}

/* Held refinements: existing native controls and content only. */
@media (min-width: 768px) {
    body.mw-profile-layout .ps-js-focus--profile .mw-profile-identity {
        display: flex !important;
        flex-wrap: wrap;
        gap: 2px 8px;
        margin-top: 3px;
        font-size: 12px;
        font-weight: 400;
        line-height: 1.3;
        color: var(--PS-COLOR--TEXT--LIGHT);
    }
    body.mw-profile-layout .ps-js-focus--profile .ps-focus__detail:has(.gci-user-plus) {
        font-size: 11px;
        color: var(--PS-COLOR--TEXT--LIGHT);
    }
    body.mw-profile-layout .ps-js-focus--profile .ps-focus__mobile-actions > a:is(
        [onclick*="ps_messages.new_message"], :has(> .pso-i-user-pen)),
    body.mw-profile-layout .ps-js-focus--profile .ps-focus__info:not(:has([onclick*="ps_messages.new_message"])) .ps-focus__mobile-actions > :is(.ps-js-friend-follow, .ps-js-friend-unfollow) {
        background: var(--PS-COLOR--PRIMARY, #2f88ff);
        color: #fff;
        border-color: var(--PS-COLOR--PRIMARY, #2f88ff);
    }
    body.mw-profile-layout .profile-wrapper .mwi-cellar-v2 > .mwi-v2-hero {
        padding-block: 12px;
        gap: 12px;
    }
    body.mw-profile-layout .profile-wrapper .mwi-v2-identity > .mwi-v2-avatar,
    body.mw-profile-layout .profile-wrapper .mwi-v2-identity .mwi-v2-kicker {
        display: none;
    }
}

/* WPCode20100 leaves the native empty chat root shrink-to-fit at zero width.
 * Restore its native viewport insets before PeepSo measures available windows.
 * Keep native visibility, breakpoints, stacking, permissions and handlers.
 */
@media (min-width: 768px) {
    body.mw-profile-layout #ps-chat-root.ps-chat__wrapper {
        left: var(--PADD--MD, 20px) !important;
        right: var(--PADD--MD, 20px) !important;
    }
}

/* Compact section card; native mobile titles and layouts remain untouched. */
body.mw-profile-layout .profile-wrapper .mw-profile-content-heading { display: none; }
@media (min-width: 768px) {
    body.mw-profile-layout .profile-wrapper .mw-profile-content-heading {
     display: flex;
        align-items: center;
        gap: 12px;
        box-sizing: border-box;
        width: 100%;
        min-width: 0;
        margin: 0 0 16px;
        padding: 10px 10px;
        border-radius: 20px;
        background: #f5f8fc;
        box-shadow: none;
        font-family: inherit;
        font-size: 22px;
        font-weight: 600;
        line-height: 1.3;
        color: var(--PS-COLOR--TEXT, #494954);
    }
    body.mw-profile-layout .profile-wrapper .mw-profile-heading-icon {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 40px;
        height: 40px;
        flex: 0 0 40px;
        border-radius: 50%;
        background: rgba(47, 136, 255, .10);
        color: var(--PS-COLOR--PRIMARY, #2f88ff);
        font-size: 20px;
        line-height: 1;
    }
    body.mw-profile-layout .profile-wrapper .mw-profile-heading-label {
        min-width: 0;
        overflow-wrap: anywhere;
    }
    body.mw-profile-layout .profile-wrapper .mw-profile-equivalent-title { display: none !important; }
}
