/* OSANIME Profile UI — Stage 6 v282
 * Final responsive/device QA layer.
 * This file is intentionally loaded last. It reconciles historical profile
 * breakpoints without changing any backend/profile behaviour.
 */

body.profile-ui-stage6-v282 {
    --profile-s6-gutter: clamp(12px, 2.1vw, 30px);
    --profile-s6-gap: clamp(12px, 1.45vw, 20px);
    --profile-s6-radius: 16px;
    --profile-s6-control: 44px;
    --profile-s6-header-gap: 92px;
    --profile-s6-visual-height: 100dvh;
    overflow-x: clip !important;
    scroll-padding-bottom: max(36px, calc(env(safe-area-inset-bottom) + 24px));
}

/* Final sizing contract: no descendant is allowed to force the document
   wider than the viewport. */
body.profile-ui-stage6-v282 :where(
    .profile-php-wrap,
    .member-main,
    .member-layout,
    .profile-main-column,
    .profile-member-side,
    .profile-member-side-sticky,
    .profile-identity-card,
    .member-profile-info,
    .member-tabs,
    .member-extra-panel,
    .member-list-panel,
    .profile-stage9-card,
    .profile-about-panel-v280,
    .profile-community-v280,
    .profile-library-intro,
    .profile-upload-toolbar,
    .profile-post-feed
) {
    min-width: 0 !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
}

body.profile-ui-stage6-v282 :where(
    .profile-name-copy,
    .profile-stat-copy,
    .profile-upload-mobile-copy,
    .profile-post-card,
    .profile-stage9-contribution-copy,
    .profile-stage9-suggestion-copy,
    .profile-about-data-copy-v280
) {
    min-width: 0 !important;
}

body.profile-ui-stage6-v282 :where(
    .profile-name-copy h2,
    .profile-name-copy small,
    .member-bio,
    .profile-post-card h3,
    .profile-post-card p,
    .profile-upload-mobile-copy,
    .profile-stage9-contribution-copy,
    .profile-stage9-suggestion-copy,
    .profile-about-data-copy-v280,
    .profile-social-user-row b,
    .profile-social-user-row small
) {
    overflow-wrap: anywhere !important;
    word-break: normal !important;
}

body.profile-ui-stage6-v282 .profile-php-wrap {
    width: 100% !important;
    max-width: 1440px !important;
    margin-inline: auto !important;
    padding: clamp(16px, 2vw, 26px) var(--profile-s6-gutter)
        max(48px, calc(env(safe-area-inset-bottom) + 34px)) !important;
}

body.profile-ui-stage6-v282 .member-layout {
    grid-template-columns: minmax(0, 1fr) clamp(286px, 21vw, 312px) !important;
    gap: var(--profile-s6-gap) !important;
    align-items: start !important;
}

body.profile-ui-stage6-v282 .profile-main-column {
    width: 100% !important;
}

body.profile-ui-stage6-v282 .profile-member-side-sticky {
    gap: 12px !important;
    align-items: start !important;
}

body.profile-ui-stage6-v282 .profile-member-side-sticky > * {
    min-width: 0 !important;
    align-self: start !important;
}

/* Hero final density. Avoid a huge empty cover on laptops while preserving a
   strong identity area on wide desktop. */
body.profile-ui-stage6-v282 .profile-identity-card {
    min-height: 0 !important;
    grid-template-columns: clamp(116px, 10.5vw, 136px) minmax(0, 1fr) !important;
    gap: clamp(20px, 2vw, 28px) !important;
    padding: clamp(24px, 2.4vw, 34px) !important;
    border-radius: 20px !important;
}

body.profile-ui-stage6-v282 .profile-hero-avatar-shell,
body.profile-ui-stage6-v282 .profile-hero-avatar-shell .member-profile-avatar {
    width: clamp(112px, 10.5vw, 136px) !important;
    height: clamp(112px, 10.5vw, 136px) !important;
}

