/* ④号子屏幕 · 固定比例社交照片卡 + 下方快捷入口 */
.home-sub-screen-4-page {
    --ss3-card-bg: rgba(250, 248, 244, 0.78);
    --ss3-card-border: rgba(255, 255, 255, 0.58);
    --ss3-card-shadow: rgba(92, 82, 105, 0.14);
    --ss3-text: #3e3b46;
    --ss3-muted: rgba(62, 59, 70, 0.58);
    --ss3-accent: #9b6f93;
    --ss3-accent-2: #708aa8;
    --ss3-photo-width: calc(88.888888889% - 19.555555556px);
    /* 标题/作者/页脚、两排快捷入口及间距共预留 371px；乘 3/2 转为宽度。 */
    --ss3-photo-budget-offset: 556.5px;
    box-sizing: border-box;
    align-items: stretch;
    justify-content: flex-start;
    overflow: hidden;
    /* home-widgets.css 在短屏上启用纵向滚动；仅隐藏轨道，保留原生滚动。 */
    scrollbar-width: none;
    -ms-overflow-style: none;
    padding: clamp(8px, 1.7vh, 14px) 12px 0;
    background: transparent;
}

.home-sub-screen-4-page::-webkit-scrollbar {
    display: none;
    width: 0;
    height: 0;
}

.ss3sf-card {
    box-sizing: border-box;
    width: 100%;
    height: auto;
    min-height: 0;
    max-height: none;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    color: var(--ss3-text);
    background: var(--ss3-card-bg);
    border: 1px solid var(--ss3-card-border);
    border-radius: clamp(18px, 5vw, 24px);
    box-shadow: 0 10px 28px var(--ss3-card-shadow);
    -webkit-backdrop-filter: blur(18px) saturate(130%);
    backdrop-filter: blur(18px) saturate(130%);
}

.ss3sf-stories {
    flex: 0 0 auto;
    padding: 9px 10px 7px;
    border-bottom: 1px solid rgba(112, 100, 120, 0.1);
}

.ss3sf-stories-title {
    margin: 0 0 5px 2px;
    font-size: 11px;
    line-height: 1;
    font-weight: 750;
    letter-spacing: 0.03em;
    color: var(--ss3-muted);
}

.ss3sf-story-list {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 6px;
}

.ss3sf-story {
    min-width: 0;
    text-align: center;
}

.ss3sf-story-avatar,
.ss3sf-author-avatar {
    position: relative;
    overflow: hidden;
    border-radius: 50%;
    background: linear-gradient(145deg, rgba(155, 111, 147, 0.2), rgba(112, 138, 168, 0.2));
}

.ss3sf-story-avatar {
    width: clamp(37px, 10.5vw, 46px);
    height: clamp(37px, 10.5vw, 46px);
    margin: 0 auto;
    padding: 2px;
    border: 1.5px solid var(--ss3-accent);
    box-sizing: border-box;
}

.ss3sf-story--user .ss3sf-story-avatar {
    border-color: rgba(112, 138, 168, 0.56);
}

.ss3sf-avatar-img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
    border-radius: inherit;
}

.ss3sf-avatar-fallback {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: inherit;
    font-size: 13px;
    font-weight: 750;
    color: var(--ss3-accent-2);
    background: rgba(255, 255, 255, 0.55);
}

.ss3sf-story-name {
    display: block;
    margin-top: 3px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 9px;
    line-height: 1.15;
    color: var(--ss3-muted);
}

.ss3sf-author {
    flex: 0 0 auto;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 11px;
}

.ss3sf-author-avatar {
    flex: 0 0 35px;
    width: 35px;
    height: 35px;
    border: 1px solid rgba(112, 138, 168, 0.45);
}

.ss3sf-author-copy {
    min-width: 0;
    flex: 1;
    display: flex;
    align-items: baseline;
    gap: 6px;
}

.ss3sf-author-name {
    min-width: 0;
    max-width: 48%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 13px;
    font-weight: 760;
}

.ss3sf-song {
    min-width: 0;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 9px;
    color: var(--ss3-muted);
}

.ss3sf-song::before {
    content: '♪ ';
    color: var(--ss3-accent);
}

