
/* ShrineForSouls — shared profile theme extensions.
   Loaded after the page's existing inline CSS. */

/* ADMIN THEME PRESET MANAGER */

#themePreview .pv-avatar {
    background: var(--pv-avatar-bg, var(--pv-accent));
    color: var(--pv-avatar-symbol, var(--pv-bg));
    border: var(--pv-avatar-border-width, 5px) solid
            var(--pv-avatar-border-color, var(--pv-surface));
}

#themePreview .pv-content {
    border-top: var(--pv-divider-width, var(--pv-border-width, 1px)) solid
                var(--pv-divider-color, var(--pv-border));
}

#themePreview .pv-cover {
    height: var(--pv-cover-height, 170px);
}

/* CUSTOMIZE LIVE PREVIEW */

#profilePreview .preview-avatar {
    background-color: var(--sfs-avatar-bg, var(--preview-link-color));
    color: var(--sfs-avatar-symbol, white);
    border: var(--sfs-avatar-border-width, 5px) solid
            var(--sfs-avatar-border-color, white);
}

#profilePreview.layout-classic .content-column {
    border-top: var(--sfs-divider-width, var(--user-border-width)) solid
                var(--sfs-divider-color, var(--user-border-color));
}

#profilePreview.layout-editorial .profile-column,
#profilePreview.layout-sidebar .profile-column {
    border-bottom: var(--sfs-divider-width, var(--user-border-width)) solid
                   var(--sfs-divider-color, var(--user-border-color));
}

#profilePreview.layout-split .profile-column {
    border-right: var(--sfs-divider-width, var(--user-border-width)) solid
                  var(--sfs-divider-color, var(--user-border-color));
}

/* REAL PROFILE */

#profile.profile {
    border: var(--user-border-width, 1px) solid
            var(--user-border-color, #565d48);
}

#profile .profile-avatar {
    background-color: var(--sfs-avatar-bg, var(--accent-color));
    color: var(--sfs-avatar-symbol, white);
    border: var(--sfs-avatar-border-width, 5px) solid
            var(--sfs-avatar-border-color, white);
}

#profile.layout-classic .profile-content {
    border-top: var(--sfs-divider-width, var(--user-border-width)) solid
                var(--sfs-divider-color, var(--user-border-color));
}

#profile.layout-editorial .profile-information,
#profile.layout-sidebar .profile-information {
    border-bottom: var(--sfs-divider-width, var(--user-border-width)) solid
                   var(--sfs-divider-color, var(--user-border-color));
}

#profile.layout-split .profile-information {
    border-right: var(--sfs-divider-width, var(--user-border-width)) solid
                  var(--sfs-divider-color, var(--user-border-color));
}

/* INDEPENDENT COVER HEIGHT */

#profilePreview.layout-classic .preview-cover,
#profile.layout-classic .profile-cover {
    height: var(--sfs-cover-height, 170px);
}

#profilePreview.layout-sidebar .preview-cover,
#profile.layout-sidebar .profile-cover {
    height: var(--sfs-cover-height, 130px);
}

#profilePreview.layout-editorial .preview-cover,
#profile.layout-editorial .profile-cover {
    height: var(--sfs-cover-height, 150px);
}

#profilePreview.layout-split,
#profile.layout-split {
    grid-template-rows: var(--sfs-cover-height, 180px) auto;
}

#profilePreview.layout-split .preview-cover,
#profile.layout-split .profile-cover {
    height: var(--sfs-cover-height, 180px);
    min-height: 0;
}

#profilePreview.layout-split .profile-column,
#profile.layout-split .profile-information {
    padding-top: calc(var(--sfs-cover-height, 180px) + 20px);
    background: var(--surface-color);
}

/* NEW LAYOUT: MINIMAL */

.layout-minimal :is(.preview-cover, .profile-cover) {
    height: var(--sfs-cover-height, 100px);
}

.layout-minimal :is(.profile-column, .profile-information) {
    padding: 18px 28px 25px;
}

.layout-minimal :is(.preview-avatar, .profile-avatar) {
    width: 82px;
    height: 82px;
    margin-top: -42px;
    position: relative;
    z-index: 2;
}

.layout-minimal :is(.content-column, .profile-content) {
    padding: 22px 28px 32px;
    border-top: var(--sfs-divider-width, 1px) solid
                var(--sfs-divider-color, var(--user-border-color));
}

/* NEW LAYOUT: MAGAZINE */

.layout-magazine :is(.preview-cover, .profile-cover) {
    height: var(--sfs-cover-height, 220px);
}

.layout-magazine :is(.profile-column, .profile-information) {
    padding: 0 32px 28px;
}

.layout-magazine :is(.preview-avatar, .profile-avatar) {
    margin-top: -55px;
    position: relative;
    z-index: 2;
}

.layout-magazine :is(.content-column, .profile-content) {
    padding: 26px 32px 35px;
    border-top: var(--sfs-divider-width, 1px) solid
                var(--sfs-divider-color, var(--user-border-color));
}

.layout-magazine :is(.preview-modules, .overview-stack) {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px;
}

.layout-magazine :is(.preview-modules, .overview-stack) > :first-child {
    grid-column: 1 / -1;
}

/* NEW LAYOUT: CENTERED */

.layout-centered-modern :is(.preview-cover, .profile-cover) {
    height: var(--sfs-cover-height, 180px);
}

.layout-centered-modern :is(.profile-column, .profile-information) {
    padding: 0 28px 26px;
    text-align: center;
}

.layout-centered-modern :is(.preview-avatar, .profile-avatar) {
    margin: -55px auto 14px;
    position: relative;
    z-index: 2;
}

.layout-centered-modern :is(
    .preview-stats,
    .profile-stats,
    .preview-actions,
    .visitor-actions,
    .profile-navigation
) {
    justify-content: center;
}

.layout-centered-modern :is(.content-column, .profile-content) {
    padding: 27px 32px 35px;
    border-top: var(--sfs-divider-width, 1px) solid
                var(--sfs-divider-color, var(--user-border-color));
}

/* MOBILE */

@media (max-width: 800px) {
    #profilePreview.layout-split .profile-column,
    #profile.layout-split .profile-information {
        padding-top: 24px;
        border-right: none;
        border-bottom: var(--sfs-divider-width, 1px) solid
                       var(--sfs-divider-color, var(--user-border-color));
    }

    .layout-magazine :is(.preview-modules, .overview-stack) {
        grid-template-columns: minmax(0, 1fr);
    }

    .layout-magazine :is(.preview-modules, .overview-stack) > :first-child {
        grid-column: auto;
    }
}


/* =========================================
   SHRINEFORSOULS — INDEPENDENT CARD TEXT
   Admin Presets / Customize / Profile
========================================= */

/* ADMIN THEME PRESET PREVIEW */

#themePreview .pv-card {
    color: var(
        --pv-card-text,
        var(--pv-text)
    );
}

/* CUSTOMIZE LIVE PREVIEW */

#profilePreview .sample-card {
    color: var(
        --user-card-text-color,
        inherit
    );
}

/* REAL MEMBER PROFILE */

#profile :is(
    .content-card,
    .post-profile-card,
    .story-profile-card,
    .bookmark-collection-card,
    .posts-status-summary
) {
    color: var(
        --user-card-text-color,
        inherit
    );
}


/* =========================================
   THEME 3.7
   OPTIONAL COVER + INDEPENDENT BACKGROUNDS
========================================= */

/* ADMIN PRESET PREVIEW */