body.profile-ui-stage6-v282 .member-profile-info {
    width: 100% !important;
    max-width: none !important;
}

body.profile-ui-stage6-v282 .member-profile-name {
    min-width: 0 !important;
    justify-content: flex-start !important;
}

body.profile-ui-stage6-v282 .profile-name-copy h2 {
    max-width: min(100%, 780px) !important;
    font-size: clamp(27px, 2.4vw, 36px) !important;
}

body.profile-ui-stage6-v282 .profile-stage9-identity-community {
    max-width: 100% !important;
    flex-wrap: wrap !important;
}

body.profile-ui-stage6-v282 .profile-identity-actions {
    width: 100% !important;
    max-width: 100% !important;
    gap: 8px !important;
}

body.profile-ui-stage6-v282 .profile-identity-actions > *,
body.profile-ui-stage6-v282 .profile-social-actions > * {
    min-width: 0 !important;
}

body.profile-ui-stage6-v282 .member-stats-inline.profile-stats-social {
    width: min(100%, 860px) !important;
    gap: 7px !important;
}

body.profile-ui-stage6-v282 .member-stats-inline.profile-stats-social > div,
body.profile-ui-stage6-v282 .member-stats-inline.profile-stats-social > .profile-stat-button {
    min-width: 0 !important;
    min-height: 66px !important;
}

/* Tabs: keep them compact on desktop and reliably scrollable on touch. */
body.profile-ui-stage6-v282 .member-tabs {
    position: relative !important;
    width: 100% !important;
    max-width: 100% !important;
    scroll-behavior: smooth;
    scroll-padding-inline: 10px !important;
}

body.profile-ui-stage6-v282 .member-tabs a {
    min-height: var(--profile-s6-control) !important;
    height: var(--profile-s6-control) !important;
}