.ss3sf-photo-button {
    position: relative;
    flex: 0 0 auto;
    box-sizing: border-box;
    /* 继续缩小上方名片；照片保持 3:2 居中铺满，两排入口优先可见。 */
    aspect-ratio: 3 / 2;
    min-height: 0;
    width: var(--ss3-photo-width);
    margin: 0 auto;
    padding: 0;
    overflow: hidden;
    border: 0;
    border-radius: 14px;
    color: var(--ss3-muted);
    background:
        radial-gradient(circle at 26% 18%, rgba(255, 255, 255, 0.72), transparent 34%),
        linear-gradient(145deg, rgba(224, 217, 226, 0.76), rgba(205, 217, 225, 0.7));
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.ss3sf-photo-button.has-photo {
    background: rgba(30, 30, 34, 0.08);
}

.ss3sf-photo-img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    object-fit: cover;
}

/* 旧 WebView 没有 aspect-ratio 时，也保留相同的横向比例。 */
@supports not (aspect-ratio: 3 / 2) {
    .ss3sf-photo-button::before {
        content: '';
        display: block;
        padding-top: 66.666667%;
    }
}

.ss3sf-photo-button.has-photo .ss3sf-photo-img {
    display: block;
}

.ss3sf-photo-placeholder {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    font-size: 10px;
}

.ss3sf-photo-button.has-photo .ss3sf-photo-placeholder {
    display: none;
}

.ss3sf-photo-plus {
    font-size: 22px;
    font-weight: 300;
    color: var(--ss3-accent);
}

.ss3sf-footer {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 7px 12px 9px;
}

.ss3sf-actions {
    display: flex;
    align-items: center;
    gap: 9px;
    color: var(--ss3-muted);
}

.ss3sf-action-icon {
    width: 17px;
    height: 17px;
    display: block;
}

.ss3sf-likes {
    margin-left: auto;
    font-size: 11px;
    line-height: 1;
    font-weight: 760;
    white-space: nowrap;
}

.ss3sf-shortcuts {
    box-sizing: border-box;
    width: 100%;
    margin-top: 16px;
    padding: 0 2px;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    /* 行距对齐③号屏快捷区（#desktop-third-shortcuts 的 20px），
       第二排「Love TV」不再贴着第一排名称。 */
    row-gap: 20px;
    column-gap: clamp(2px, 1.6vw, 8px);
    align-items: start;
}

.ss3sf-shortcut.sub-screen-action {
    min-width: 0;
    width: 100%;
    color: var(--ss3-text);
    background: transparent;
}

/* 两排都参与实际布局，第二排名称不再额外移向底部分页器。 */
#home-screen .home-sub-screen-4-page > .ss3sf-shortcuts {
    margin-bottom: 8px;
}

.ss3sf-shortcut[data-ss3-shortcut="app-store"]:active,
.ss3sf-shortcut[data-ss3-shortcut="custom-theater"]:active {
    transform: scale(0.96);
}

.ss3sf-shortcut .ss3sf-shortcut-icon.sub-screen-action-icon {
    width: clamp(44px, 12vw, 52px);
    height: clamp(44px, 12vw, 52px);
    color: var(--ss3-accent);
}

.ss3sf-shortcut-icon svg,
.ss3sf-shortcut-icon-img {
    width: clamp(25px, 7vw, 29px);
    height: clamp(25px, 7vw, 29px);
    display: block;
    object-fit: cover;
    border-radius: inherit;
}

.ss3sf-shortcut .ss3sf-shortcut-label.sub-screen-action-label {
    width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: clamp(9px, 2.8vw, 11px);
    line-height: 1.2;
    letter-spacing: 0.02em;
}

.ss3sf-shortcut:focus-visible {
    outline: 2px solid color-mix(in srgb, var(--ss3-accent) 72%, white);
    outline-offset: 3px;
}

.ss3sf-picker-overlay {
    position: absolute;
    inset: 0;
    z-index: 3200;
    display: none;
    align-items: flex-end;
    justify-content: center;
    padding: max(12px, var(--safe-area-inset-top, env(safe-area-inset-top, 0px))) 12px max(14px, var(--safe-area-inset-bottom, env(safe-area-inset-bottom, 0px)));
    box-sizing: border-box;
    background: rgba(34, 30, 38, 0.34);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
}