#themePreview .pv-information {
    background-color:
        var(--sfs-info-background, var(--pv-surface));
}

#themePreview .pv-content {
    background-color:
        var(--sfs-content-background, var(--pv-surface));
}

/* CUSTOMIZE + REAL PROFILE */

#profilePreview .profile-column,
#profile .profile-information {
    background-color:
        var(--sfs-info-background, var(--surface-color));
}

#profilePreview .content-column,
#profile .profile-content {
    background-color:
        var(--sfs-content-background, var(--surface-color));
}

/* SPLIT: REVEAL THE COVER BEHIND
   THE TOP OF THE INFORMATION COLUMN */

#profilePreview.layout-split .profile-column,
#profile.layout-split .profile-information {
    background: linear-gradient(
        to bottom,
        transparent 0,
        transparent calc(
            var(--sfs-cover-height, 180px) - 20px
        ),
        var(--sfs-info-background, var(--surface-color))
            calc(var(--sfs-cover-height, 180px) - 20px),
        var(--sfs-info-background, var(--surface-color)) 100%
    );
}

/* COMPLETELY HIDE THE COVER */

#themePreview .pv-profile.sfs-cover-hidden .pv-cover,
#profilePreview.sfs-cover-hidden .preview-cover,
#profile.sfs-cover-hidden .profile-cover {
    display: none !important;
}

/* ADMIN PREVIEW WITHOUT COVER */

#themePreview .pv-profile.sfs-cover-hidden .pv-information {
    padding-top: 25px;
}

#themePreview .pv-profile.sfs-cover-hidden .pv-avatar {
    margin-top: 0;
}

/* CLASSIC WITHOUT COVER */

#profilePreview.sfs-cover-hidden.layout-classic .profile-column,
#profile.sfs-cover-hidden.layout-classic .profile-information {
    padding-top: 25px;
}

/* MAGAZINE AND CENTERED WITHOUT COVER */

#profilePreview.sfs-cover-hidden.layout-magazine .profile-column,
#profile.sfs-cover-hidden.layout-magazine .profile-information,
#profilePreview.sfs-cover-hidden.layout-centered-modern .profile-column,
#profile.sfs-cover-hidden.layout-centered-modern .profile-information {
    padding-top: 25px;
}

/* REMOVE NEGATIVE AVATAR OFFSET */

#profilePreview.sfs-cover-hidden .preview-avatar,
#profile.sfs-cover-hidden .profile-avatar {
    margin-top: 0;
}

/* PRESERVE CENTERED AVATAR ALIGNMENT */

#profilePreview.sfs-cover-hidden.layout-centered-modern .preview-avatar,
#profile.sfs-cover-hidden.layout-centered-modern .profile-avatar {
    margin: 0 auto 14px;
}

/* PRESERVE SIDEBAR AVATAR ALIGNMENT */

#profilePreview.sfs-cover-hidden.layout-sidebar .preview-avatar,
#profile.sfs-cover-hidden.layout-sidebar .profile-avatar {
    margin: 0 auto 18px;
}

/* SPLIT WITHOUT COVER:
   REMOVE THE RESERVED 180px ROW */

#profilePreview.sfs-cover-hidden.layout-split,
#profile.sfs-cover-hidden.layout-split {
    grid-template-rows: auto;
}

#profilePreview.sfs-cover-hidden.layout-split .preview-main,
#profile.sfs-cover-hidden.layout-split .profile-main {
    grid-row: 1;
}

#profilePreview.sfs-cover-hidden.layout-split .profile-column,
#profile.sfs-cover-hidden.layout-split .profile-information {
    padding-top: 28px;

    background:
        var(--sfs-info-background, var(--surface-color));
}

/* MOBILE:
   SPLIT IS STACKED, NOT OVERLAPPING */

@media (max-width: 800px) {

    #profilePreview.layout-split .profile-column,
    #profile.layout-split .profile-information {
        background:
            var(--sfs-info-background, var(--surface-color));
    }
}


/* =========================================
   SHRINEFORSOULS — THEME EDITOR ORGANIZATION
   Admin Presets + Customize Advanced
========================================= */

.sfs-editor-area {
    min-width: 0;
    border: 1px solid var(--border-color, #565d48);
    border-radius: 12px;
    padding: 16px;
    margin: 0 0 18px;
}

.sfs-editor-area > h3 {
    font-size: 18px;
    font-weight: normal;
    margin: 0 0 14px;
}

.sfs-editor-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.sfs-editor-field {
    min-width: 0;
}

.sfs-editor-field > label {
    display: block;
    margin: 0 0 7px;
}

.sfs-editor-field .color-pair,
.sfs-editor-field .color-row {
    min-width: 0;
}

.sfs-editor-field input[type="number"] {
    width: 100%;
}

.sfs-editor-subheading {
    grid-column: 1 / -1;
    font-size: 14px;
    margin: 14px 0 2px;
    padding-top: 10px;
    border-top: 1px solid var(--border-color, #565d48);
}

.sfs-editor-wide,
.sfs-editor-area .preset-typography-group {
    grid-column: 1 / -1;
}

/* Customize has a narrower settings panel. */

.sfs-customize-area .sfs-editor-grid {
    grid-template-columns: minmax(0, 1fr);
}

.sfs-customize-area .setting {
    margin-bottom: 4px;
    min-width: 0;
}

.sfs-customize-area .typography-control {
    min-width: 0;
}

@media (max-width: 720px) {
    .sfs-editor-area .sfs-editor-grid {
        grid-template-columns: minmax(0, 1fr);
    }
}


/* =========================================
   THEME 3.8 — LAYOUT REFINEMENTS
========================================= */

/* SECTION TITLE ALIGNMENT */

#profilePreview .preview-module-header .content-title,
#profile .section-heading-row .section-title {
    flex: 1 1 0;
    min-width: 0;
}

/* =========================================
   SIDEBAR — FIT THE AVAILABLE SPACE
========================================= */

#profilePreview.layout-sidebar .preview-main,
#profile.layout-sidebar .profile-main {
    grid-template-columns:
        minmax(180px, var(--sfs-sidebar-width, 230px))
        minmax(0, 1fr);
}

#profilePreview.layout-sidebar .content-column,
#profile.layout-sidebar .profile-content,
#profilePreview.layout-sidebar .sample-card,
#profile.layout-sidebar .content-card {
    min-width: 0;
    max-width: 100%;
}

#profilePreview.layout-sidebar .content-column,
#profile.layout-sidebar .profile-content {
    padding: 14px;
    overflow: hidden;
}

#profilePreview.layout-sidebar .preview-modules,
#profile.layout-sidebar .overview-stack {
    display: flex;
    flex-direction: column;
    gap: 18px;
    min-width: 0;
}

#profilePreview.layout-sidebar .sfs-preview-story-row,
#profile.layout-sidebar .profile-module-list {
    min-width: 0;
    max-width: 100%;
    overflow-x: auto;
}

/* =========================================
   MAGAZINE — CONFIGURABLE COLUMNS
========================================= */

#profilePreview.layout-magazine .preview-modules,
#profile.layout-magazine .overview-stack {
    grid-template-columns:
        repeat(
            var(--sfs-magazine-columns, 2),
            minmax(0, 1fr)
        );
}

/* =========================================
   AVATAR — INDEPENDENT POSITIONING
========================================= */

#profilePreview.sfs-avatar-custom .preview-avatar,
#profile.sfs-avatar-custom .profile-avatar {
    margin-left: var(--sfs-avatar-ml, 0px) !important;
    margin-right: var(--sfs-avatar-mr, auto) !important;
}