body.profile-ui-stage6-v282 .member-tabs.is-scrollable {
    mask-image: linear-gradient(90deg, transparent 0, #000 14px, #000 calc(100% - 14px), transparent 100%);
    -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 14px, #000 calc(100% - 14px), transparent 100%);
}
body.profile-ui-stage6-v282 .member-tabs.is-at-start {
    mask-image: linear-gradient(90deg, #000 0, #000 calc(100% - 14px), transparent 100%);
    -webkit-mask-image: linear-gradient(90deg, #000 0, #000 calc(100% - 14px), transparent 100%);
}
body.profile-ui-stage6-v282 .member-tabs.is-at-end {
    mask-image: linear-gradient(90deg, transparent 0, #000 14px, #000 100%);
    -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 14px, #000 100%);
}
body.profile-ui-stage6-v282 .member-tabs.is-at-start.is-at-end {
    mask-image: none;
    -webkit-mask-image: none;
}

/* Normalize content surfaces so every tab feels like the same product. */
body.profile-ui-stage6-v282 :where(
    .member-list-panel,
    .member-extra-panel,
    .profile-stage9-card,
    .profile-about-bio-card-v280,
    .profile-about-section-v280,
    .profile-library-intro,
    .profile-post-feed,
    .member-side-card,
    .member-profile-share-card
) {
    border-radius: var(--profile-s6-radius) !important;
}

body.profile-ui-stage6-v282 :where(
    .profile-social-btn,
    .profile-hero-action,
    .member-owner-link,
    .member-website-link,
    .member-extra-btn,
    .profile-content-head-actions a,
    .profile-content-head-actions button,
    .profile-login-primary,
    .profile-login-secondary,
    .profile-social-list-more,
    .profile-social-list-retry
) {
    min-height: var(--profile-s6-control) !important;
}

/* Dynamic viewport-safe dialogs. --profile-s6-visual-height is updated by JS
   from visualViewport, so Android/iOS keyboards cannot trap the bottom action. */
body.profile-ui-stage6-v282 .profile-login-modal,
body.profile-ui-stage6-v282 .profile-social-list-modal {
    min-height: 0 !important;
    height: var(--profile-s6-visual-height, 100dvh) !important;
    max-height: var(--profile-s6-visual-height, 100dvh) !important;
}

body.profile-ui-stage6-v282 .profile-login-dialog,
body.profile-ui-stage6-v282 .profile-social-list-dialog {
    max-height: calc(var(--profile-s6-visual-height, 100dvh) - 24px) !important;
    overscroll-behavior: contain !important;
}

body.profile-ui-stage6-v282.profile-modal-open {
    overflow: hidden !important;
    overscroll-behavior: none !important;
}

/* Laptop / small desktop: sidebar stays useful without crushing main content. */
@media (min-width: 1181px) and (max-width: 1360px) {
    body.profile-ui-stage6-v282 {
        --profile-s6-gutter: clamp(14px, 1.8vw, 24px);
    }
    body.profile-ui-stage6-v282 .member-layout {
        grid-template-columns: minmax(0, 1fr) 286px !important;
        gap: 16px !important;
    }
    body.profile-ui-stage6-v282 .profile-identity-card {
        grid-template-columns: 116px minmax(0, 1fr) !important;
        padding: 26px !important;
    }
    body.profile-ui-stage6-v282 .profile-hero-avatar-shell,
    body.profile-ui-stage6-v282 .profile-hero-avatar-shell .member-profile-avatar {
        width: 112px !important;
        height: 112px !important;
    }
    body.profile-ui-stage6-v282 .profile-name-copy h2 {
        font-size: clamp(25px, 2.3vw, 31px) !important;
    }
}

/* Any short desktop viewport should scroll normally rather than trapping a
   tall sidebar inside sticky positioning. */
@media (min-width: 1181px) and (max-height: 720px) {
    body.profile-ui-stage6-v282 .profile-member-side,
    body.profile-ui-stage6-v282 .profile-member-side-sticky {
        position: static !important;
        top: auto !important;
    }
}

/* Tablet: supporting content moves below the profile in two equal columns. */
@media (max-width: 1180px) {
    body.profile-ui-stage6-v282 .member-layout {
        grid-template-columns: minmax(0, 1fr) !important;
        gap: 14px !important;
    }
    body.profile-ui-stage6-v282 .profile-member-side,
    body.profile-ui-stage6-v282 .profile-member-side-sticky {
        position: static !important;
        top: auto !important;
    }
    body.profile-ui-stage6-v282 .profile-member-side-sticky {
        display: grid !important;
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 12px !important;
    }
}

/* Tablet portrait / large phone. */
@media (max-width: 860px) {
    body.profile-ui-stage6-v282 {
        --profile-s6-gutter: 13px;
        --profile-s6-gap: 12px;
    }
    body.profile-ui-stage6-v282 .profile-php-wrap {
        padding-top: 16px !important;
    }
    body.profile-ui-stage6-v282 .profile-identity-card {
        grid-template-columns: 104px minmax(0, 1fr) !important;
        gap: 18px !important;
        padding: 22px !important;
    }
    body.profile-ui-stage6-v282 .profile-hero-avatar-shell,
    body.profile-ui-stage6-v282 .profile-hero-avatar-shell .member-profile-avatar {
        width: 100px !important;
        height: 100px !important;
    }
    body.profile-ui-stage6-v282 .profile-name-copy h2 {
        font-size: clamp(24px, 5vw, 30px) !important;
    }
    body.profile-ui-stage6-v282 .member-stats-inline.profile-stats-social {
        grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    }
}

/* Phones: one clear vertical flow, no desktop grid squeezed into the viewport. */
@media (max-width: 700px) {
    body.profile-ui-stage6-v282 {
        --profile-s6-gutter: 11px;
        --profile-s6-control: 46px;
    }
    body.profile-ui-stage6-v282 .profile-php-wrap {
        padding-top: 12px !important;
        padding-bottom: max(42px, calc(env(safe-area-inset-bottom) + 30px)) !important;
    }
    body.profile-ui-stage6-v282 .profile-identity-card {
        grid-template-columns: minmax(0, 1fr) !important;
        gap: 13px !important;
        padding: 18px 16px !important;
        border-radius: 17px !important;
    }
    body.profile-ui-stage6-v282 .profile-hero-avatar-shell,
    body.profile-ui-stage6-v282 .profile-hero-avatar-shell .member-profile-avatar {
        width: 88px !important;
        height: 88px !important;
    }
    body.profile-ui-stage6-v282 .profile-hero-avatar-shell {
        margin-top: 0 !important;
    }
    body.profile-ui-stage6-v282 .profile-name-copy h2 {
        font-size: clamp(23px, 7.3vw, 29px) !important;
        line-height: 1.1 !important;
    }
    body.profile-ui-stage6-v282 .member-profile-name {
        align-items: flex-start !important;
        gap: 7px !important;
    }
    body.profile-ui-stage6-v282 .member-bio {
        max-width: none !important;
        margin-block: 8px 12px !important;
    }
    body.profile-ui-stage6-v282 .profile-social-actions,
    body.profile-ui-stage6-v282 .profile-identity-actions {
        width: 100% !important;
    }
    body.profile-ui-stage6-v282 .profile-social-actions {
        display: grid !important;
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 7px !important;
    }
    body.profile-ui-stage6-v282 .profile-identity-actions > .profile-hero-action,
    body.profile-ui-stage6-v282 .profile-identity-actions > .member-owner-link,
    body.profile-ui-stage6-v282 .profile-identity-actions > .member-website-link {
        flex: 1 1 calc(50% - 4px) !important;
        justify-content: center !important;
    }
    body.profile-ui-stage6-v282 .member-stats-inline.profile-stats-social {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 6px !important;
    }
    body.profile-ui-stage6-v282 .member-stats-inline.profile-stats-social > div,
    body.profile-ui-stage6-v282 .member-stats-inline.profile-stats-social > .profile-stat-button {
        min-height: 62px !important;
    }
    body.profile-ui-stage6-v282 .member-stats-inline.profile-stats-social > :last-child:nth-child(odd) {
        grid-column: 1 / -1 !important;
    }
    body.profile-ui-stage6-v282 .member-tabs {
        margin-top: 10px !important;
        padding: 5px !important;
        gap: 4px !important;
        border-radius: 13px !important;
        scroll-snap-type: x proximity !important;
    }
    body.profile-ui-stage6-v282 .member-tabs a {
        min-width: max-content !important;
        padding-inline: 13px !important;
        scroll-snap-align: center !important;
    }
    body.profile-ui-stage6-v282 .profile-member-side-sticky {
        grid-template-columns: minmax(0, 1fr) !important;
    }
    body.profile-ui-stage6-v282 .member-side-card,
    body.profile-ui-stage6-v282 .member-profile-share-card,
    body.profile-ui-stage6-v282 .member-extra-panel,
    body.profile-ui-stage6-v282 .profile-stage9-card {
        border-radius: 14px !important;
    }
    body.profile-ui-stage6-v282 :where(input, select, textarea) {
        font-size: 16px !important;
    }
    body.profile-ui-stage6-v282 .profile-social-feedback {
        width: calc(100vw - 20px) !important;
        max-width: 460px !important;
        bottom: max(12px, calc(env(safe-area-inset-bottom) + 10px)) !important;
    }
}

/* Small phones including 320/360px CSS width. */
@media (max-width: 390px) {
    body.profile-ui-stage6-v282 {
        --profile-s6-gutter: 8px;
    }
    body.profile-ui-stage6-v282 .profile-identity-card {
        padding: 15px 13px !important;
    }
    body.profile-ui-stage6-v282 .profile-hero-avatar-shell,
    body.profile-ui-stage6-v282 .profile-hero-avatar-shell .member-profile-avatar {
        width: 82px !important;
        height: 82px !important;
    }
    body.profile-ui-stage6-v282 .profile-avatar-presence {
        width: 23px !important;
        height: 23px !important;
    }
    body.profile-ui-stage6-v282 .profile-stage9-identity-community {
        gap: 5px !important;
    }
    body.profile-ui-stage6-v282 .profile-stage9-presence,
    body.profile-ui-stage6-v282 .profile-stage9-mini-badge,
    body.profile-ui-stage6-v282 .profile-stage9-more-badges,
    body.profile-ui-stage6-v282 .member-badge {
        font-size: 10px !important;
    }
    body.profile-ui-stage6-v282 .profile-identity-actions {
        display: grid !important;
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    }
    body.profile-ui-stage6-v282 .profile-identity-actions > * {
        width: 100% !important;
        max-width: none !important;
        justify-content: center !important;
    }
    body.profile-ui-stage6-v282 .profile-identity-actions > .member-website-link:only-child,
    body.profile-ui-stage6-v282 .profile-identity-actions > .member-owner-link:only-child {
        grid-column: 1 / -1 !important;
    }
    body.profile-ui-stage6-v282 .member-tabs a {
        padding-inline: 11px !important;
        font-size: 11.5px !important;
    }
    body.profile-ui-stage6-v282 .profile-upload-mobile-card {
        grid-template-columns: 54px minmax(0, 1fr) 30px !important;
        gap: 8px !important;
    }
    body.profile-ui-stage6-v282 .profile-upload-mobile-card > img {
        width: 54px !important;
        height: 54px !important;
    }
}

@media (max-width: 340px) {
    body.profile-ui-stage6-v282 .profile-social-actions,
    body.profile-ui-stage6-v282 .profile-identity-actions {
        grid-template-columns: minmax(0, 1fr) !important;
    }
    body.profile-ui-stage6-v282 .member-stats-inline.profile-stats-social {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    }
    body.profile-ui-stage6-v282 .profile-name-copy h2 {
        font-size: 22px !important;
    }
}

/* Landscape phones: prioritize vertical room and keep modal actions reachable. */
@media (max-height: 560px) and (orientation: landscape) {
    body.profile-ui-stage6-v282 .profile-php-wrap {
        padding-top: 8px !important;
    }
    body.profile-ui-stage6-v282 .profile-identity-card {
        min-height: 0 !important;
    }
    body.profile-ui-stage6-v282 .profile-login-dialog,
    body.profile-ui-stage6-v282 .profile-social-list-dialog {
        max-height: calc(var(--profile-s6-visual-height, 100dvh) - 12px) !important;
    }
}

@media (hover: none) and (pointer: coarse) {
    body.profile-ui-stage6-v282 :where(
        .profile-stat-button,
        .profile-post-card,
        .profile-stage9-contribution-row,
        .profile-stage9-suggestion,
        .profile-social-btn
    ):hover {
        transform: none !important;
    }
}

@media (prefers-reduced-motion: reduce) {
    body.profile-ui-stage6-v282 .member-tabs {
        scroll-behavior: auto !important;
    }
}

@media (forced-colors: active) {
    body.profile-ui-stage6-v282 :where(
        .profile-identity-card,
        .member-tabs,
        .member-list-panel,
        .member-extra-panel,
        .profile-stage9-card,
        .member-side-card
    ) {
        border: 1px solid CanvasText !important;
    }
}

@supports not (height: 100dvh) {
    body.profile-ui-stage6-v282 {
        --profile-s6-visual-height: 100vh;
    }
}

@media (min-width: 1181px) {
    body.profile-ui-stage6-v282 .profile-member-side-sticky.profile-sidebar-static-v282 {
        position: static !important;
        top: auto !important;
    }
}