.ss3sf-picker-overlay.is-open {
    display: flex;
}

.ss3sf-picker-sheet {
    width: min(100%, 420px);
    max-height: min(72vh, 620px);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    color: var(--ss3-text, #3e3b46);
    background: rgba(249, 247, 244, 0.96);
    border: 1px solid rgba(255, 255, 255, 0.72);
    border-radius: 22px;
    box-shadow: 0 18px 50px rgba(40, 33, 45, 0.22);
}

.ss3sf-picker-overlay.is-album .ss3sf-picker-sheet {
    height: min(72vh, 620px);
}

.ss3sf-picker-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px 10px;
}

.ss3sf-picker-title {
    font-size: 15px;
    font-weight: 760;
}

.ss3sf-picker-content {
    min-height: 0;
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    overflow: hidden;
}

.ss3sf-picker-close {
    width: 34px;
    height: 34px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    color: inherit;
    background: rgba(112, 100, 120, 0.1);
    font-size: 20px;
    cursor: pointer;
    touch-action: manipulation;
}

.ss3sf-source-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    padding: 6px 14px 16px;
}

.ss3sf-source-button {
    min-height: 72px;
    border: 1px solid rgba(112, 100, 120, 0.12);
    border-radius: 16px;
    color: inherit;
    background: linear-gradient(145deg, rgba(155, 111, 147, 0.12), rgba(112, 138, 168, 0.12));
    font: inherit;
    cursor: pointer;
    touch-action: manipulation;
}

.ss3sf-source-button strong,
.ss3sf-source-button small {
    display: block;
}

.ss3sf-source-button strong {
    font-size: 14px;
}

.ss3sf-source-button small {
    margin-top: 4px;
    color: var(--ss3-muted, rgba(62, 59, 70, 0.58));
    font-size: 10px;
}

.ss3sf-album-grid {
    min-height: 0;
    flex: 1 1 auto;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
    touch-action: pan-y;
    scrollbar-width: thin;
    scrollbar-color: rgba(126, 101, 132, 0.42) transparent;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 7px;
    padding: 4px 14px 16px;
}

.ss3sf-album-grid::-webkit-scrollbar {
    width: 4px;
}

.ss3sf-album-grid::-webkit-scrollbar-track {
    background: transparent;
}

.ss3sf-album-grid::-webkit-scrollbar-thumb {
    border-radius: 999px;
    background: rgba(126, 101, 132, 0.42);
}

.ss3sf-album-item {
    position: relative;
    min-height: 92px;
    padding: 0;
    overflow: hidden;
    border: 0;
    border-radius: 12px;
    background: rgba(112, 100, 120, 0.1);
    cursor: pointer;
}

.ss3sf-album-item img {
    width: 100%;
    height: 100%;
    min-height: 92px;
    display: block;
    object-fit: cover;
}

.ss3sf-album-empty {
    grid-column: 1 / -1;
    padding: 28px 12px;
    text-align: center;
    color: var(--ss3-muted, rgba(62, 59, 70, 0.58));
    font-size: 12px;
}

html[data-appearance="dark"] .home-sub-screen-4-page {
    --ss3-card-bg: rgba(39, 39, 46, 0.78);
    --ss3-card-border: rgba(255, 255, 255, 0.12);
    --ss3-card-shadow: rgba(0, 0, 0, 0.32);
    --ss3-text: rgba(255, 255, 255, 0.9);
    --ss3-muted: rgba(255, 255, 255, 0.58);
}

html[data-appearance="dark"] .ss3sf-picker-sheet {
    color: rgba(255, 255, 255, 0.9);
    background: rgba(38, 38, 44, 0.97);
    border-color: rgba(255, 255, 255, 0.12);
}

html[data-appearance="dark"] .ss3sf-shortcut .ss3sf-shortcut-icon {
    color: rgba(233, 216, 231, 0.88);
}