#profilePreview .preview-avatar,
#profile .profile-avatar {
    margin-bottom:
        var(--sfs-avatar-gap, 18px) !important;
}

/* With cover: keep the avatar in normal layout flow. */

#profilePreview:not(.sfs-cover-hidden):is(
    .layout-classic,
    .layout-magazine,
    .layout-centered-modern
) .preview-avatar,
#profile:not(.sfs-cover-hidden):is(
    .layout-classic,
    .layout-magazine,
    .layout-centered-modern
) .profile-avatar {
    margin-top:
        calc(-55px + var(--sfs-avatar-top, 0px));
}

#profilePreview:not(.sfs-cover-hidden):is(
    .layout-sidebar,
    .layout-split,
    .layout-editorial
) .preview-avatar,
#profile:not(.sfs-cover-hidden):is(
    .layout-sidebar,
    .layout-split,
    .layout-editorial
) .profile-avatar {
    margin-top: var(--sfs-avatar-top, 0px);
}

/* Without cover: add safe space above the avatar. */

#profilePreview.sfs-cover-hidden:is(
    .layout-classic,
    .layout-sidebar,
    .layout-editorial,
    .layout-magazine,
    .layout-centered-modern
) .profile-column,
#profile.sfs-cover-hidden:is(
    .layout-classic,
    .layout-sidebar,
    .layout-editorial,
    .layout-magazine,
    .layout-centered-modern
) .profile-information {
    padding-top:
        calc(26px + var(--sfs-avatar-top, 0px));
}

#profilePreview.sfs-cover-hidden.layout-split
.profile-column,
#profile.sfs-cover-hidden.layout-split
.profile-information {
    padding-top:
        calc(28px + var(--sfs-avatar-top, 0px));
}

/* ADMIN PRESET PREVIEW */

#themePreview.sfs-avatar-custom .pv-avatar {
    margin-left: var(--sfs-avatar-ml, 0px);
    margin-right: var(--sfs-avatar-mr, auto);
}

#themePreview .pv-avatar {
    margin-bottom: var(--sfs-avatar-gap, 18px);
}

#themePreview .pv-profile:not(.sfs-cover-hidden)
.pv-avatar {
    margin-top:
        calc(-55px + var(--sfs-avatar-top, 0px));
}

#themePreview .pv-profile.sfs-cover-hidden
.pv-information {
    padding-top:
        calc(25px + var(--sfs-avatar-top, 0px));
}

/* =========================================
   CARD METADATA TYPOGRAPHY
========================================= */

#profilePreview .sample-meta,
#profile .post-profile-meta,
#profile .story-profile-meta,
#profile .posts-status-summary {
    font-family: var(--sfs-meta-font, inherit);
    font-size: var(--sfs-meta-size, inherit);
    font-weight: var(--sfs-meta-weight, inherit);
    font-style: var(--sfs-meta-style, inherit);
    text-align: var(--sfs-meta-align, inherit);
}

#profile .post-profile-meta,
#profile .story-profile-meta {
    justify-content:
        var(--sfs-meta-justify, flex-start);
}

/* =========================================
   MOBILE
========================================= */

@media (max-width: 800px) {

    #profilePreview.layout-sidebar .preview-main,
    #profile.layout-sidebar .profile-main {
        grid-template-columns: minmax(0, 1fr);
    }

    #profilePreview.layout-sidebar .content-column,
    #profile.layout-sidebar .profile-content {
        overflow: visible;
    }

    #profilePreview.layout-magazine .preview-modules,
    #profile.layout-magazine .overview-stack {
        grid-template-columns: minmax(0, 1fr);
    }
}


/* =========================================
   THEME 3.9 — AVATAR SIZE
========================================= */

#themePreview .pv-avatar,
#profilePreview .preview-avatar,
#profile .profile-avatar {
    width: var(--sfs-avatar-size, 105px);
    height: var(--sfs-avatar-size, 105px);
    min-width: var(--sfs-avatar-size, 105px);
    flex-shrink: 0;
}


/* =========================================
   MAGAZINE — MATCH ITS LAYOUT ICON

   Profile information on the left.
   Cards and content on the right.
========================================= */

#profilePreview.layout-magazine .preview-main,
#profile.layout-magazine .profile-main {
    display: grid;
    grid-template-columns:
        minmax(190px, 30%)
        minmax(0, 1fr);
    align-items: start;
    gap: 0;
}

#profilePreview.layout-magazine .profile-column,
#profile.layout-magazine .profile-information {
    min-width: 0;
    padding: 25px 22px;
}

#profilePreview.layout-magazine .content-column,
#profile.layout-magazine .profile-content {
    min-width: 0;
    padding: 25px 22px;
    border-top: 0;
}

#profilePreview.layout-magazine .preview-modules,
#profile.layout-magazine .overview-stack {
    min-width: 0;
}


/* =========================================
   ADMIN — PROFILE WIDTH
========================================= */

#themePreview {
    overflow-x: auto;
}

#themePreview .pv-profile {
    width: 100%;
    max-width:
        var(--sfs-admin-profile-max-width, 850px);
    margin-inline: auto;
    min-width: 0;
}


/* =========================================
   ADMIN — SIDEBAR / SPLIT / MAGAZINE
========================================= */

#themePreview .pv-profile:is(
    .sfs-layout-sidebar,
    .sfs-layout-split,
    .sfs-layout-magazine
) {
    display: grid;

    grid-template-columns:
        minmax(
            160px,
            var(--sfs-sidebar-width, 230px)
        )
        minmax(0, 1fr);

    align-items: stretch;
}

#themePreview .pv-profile.sfs-layout-magazine {
    grid-template-columns:
        minmax(180px, 30%)
        minmax(0, 1fr);
}

#themePreview .pv-profile:is(
    .sfs-layout-sidebar,
    .sfs-layout-split,
    .sfs-layout-magazine
) .pv-cover {
    grid-column: 1 / -1;
}

#themePreview .pv-profile:is(
    .sfs-layout-sidebar,
    .sfs-layout-split,
    .sfs-layout-magazine
) .pv-information {
    grid-column: 1;
    min-width: 0;
    padding: 25px 18px;
}

#themePreview .pv-profile:is(
    .sfs-layout-sidebar,
    .sfs-layout-split,
    .sfs-layout-magazine
) .pv-content {
    grid-column: 2;
    min-width: 0;
    padding: 15px;
    border-top: 0;
}

#themePreview .pv-profile:is(
    .sfs-layout-sidebar,
    .sfs-layout-split
) .pv-information {
    border-right:
        var(--pv-divider-width, 1px)
        solid
        var(--pv-divider-color, var(--pv-border));
}

#themePreview .pv-profile:is(
    .sfs-layout-sidebar,
    .sfs-layout-split,
    .sfs-layout-magazine
) .pv-avatar {
    margin-top: 0;
}


/* ADMIN MAGAZINE CARDS */

#themePreview
.pv-profile.sfs-layout-magazine
.pv-content {
    display: grid;

    grid-template-columns:
        repeat(
            var(--sfs-magazine-columns, 2),
            minmax(0, 1fr)
        );

    gap: 10px;
    align-content: start;
}

#themePreview
.pv-profile.sfs-layout-magazine
.pv-card {
    margin-top: 0;
    min-width: 0;
}

#themePreview
.pv-profile.sfs-layout-magazine
.pv-card:first-child {
    grid-column: 1 / -1;
}



/* =========================================
   ADMIN — CENTERED
========================================= */

#themePreview
.pv-profile.sfs-layout-centered-modern
.pv-information {
    text-align: center;
}

#themePreview
.pv-profile.sfs-layout-centered-modern
.pv-avatar {
    margin-left: auto;
    margin-right: auto;
}

#themePreview
.pv-profile.sfs-layout-centered-modern
:is(.pv-actions, .pv-stats) {
    justify-content: center;
}


/* =========================================
   ADMIN — EXPANDED PREVIEW
========================================= */

body.sfs-admin-preview-open {
    overflow: hidden;
}

.preview-panel.sfs-preview-expanded {
    position: fixed;
    inset: 12px;
    z-index: 2000;

    width: auto;
    max-width: none;
    height: calc(100dvh - 24px);

    overflow: auto;
    padding: 22px;

    box-shadow:
        0 20px 70px rgba(0, 0, 0, .75);
}

.preview-panel.sfs-preview-expanded
.preview-stage {
    max-width: 1320px;
    margin-inline: auto;
}

.sfs-preview-expand {
    margin-top: 12px;
}


/* =========================================
   MOBILE
========================================= */

@media (max-width: 800px) {

    #profilePreview.layout-magazine
    .preview-main,

    #profile.layout-magazine
    .profile-main {
        grid-template-columns:
            minmax(0, 1fr);
    }

    #profilePreview.layout-magazine
    .content-column,

    #profile.layout-magazine
    .profile-content {
        border-top:
            var(--sfs-divider-width, 1px)
            solid
            var(
                --sfs-divider-color,
                var(--user-border-color)
            );
    }

    #themePreview .pv-profile:is(
        .sfs-layout-sidebar,
        .sfs-layout-split,
        .sfs-layout-magazine
    ) {
        grid-template-columns:
            minmax(0, 1fr);
    }

    #themePreview .pv-profile:is(
        .sfs-layout-sidebar,
        .sfs-layout-split,
        .sfs-layout-magazine
    ) :is(.pv-information, .pv-content) {
        grid-column: 1;
    }

    #themePreview
    .pv-profile.sfs-layout-magazine
    .pv-content {
        grid-template-columns:
            minmax(0, 1fr);
    }
}


/* =========================================
   EDITORIAL — CUSTOMIZE PREVIEW ONLY
   Avatar placement and alignment
========================================= */

#profilePreview.layout-editorial {
    container-type: inline-size;
}

/* Preview buttons: visible in every profile layout */

#profilePreview .sfs-editorial-demo-actions {
    display: flex !important;
    flex-wrap: wrap;
    gap: 8px;
}

/* =========================================
   EDITORIAL — DEFAULT AVATAR LEFT
========================================= */

#profilePreview.layout-editorial .profile-column {
    display: grid;

    grid-template-columns:
        var(--sfs-avatar-size, 105px)
        minmax(0, 1fr);

    grid-auto-rows: min-content;
    column-gap: 24px;
    align-items: start;

    min-width: 0;
    padding-top: 26px;
    padding-bottom:
        calc(24px + var(--sfs-avatar-gap, 18px));
}

/* Editorial: keep information stationary
   when the cover is hidden. */

#profilePreview.sfs-cover-hidden.layout-editorial
.profile-column {
    padding-top: 26px;
}

#profilePreview.layout-editorial
.profile-column > .preview-avatar {
    grid-column: 1;
    grid-row: 1 / span 6;

    justify-self: start;
    align-self: start;

    margin:
        var(--sfs-avatar-top, 0px)
        0
        0 !important;

    transform:
        translateX(
            var(--sfs-editorial-avatar-x, 0px)
        );
}

/* All text stays in its own column */

#profilePreview.layout-editorial
.profile-column > :not(.preview-avatar) {
    grid-column: 2;
    min-width: 0;
}

/* Joined date has independent alignment */

#profilePreview.layout-editorial
.profile-column > .preview-joined {
    width: 100%;

    text-align:
        var(--sfs-editorial-joined-align, left);
}

/* =========================================
   EDITORIAL — AVATAR RIGHT
========================================= */

#profilePreview.layout-editorial[data-editorial-avatar-position="right"]
.profile-column {
    grid-template-columns:
        minmax(0, 1fr)
        var(--sfs-avatar-size, 105px);
}

#profilePreview.layout-editorial[data-editorial-avatar-position="right"]
.profile-column > .preview-avatar {
    grid-column: 2;
    justify-self: end;
}

#profilePreview.layout-editorial[data-editorial-avatar-position="right"]
.profile-column > :not(.preview-avatar) {
    grid-column: 1;
}

/* =========================================
   EDITORIAL — AVATAR CENTER
========================================= */

#profilePreview.layout-editorial[data-editorial-avatar-position="center"]
.profile-column {
    grid-template-columns: minmax(0, 1fr);
    padding-bottom: 24px;
}

#profilePreview.layout-editorial[data-editorial-avatar-position="center"]
.profile-column > .preview-avatar {
    grid-column: 1;
    grid-row: auto;

    justify-self: center;

    margin-left: auto !important;
    margin-right: auto !important;

    margin-bottom:
        var(--sfs-avatar-gap, 18px) !important;
}

#profilePreview.layout-editorial[data-editorial-avatar-position="center"]
.profile-column > :not(.preview-avatar) {
    grid-column: 1;
}

/* =========================================
   EDITORIAL — CONTENT CARDS
========================================= */

#profilePreview.layout-editorial .preview-modules {
    display: grid;

    grid-template-columns:
        repeat(2, minmax(0, 1fr));

    gap: 18px;
    min-width: 0;
}

#profilePreview.layout-editorial
.preview-modules > .sample-card {
    min-width: 0;
    max-width: 100%;
    margin-bottom: 0;
}

/* Posts spans both columns */

#profilePreview.layout-editorial
.preview-modules > .sample-card:first-child {
    grid-column: 1 / -1;
}

/* Stories cannot stretch the grid */

#profilePreview.layout-editorial
.sfs-preview-story-row {
    min-width: 0;
    max-width: 100%;
    overflow-x: auto;
}

/* =========================================
   EDITORIAL — NARROW PROFILE
========================================= */

@container (max-width: 560px) {

    #profilePreview.layout-editorial .profile-column,
    #profilePreview.layout-editorial
    [data-editorial-avatar-position="right"]
    .profile-column {
        grid-template-columns: minmax(0, 1fr);
        padding-bottom: 24px;
    }

    #profilePreview.layout-editorial
    .profile-column > .preview-avatar,

    #profilePreview.layout-editorial
    [data-editorial-avatar-position="right"]
    .profile-column > .preview-avatar {
        grid-column: 1;
        grid-row: 1;

        justify-self: start;

        margin-bottom:
            var(--sfs-avatar-gap, 18px) !important;
    }

    #profilePreview.layout-editorial
    .profile-column > :not(.preview-avatar),

    #profilePreview.layout-editorial
    [data-editorial-avatar-position="right"]
    .profile-column > :not(.preview-avatar) {
        grid-column: 1;
    }

    #profilePreview.layout-editorial
    [data-editorial-avatar-position="right"]
    .profile-column > .preview-avatar {
        justify-self: end;
    }

    #profilePreview.layout-editorial
    [data-editorial-avatar-position="center"]
    .profile-column > .preview-avatar {
        justify-self: center;
    }

    #profilePreview.layout-editorial .preview-modules {
        display: flex;
        flex-direction: column;
    }
}