html[data-global-beautify="1"] .home-sub-screen-4-page {
    --ss3-card-bg: var(--lmg-sub-component-bg, rgba(250, 248, 244, 0.78));
    --ss3-card-border: var(--lmg-border, rgba(255, 255, 255, 0.58));
    --ss3-card-shadow: var(--lmg-shadow, rgba(92, 82, 105, 0.14));
    --ss3-text: var(--lmg-text, #3e3b46);
    --ss3-muted: color-mix(in srgb, var(--lmg-text, #3e3b46) 58%, transparent);
    --ss3-accent: var(--lmg-button-text, #9b6f93);
    --ss3-accent-2: var(--lmg-button-text, #708aa8);
}

html[data-global-beautify="1"] .ss3sf-shortcut .ss3sf-shortcut-icon.sub-screen-action-icon {
    color: var(--lmg-button-text, var(--ss3-accent));
}

@supports not (color: color-mix(in srgb, black, white)) {
    html[data-global-beautify="1"] .home-sub-screen-4-page {
        --ss3-muted: var(--lmg-text, #5f5966);
    }
}

@media (max-height: 700px) {
    .home-sub-screen-4-page {
        --ss3-photo-width: calc(83.333333333% - 18.333333333px);
        --ss3-photo-budget-offset: 475.5px;
        padding-top: 6px;
    }
    .ss3sf-card {
        height: auto;
        min-height: 0;
        border-radius: 18px;
    }
    .ss3sf-stories {
        padding-top: 6px;
        padding-bottom: 5px;
    }
    .ss3sf-story-avatar {
        width: 34px;
        height: 34px;
    }
    .ss3sf-author {
        padding-top: 5px;
        padding-bottom: 5px;
    }
    .ss3sf-footer {
        padding-top: 5px;
        padding-bottom: 7px;
    }
    .ss3sf-shortcuts {
        margin-top: 12px;
        row-gap: 20px;
    }
    .ss3sf-shortcut .ss3sf-shortcut-icon.sub-screen-action-icon {
        width: 42px;
        height: 42px;
        border-radius: 13px;
    }
    /* 覆盖公共美化的 52px，让两排自定义图标与默认图标占用相同空间。 */
    .ss3sf-shortcut .ss3sf-shortcut-icon.sub-screen-action-icon.theme-icon-wrap--custom {
        width: 42px !important;
        height: 42px !important;
        max-height: 42px !important;
    }
    .ss3sf-shortcut-icon svg,
    .ss3sf-shortcut-icon-img {
        width: 24px;
        height: 24px;
    }
}

/* 568px 等矮屏进一步收紧名片，仍为两排快捷入口保留位置。 */
@media (max-height: 600px) {
    .home-sub-screen-4-page {
        --ss3-photo-width: calc(75% - 16.5px);
        --ss3-photo-budget-offset: 400.5px;
        padding-top: 4px;
    }
    .ss3sf-stories {
        padding-top: 4px;
        padding-bottom: 4px;
    }
    .ss3sf-story-avatar {
        width: 26px;
        height: 26px;
    }
    .ss3sf-author {
        padding-top: 3px;
        padding-bottom: 3px;
    }
    .ss3sf-author-avatar {
        flex-basis: 28px;
        width: 28px;
        height: 28px;
    }
    .ss3sf-footer {
        padding-top: 3px;
        padding-bottom: 5px;
    }
    .ss3sf-shortcuts {
        margin-top: 8px;
    }
}

/* 只以本页已经扣除状态栏/底栏的实际高度为预算；不测量或改写全屏根尺寸。 */
@supports (container-type: size) and (width: 1cqh) {
    .home-sub-screen-4-page {
        container-type: size;
    }
    .ss3sf-photo-button {
        width: max(66px, min(var(--ss3-photo-width), calc(150cqh - var(--ss3-photo-budget-offset))));
    }
}

/* 旧内核不能读取本页高度，额外预留约 19px 高度，兼容较大的底部安全区。 */
@supports not ((container-type: size) and (width: 1cqh)) {
    .ss3sf-photo-button {
        width: calc(var(--ss3-photo-width) - 28px);
    }
}

@media (prefers-reduced-motion: reduce) {
    .ss3sf-picker-overlay,
    .ss3sf-card,
    .ss3sf-photo-button,
    .ss3sf-shortcut {
        scroll-behavior: auto;
        transition: none !important;
    }
}