/* =========================================
   EDITORIAL — REAL PROFILE GRID
   Match Customize's equal-width columns
========================================= */

#profile.layout-editorial .overview-stack {
    grid-template-columns:
        repeat(2, minmax(0, 1fr));
}

/* Do not let Stories force Bookmarks
   into a tiny column. */

#profile.layout-editorial
.overview-stack > .content-card {
    min-width: 0;
    max-width: 100%;
}

#profile.layout-editorial .profile-module-list,
#profile.layout-editorial .bookmark-collection-list,
#profile.layout-editorial .bookmark-collection-card {
    min-width: 0;
    max-width: 100%;
}


/* =========================================
   EDITORIAL — AVATAR POSITION
========================================= */

/* Preserve the saved horizontal offset. */

#profile.layout-editorial
.profile-information > .profile-avatar {
    transform:
        translateX(
            var(--sfs-editorial-avatar-x, 0px)
        );
}

/* Desktop: normal and right-aligned grids. */

@media (min-width: 801px) {

    #profile.layout-editorial .profile-information {
        grid-template-columns:
            var(--sfs-avatar-size, 105px)
            minmax(0, 1fr);
    }

    #profile.layout-editorial
    [data-editorial-avatar-position="right"] {
        min-width: 0;
    }

    #profile.layout-editorial[data-editorial-avatar-position="right"]
    .profile-information {
        grid-template-columns:
            minmax(0, 1fr)
            var(--sfs-avatar-size, 105px);
    }

    #profile.layout-editorial[data-editorial-avatar-position="right"]
    .profile-information > .profile-avatar {
        grid-column: 2;
        justify-self: end;
    }

    #profile.layout-editorial[data-editorial-avatar-position="right"]
    .profile-information > :not(.profile-avatar) {
        grid-column: 1;
    }

}

/* Center means centered within the
   entire profile information area,
   not merely the first grid column. */

#profile.layout-editorial[data-editorial-avatar-position="center"]
.profile-information {
    grid-template-columns: minmax(0, 1fr);
}

#profile.layout-editorial[data-editorial-avatar-position="center"]
.profile-information > .profile-avatar {
    grid-column: 1;
    grid-row: auto;

    justify-self: center;

    margin-left: auto !important;
    margin-right: auto !important;
}

#profile.layout-editorial[data-editorial-avatar-position="center"]
.profile-information > :not(.profile-avatar) {
    grid-column: 1;
}

#profile.layout-editorial .profile-joined {
    text-align:
        var(--sfs-editorial-joined-align, left);
}

/* Preserve responsive single-column behavior. */

@media (max-width: 800px) {

    #profile.layout-editorial[data-editorial-avatar-position="right"]
    .profile-information > .profile-avatar {
        grid-column: 1;
        justify-self: end;
    }

}


/* =========================================
   JOURNAL RAIL — AVATAR POSITION
========================================= */

/* Restore the horizontal offset. */

#profile.layout-journal-rail
.profile-information > .profile-avatar {
    transform:
        translateX(
            var(--sfs-editorial-avatar-x, 0px)
        );
}

/* Right alignment in the two-column layout. */

@container (min-width: 651px) {

    #profile.layout-journal-rail[data-editorial-avatar-position="right"]
    .profile-main:has(.overview-stack)
    > .profile-information {
        grid-template-columns:
            minmax(0, 1fr)
            var(--sfs-avatar-size, 105px);
    }

    #profile.layout-journal-rail[data-editorial-avatar-position="right"]
    .profile-information > .profile-avatar {
        grid-column: 2;
        justify-self: end;
    }

    #profile.layout-journal-rail[data-editorial-avatar-position="right"]
    .profile-information > :not(.profile-avatar) {
        grid-column: 1;
    }

}

/* Center alignment uses the full
   width of the information card. */

#profile.layout-journal-rail[data-editorial-avatar-position="center"]
.profile-main:has(.overview-stack)
> .profile-information {
    grid-template-columns: minmax(0, 1fr);
}

#profile.layout-journal-rail[data-editorial-avatar-position="center"]
.profile-information > .profile-avatar {
    grid-column: 1;
    grid-row: auto;

    justify-self: center;

    margin-left: auto !important;
    margin-right: auto !important;

    margin-bottom:
        var(--sfs-avatar-gap, 18px) !important;
}

#profile.layout-journal-rail[data-editorial-avatar-position="center"]
.profile-information > :not(.profile-avatar) {
    grid-column: 1;
}

#profile.layout-journal-rail .profile-joined {
    text-align:
        var(--sfs-editorial-joined-align, left);
}

/* =========================================
   BOOKMARKS — VERTICAL COLLECTIONS
   Single scrollbar for the whole module
========================================= */

#profile:is(
    .layout-classic,
    .layout-editorial,
    .layout-split,
    .layout-journal-rail
)
.overview-stack > .content-card:nth-child(3) {
    min-width: 0;
    overflow: hidden;
}

#profile:is(
    .layout-classic,
    .layout-editorial,
    .layout-split,
    .layout-journal-rail
)
.bookmark-collection-list {
    display: flex;
    flex-direction: column;

    gap: 12px;

    min-width: 0;
    min-height: 0;

    max-height: min(68vh, 700px);

    overflow-x: hidden;
    overflow-y: auto;

    padding: 4px 6px 10px 0;

    scrollbar-width: thin;

    scrollbar-color:
        var(--theme-scrollbar-thumb, #929982)
        var(--theme-scrollbar-track, #1f231a);
}

#profile:is(
    .layout-classic,
    .layout-editorial,
    .layout-split,
    .layout-journal-rail
)
.bookmark-collection-card {
    display: flex;
    flex: 0 0 auto;
    flex-direction: column;

    align-items: stretch;

    gap: 10px;

    min-width: 0;
    width: 100%;

    padding: 12px;
}

/* =========================================
   CLASSIC / EDITORIAL / SPLIT
   Horizontal scrolling inside each collection
========================================= */

#profile:is(
    .layout-classic,
    .layout-editorial,
    .layout-split
)
.bookmark-collection-items {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;

    gap: 10px;

    width: 100%;
    min-width: 0;

    flex: 0 0 auto;

    overflow-x: auto;
    overflow-y: hidden;

    padding: 10px 0;

    scrollbar-width: thin;

    scrollbar-color:
        var(--theme-scrollbar-thumb, #929982)
        var(--theme-scrollbar-track, #1f231a);
}

/* Individual Story tiles */

#profile:is(
    .layout-classic,
    .layout-editorial,
    .layout-split
)
.bookmark-story-item {
    display: flex;
    flex: 0 0 88px;
    flex-direction: column;

    width: 88px;
    min-width: 88px;
    max-width: 88px;

    gap: 6px;
    padding: 4px;
}

/* Real covers */

#profile:is(
    .layout-classic,
    .layout-editorial,
    .layout-split
)
.bookmark-story-cover {
    position: relative;
    display: block;

    width: 100%;
    aspect-ratio: 2 / 3;

    overflow: hidden;
    border-radius: 6px;
}

#profile:is(
    .layout-classic,
    .layout-editorial,
    .layout-split
)
.bookmark-story-cover img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

#profile:is(
    .layout-classic,
    .layout-editorial,
    .layout-split
)
.bookmark-story-information {
    min-width: 0;
    max-width: 100%;

    overflow-wrap: anywhere;
    font-size: 11px;
}

/* =========================================
   JOURNAL RAIL — PROFILE LAYOUT
========================================= */

#profile.layout-journal-rail {
    container-type: inline-size;
    padding: 20px;
}

#profile.layout-journal-rail .profile-cover {
    display: block;

    height: var(--sfs-cover-height, 150px);

    margin-bottom: 16px;

    border-radius: 11px;
}

#profile.layout-journal-rail
.profile-main:has(.overview-stack) {
    display: grid;

    grid-template-columns:
        minmax(0, 1fr)
        minmax(245px, 36%);

    grid-template-areas:
        "identity bookmarks"
        "posts bookmarks"
        "stories bookmarks";

    gap: 16px;

    align-items: stretch;
    min-width: 0;
}

/* Promote the existing overview cards into the grid. */

#profile.layout-journal-rail
.profile-main:has(.overview-stack) > .profile-content,

#profile.layout-journal-rail
.profile-main:has(.overview-stack) #profileTabContent,

#profile.layout-journal-rail
.profile-main:has(.overview-stack) .overview-stack {
    display: contents;
}

/* Identity */

#profile.layout-journal-rail
.profile-main:has(.overview-stack) > .profile-information {
    grid-area: identity;

    display: grid;

    grid-template-columns:
        var(--sfs-avatar-size, 105px)
        minmax(0, 1fr);

    grid-auto-rows: min-content;

    column-gap: 18px;

    min-width: 0;
    padding: 18px;

    border:
        var(--user-border-width, 1px)
        solid
        var(--user-border-color, #565d48);

    border-radius: 11px;

    background:
        var(--sfs-info-background, var(--surface-color));
}

#profile.layout-journal-rail
.profile-information > .profile-avatar {
    grid-column: 1;
    grid-row: 1 / span 7;

    margin-top:
        var(--sfs-avatar-top, 0px) !important;
}

#profile.layout-journal-rail
.profile-information > :not(.profile-avatar) {
    grid-column: 2;
    min-width: 0;
}

/* Overview cards */

#profile.layout-journal-rail
.overview-stack > .content-card {
    min-width: 0;
    width: 100%;
    margin: 0;
}

#profile.layout-journal-rail
.overview-stack > .content-card:nth-child(1) {
    grid-area: posts;
}

#profile.layout-journal-rail
.overview-stack > .content-card:nth-child(2) {
    grid-area: stories;
}

/* Bookmarks fills the right-hand rail. */

#profile.layout-journal-rail
.overview-stack > .content-card:nth-child(3) {
    grid-area: bookmarks;

    display: flex;
    flex-direction: column;

    align-self: stretch;

    height: 100%;

    min-height: 0;
    min-width: 0;
    max-height: none;

    overflow: hidden;
}

/* One vertical collection scroller */

#profile.layout-journal-rail
.bookmark-collection-list {
    flex: 1 1 0;

    height: 0;
    min-height: 0;

    max-height: none;
}

/* Story previews — 2 columns */

#profile.layout-journal-rail
.bookmark-collection-items {
    display: grid;
    grid-template-columns:
        repeat(2, minmax(0, 1fr));

    gap: 8px;

    flex: 0 0 auto;

    width: 100%;
    min-width: 0;
    max-width: 100%;

    padding: 10px 0 0;

    overflow: visible;
}

#profile.layout-journal-rail
.bookmark-story-item {
    display: flex;
    flex-direction: column;
    align-items: stretch;

    width: 100%;
    min-width: 0;
    max-width: 100%;

    gap: 6px;
    padding: 4px;

    overflow-wrap: anywhere;
}

/* Stable portrait-shaped bookmark covers. */

#profile.layout-journal-rail .bookmark-story-cover,
#profile:is(
    .layout-classic,
    .layout-editorial,
    .layout-split
)
.bookmark-story-cover {
    position: relative;

    display: flex;
    flex: 0 0 auto;

    align-items: center;
    justify-content: center;

    width: 100%;
    min-width: 0;

    aspect-ratio: 2 / 3;

    overflow: hidden;
}

/* Journal Rail — smaller, centered covers. */

#profile.layout-journal-rail
.bookmark-story-cover {
    width: min(100%, 72px);
    margin-inline: auto;
}

/* Real cover images cannot stretch their cards. */

#profile:is(
    .layout-classic,
    .layout-editorial,
    .layout-split,
    .layout-journal-rail
)
.bookmark-story-cover img {
    position: absolute;
    inset: 0;

    display: block;

    width: 100%;
    height: 100%;
    max-width: 100%;

    object-fit: cover;
}

#profile.layout-journal-rail
.bookmark-story-information {
    min-width: 0;
    max-width: 100%;

    overflow-wrap: anywhere;
    font-size: 11px;
}

#profile.layout-journal-rail
:is(
    .bookmark-story-title,
    .bookmark-story-author
) {
    display: block;
    max-width: 100%;

    overflow-wrap: anywhere;
}

/* =========================================
   SHARED COLLECTION CARDS
========================================= */

#profile .bookmark-collection-identity {
    min-width: 0;
    max-width: 100%;
}

#profile .bookmark-collection-name {
    overflow-wrap: anywhere;
}

#profile .bookmark-collection-actions {
    display: flex;
    flex-wrap: wrap;

    gap: 6px;

    min-width: 0;
    max-width: 100%;
}

#profile .bookmark-action-button {
    white-space: normal;
    overflow-wrap: anywhere;
}

#profile .sfs-bookmark-story-count {
    margin: 0;

    font-size: 11px;
    opacity: 0.7;
}

#profile .sfs-bookmark-see-all {
    align-self: flex-start;

    margin-top: auto;
    padding: 5px 0;

    border: 0;
    background: transparent;

    color: var(--accent-color);

    font: inherit;
    font-size: 12px;

    text-decoration: underline;
    cursor: pointer;
}

/* =========================================
   SEE ALL — COLLECTION DIALOG
========================================= */

.sfs-bookmark-dialog {
    width: min(740px, calc(100vw - 30px));

    max-height: 85vh;
    padding: 20px;

    overflow-y: auto;

    color: var(--user-card-text-color, #e9e8df);

    background:
        var(--surface-color, #272c21);

    border: 1px solid
        var(--user-border-color, #565d48);

    border-radius: 12px;

    box-shadow:
        0 20px 55px rgba(0, 0, 0, 0.4);
}

.sfs-bookmark-dialog::backdrop {
    background: rgba(0, 0, 0, 0.72);
}

.sfs-bookmark-dialog-header {
    display: flex;
    justify-content: space-between;
    align-items: center;

    flex-wrap: wrap;
    gap: 12px;

    margin-bottom: 20px;
}

.sfs-bookmark-dialog-header h2 {
    margin: 0;
    font-size: 22px;
}

.sfs-bookmark-dialog-close {
    border: 1px solid
        var(--user-border-color, #565d48);

    border-radius: 8px;
    padding: 8px 14px;

    background: transparent;
    color: inherit;

    font: inherit;
    cursor: pointer;
}

.sfs-bookmark-dialog-content {
    display: grid;
    grid-template-columns:
        repeat(auto-fit, minmax(min(100%, 230px), 1fr));

    gap: 12px;
}

.sfs-bookmark-dialog-content .bookmark-story-item {
    display: grid;
    grid-template-columns:
        56px minmax(0, 1fr);

    min-width: 0;
    max-width: 100%;
    width: 100%;

    padding: 10px;
}

.sfs-bookmark-dialog-content .bookmark-story-cover {
    width: 56px;
    height: auto;
    aspect-ratio: 2 / 3;
}

/* =========================================
   JOURNAL RAIL — RESPONSIVE
========================================= */

@container (max-width: 650px) {

    #profile.layout-journal-rail
    .profile-main:has(.overview-stack) {
        grid-template-columns: minmax(0, 1fr);

        grid-template-areas:
            "identity"
            "posts"
            "stories"
            "bookmarks";
    }

    #profile.layout-journal-rail
    .overview-stack > .content-card:nth-child(3) {
        height: auto;
        max-height: none;
    }

    #profile.layout-journal-rail
    .bookmark-collection-list {
        flex: 0 1 auto;

        height: auto;
        max-height: min(60vh, 520px);
    }

    #profile.layout-journal-rail
    .profile-main:has(.overview-stack)
    > .profile-information {
        grid-template-columns: minmax(0, 1fr);
    }

    #profile.layout-journal-rail
    .profile-information > .profile-avatar {
        grid-column: 1;
        grid-row: auto;
    }

    #profile.layout-journal-rail
    .profile-information > :not(.profile-avatar) {
        grid-column: 1;
    }
}

/* =========================================
   SEE ALL — PRESERVE DIALOG CARD LAYOUT
========================================= */

#profile
.sfs-bookmark-dialog-content
.bookmark-story-item {
    display: grid;

    grid-template-columns:
        56px minmax(0, 1fr);

    flex: initial;

    width: 100%;
    min-width: 0;

    padding: 10px;
}

#profile
.sfs-bookmark-dialog-content
.bookmark-story-cover {
    width: 56px;
    height: auto;

    aspect-ratio: 2 / 3;
}

/* =========================================
   AVATAR SHAPES
   Round / Square / Heart
========================================= */

/* Round is the existing default. */

/* =========================================
   SQUARE
========================================= */

#profilePreview[data-avatar-shape="square"]
.preview-avatar,

#profile[data-avatar-shape="square"]
.profile-avatar {
    border-radius: 12px;
    clip-path: none;
}

/* =========================================
   HEART
========================================= */

#profilePreview[data-avatar-shape="heart"]
.preview-avatar,

#profile[data-avatar-shape="heart"]
.profile-avatar {
    --sfs-heart-shape: polygon(
        50% 94%,
        43% 88%,
        29% 75%,
        15% 61%,
        7% 50%,
        3% 40%,
        3% 29%,
        7% 20%,
        15% 13%,
        26% 10%,
        38% 14%,
        50% 25%,
        62% 14%,
        74% 10%,
        85% 13%,
        93% 20%,
        97% 29%,
        97% 40%,
        93% 50%,
        85% 61%,
        71% 75%,
        57% 88%
    );

    position: relative;
    isolation: isolate;
    overflow: hidden;

    border: 0 !important;
    border-radius: 0;

    background:
        var(--sfs-avatar-border-color, #ffffff);

    clip-path: var(--sfs-heart-shape);
}

#profilePreview[data-avatar-shape="heart"]
.preview-avatar::before,

#profile[data-avatar-shape="heart"]
.profile-avatar::before {
    content: "";

    position: absolute;
    inset: var(--sfs-avatar-border-width, 5px);

    background:
        var(--sfs-avatar-bg, var(--accent-color));

    clip-path: var(--sfs-heart-shape);
    z-index: 0;
}

#profilePreview[data-avatar-shape="heart"]
.preview-avatar > *,

#profile[data-avatar-shape="heart"]
.profile-avatar > * {
    position: relative;
    z-index: 1;
}

#profilePreview[data-avatar-shape="heart"]
.preview-avatar img,

#profile[data-avatar-shape="heart"]
.profile-avatar img {
    position: absolute;
    inset: var(--sfs-avatar-border-width, 5px);

    display: block;
    width: auto;
    height: auto;
    max-width: none;
    max-height: none;

    object-fit: cover;
    clip-path: var(--sfs-heart-shape);
    z-index: 1;
}

#profilePreview[data-avatar-shape="heart"]
#previewAvatarPlaceholder,

#profile[data-avatar-shape="heart"]
#profileAvatarPlaceholder {
    z-index: 2;
}

/* =========================================
   ADVANCED — AVATAR SHAPE CHOICES
========================================= */

body[data-customize-mode="advanced"]
#avatarShape {
    display: block;

    width: 100%;
    min-height: 116px;

    padding: 5px;

    background:
        var(--site-background, #1f231a);

    color:
        var(--text-color, #e9e8df);

    border: 1px solid
        var(--border-color, #565d48);

    border-radius: 8px;

    font: inherit;
}

#avatarShape option {
    padding: 9px;
}

/* =========================================
   EDITORIAL — VERTICAL STORY PREVIEWS
   Desktop only
========================================= */

@media (min-width: 801px) {

    /* Vertical scrolling inside Stories */

    #profile.layout-editorial
    .overview-stack > .content-card:nth-child(2)
    .profile-module-list {
        display: flex;
        flex-direction: column;
        flex-wrap: nowrap;

        align-items: stretch;

        gap: 15px;

        min-width: 0;
        max-width: 100%;

        max-height: 560px;

        overflow-x: hidden;
        overflow-y: auto;

        padding: 4px 8px 12px 2px;

        scroll-snap-type: none;

        scrollbar-width: thin;
        scrollbar-color:
            var(--theme-scrollbar-thumb, #929982)
            var(--theme-scrollbar-track, #1f231a);
    }

    /* Each Story gets its own complete row */

    #profile.layout-editorial
    .overview-stack > .content-card:nth-child(2)
    .story-profile-card {
        display: grid;

        grid-template-columns:
            112px minmax(0, 1fr);

        gap: 16px;

        width: 100%;
        min-width: 0;
        max-width: 100%;

        height: auto;
        min-height: 0;

        flex: 0 0 auto;

        align-items: center;

        scroll-snap-align: none;
    }

    /* Preserve the current Editorial cover size */

    #profile.layout-editorial
    .overview-stack > .content-card:nth-child(2)
    .story-profile-cover {
        width: 112px;
        aspect-ratio: 2 / 3;

        align-self: center;
    }

    /* Summary and link stay beside the cover */

    #profile.layout-editorial
    .overview-stack > .content-card:nth-child(2)
    .story-profile-main {
        display: flex;
        flex-direction: column;

        min-width: 0;
        gap: 10px;
    }

    #profile.layout-editorial
    .overview-stack > .content-card:nth-child(2)
    .story-profile-summary {
        margin: 0;
        line-height: 1.6;

        overflow-wrap: anywhere;
    }

    #profile.layout-editorial
    .overview-stack > .content-card:nth-child(2)
    .post-profile-actions {
        margin-top: 4px;
    }
}

/* =========================================
   EDITORIAL — CUSTOMIZE PREVIEW
========================================= */

/* Extra demo details are hidden in other layouts. */

#profilePreview:not(.layout-editorial)
:is(
    .sfs-preview-story-cover,
    .sfs-preview-story-summary,
    .sfs-preview-story-link
) {
    display: none;
}

/* Apply only when the preview has enough width
   for a desktop Editorial layout. */

@container (min-width: 561px) {

    #profilePreview.layout-editorial
    .sfs-preview-story-row {
        display: flex;
        flex-direction: column;

        align-items: stretch;

        gap: 14px;

        min-width: 0;
        max-width: 100%;

        max-height: 520px;

        overflow-x: hidden;
        overflow-y: auto;

        padding: 4px 8px 12px 2px;

        scrollbar-width: thin;

        scrollbar-color:
            var(--theme-scrollbar-thumb, #929982)
            var(--theme-scrollbar-track, #1f231a);
    }

    #profilePreview.layout-editorial
    .sfs-preview-story-item {
        display: grid;

        grid-template-columns:
            112px minmax(0, 1fr);

        gap: 14px;

        flex: 0 0 auto;

        width: 100%;
        min-width: 0;
        max-width: 100%;

        height: auto;
        min-height: 0;

        box-sizing: border-box;

        align-items: center;
    }

    #profilePreview.layout-editorial
    .sfs-preview-story-cover {
        display: block;

        width: 112px;
        aspect-ratio: 2 / 3;

        border-radius: 7px;

        background: linear-gradient(
            145deg,
            var(--cover-color-1, #565d48),
            var(--cover-color-2, #25291f)
        );
    }

    #profilePreview.layout-editorial
    .sfs-preview-story-copy {
        min-width: 0;
    }

    #profilePreview.layout-editorial
    .sfs-preview-story-summary {
        display: block;
        margin-top: 10px;
        line-height: 1.55;
    }

    #profilePreview.layout-editorial
    .sfs-preview-story-link {
        display: inline-block;

        margin-top: 12px;

        color: var(--preview-link-color, #929982);

        font-size: 12px;
        font-weight: bold;
    }
}
/* =========================================
   EDITORIAL — MATCHED STORIES / BOOKMARKS
   Desktop layout refinements
========================================= */

@media (min-width: 801px) {

    /* Preserve two equal, flexible columns. */

    #profile.layout-editorial .overview-stack {
        display: grid;
        grid-template-columns:
            repeat(2, minmax(0, 1fr));
        gap: 18px;
        align-items: stretch;
    }

    /* Stories and Bookmarks have identical
       outer heights, regardless of content. */

    #profile.layout-editorial
    .overview-stack > .content-card:nth-child(2),

    #profile.layout-editorial
    .overview-stack > .content-card:nth-child(3) {
        display: flex;
        flex-direction: column;

        box-sizing: border-box;

        min-width: 0;
        min-height: 0;

        height: clamp(390px, 58vh, 610px);

        overflow: hidden;
    }

    /* Each module scrolls inside its own card. */

    #profile.layout-editorial
    .overview-stack > .content-card:nth-child(2)
    .profile-module-list,

    #profile.layout-editorial
    .overview-stack > .content-card:nth-child(3)
    .bookmark-collection-list {
        flex: 1 1 0;

        min-width: 0;
        min-height: 0;

        height: auto;
        max-height: none;

        overflow-x: hidden;
        overflow-y: auto;

        overscroll-behavior: contain;
        scrollbar-width: thin;
    }

    /* Every Story remains a horizontal
       cover + information card. */

    #profile.layout-editorial
    .overview-stack > .content-card:nth-child(2)
    .story-profile-card {
        display: grid;

        grid-template-columns:
            clamp(76px, 33%, 112px)
            minmax(0, 1fr);

        gap: 14px;

        width: 100%;
        max-width: 100%;

        min-width: 0;
        min-height: 0;

        height: auto;

        align-items: start;
        flex: 0 0 auto;
    }

    #profile.layout-editorial
    .overview-stack > .content-card:nth-child(2)
    .story-profile-cover {
        width: 100%;
        max-width: 112px;

        aspect-ratio: 2 / 3;

        align-self: start;
    }

    #profile.layout-editorial
    .story-profile-main {
        min-width: 0;
        overflow-wrap: anywhere;
    }

    /* Long Story titles must not push
       the Published badge outside the card. */

    #profile.layout-editorial
    .story-profile-card
    .post-profile-card-top {
        display: flex;
        flex-direction: column;

        align-items: stretch;
        gap: 7px;

        min-width: 0;
    }

    #profile.layout-editorial
    .story-profile-card
    .post-status-badge {
        order: -1;

        align-self: flex-end;
        flex-shrink: 0;

        max-width: 100%;
        white-space: nowrap;
    }

    #profile.layout-editorial
    .story-profile-card
    .story-profile-title {
        margin: 0;

        min-width: 0;
        max-width: 100%;

        overflow-wrap: anywhere;
        word-break: normal;
    }

    #profile.layout-editorial
    .story-profile-card
    .story-profile-title-link {
        overflow-wrap: anywhere;
    }

}

/* =========================================
   EDITORIAL — CUSTOMIZE PREVIEW PARITY
========================================= */

@container (min-width: 561px) {

    /* Same two-column arrangement as
       the real Editorial profile. */

    #profilePreview.layout-editorial
    .preview-modules {
        display: grid;

        grid-template-columns:
            repeat(2, minmax(0, 1fr));

        gap: 18px;
        align-items: stretch;
    }

    /* Match the outer panel heights. */

    #profilePreview.layout-editorial
    .preview-modules > .sample-card:nth-child(2),

    #profilePreview.layout-editorial
    .preview-modules > .sample-card:nth-child(3) {
        display: flex;
        flex-direction: column;

        box-sizing: border-box;

        min-width: 0;
        min-height: 0;

        height: clamp(390px, 58vh, 610px);

        overflow: hidden;
    }

    /* Stories and Bookmarks scroll
       independently inside equal panels. */

    #profilePreview.layout-editorial
    .sfs-preview-story-row,

    #profilePreview.layout-editorial
    .sfs-bookmark-demo-list {
        flex: 1 1 0;

        min-width: 0;
        min-height: 0;

        height: auto;
        max-height: none;

        overflow-x: hidden;
        overflow-y: auto;

        overscroll-behavior: contain;
        scrollbar-width: thin;
    }

    /* Match the real Story card proportions. */

    #profilePreview.layout-editorial
    .sfs-preview-story-item {
        display: grid;

        grid-template-columns:
            clamp(76px, 33%, 112px)
            minmax(0, 1fr);

        align-items: start;

        gap: 14px;

        width: 100%;
        min-width: 0;
        max-width: 100%;

        height: auto;
        min-height: 0;

        flex: 0 0 auto;
    }

    #profilePreview.layout-editorial
    .sfs-preview-story-cover {
        display: block;

        width: 100%;
        max-width: 112px;

        aspect-ratio: 2 / 3;
    }

    /* Same Published badge position
       as the real profile. */

    #profilePreview.layout-editorial
    .sfs-preview-story-copy {
        display: flex;
        flex-direction: column;

        align-items: stretch;

        gap: 7px;
        min-width: 0;
    }

    #profilePreview.layout-editorial
    .sfs-preview-story-copy .sample-meta {
        order: -1;

        align-self: flex-end;

        margin: 0;
        padding: 4px 8px;

        max-width: 100%;

        border: 1px solid
            var(--preview-link-color, #929982);

        border-radius: 999px;

        font-size: 9px;
        font-weight: bold;
        white-space: nowrap;
        text-transform: uppercase;
    }

    #profilePreview.layout-editorial
    .sfs-preview-story-copy h3 {
        margin: 0;

        min-width: 0;
        overflow-wrap: anywhere;
    }

    #profilePreview.layout-editorial
    .sfs-preview-story-summary {
        margin: 0;
        overflow-wrap: anywhere;
        line-height: 1.6;
    }

    #profilePreview.layout-editorial
    .sfs-preview-story-link {
        margin-top: 4px;
    }

}

/* =========================================
   JOINED DATE — INDEPENDENT ALIGNMENT
   All profile layouts
========================================= */

#profilePreview .preview-joined,
#profile .profile-joined {
    width: 100%;
    min-width: 0;

    text-align:
        var(--sfs-editorial-joined-align, left);
}