/* =====================================================================
 * ②号子屏幕 · 相册组件（Char 自拍相册）独立样式
 * ---------------------------------------------------------------------
 * 入口外观：参考「黑胶唱片套」素材重绘——磨砂玻璃唱片套 + 圆形封面窗 +
 *           右侧探出的黑色胶片（黑色部分保持不变，不随主题改变）。
 * 主界面：从右侧滑入的全屏相册（网格 + 大图查看 + 设为封面 / 移出相册）。
 * 主题：磨砂套/窗/文字随 --lmg-* 与暗色联动；黑色胶片恒为黑。
 * 命名：统一 ss2ab- 前缀，独立文件，不与其它屏幕/组件共用。
 * ===================================================================== */

/* ============ 入口：唱片套组件 ============ */
.ss2ab-entry {
    --ss2ab-sleeve: rgba(252, 250, 249, 0.66);
    --ss2ab-sleeve-border: rgba(255, 255, 255, 0.6);
    --ss2ab-sleeve-shadow: rgba(120, 122, 140, 0.24);
    --ss2ab-text: #4a4750;
    --ss2ab-accent: #d98aa0;
    --ss2ab-window-bg: rgba(255, 255, 255, 0.5);

    position: relative;
    align-self: flex-start;
    width: clamp(170px, 56%, 212px);
    /* 套(正方) + 右侧探出的胶片，整体略宽于高 */
    aspect-ratio: 1.18 / 1;
    /* 入口在②号子屏幕内的偏移：上移为右下快捷区（70×2+12）腾出空间，左移 12px */
    margin: 72px 0 4px 12px;
    padding: 0;
    border: none;
    background: transparent;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: transform 0.2s ease;
}

.ss2ab-entry:active {
    transform: scale(0.96);
}

/* 黑色胶片：恒为黑，不随主题/美化改变 */
.ss2ab-disc {
    position: absolute;
    top: 50%;
    right: 0;
    transform: translateY(-50%);
    height: 84%;
    width: auto;
    aspect-ratio: 1 / 1;
    border-radius: 50%;
    z-index: 1;
    background:
        repeating-radial-gradient(circle at 50% 50%, rgba(255, 255, 255, 0.05) 0 0.5px, rgba(0, 0, 0, 0) 1.5px 3.5px),
        radial-gradient(circle at 50% 50%, #2a2a2a 0 6%, #0b0b0b 6.5% 100%);
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.4), inset 0 0 14px rgba(0, 0, 0, 0.55);
}

/* 唱片中心标签 + 轴孔 */
.ss2ab-disc::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 28%;
    height: 28%;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    background: radial-gradient(circle at 50% 50%, #1a1a1a 0 16%, #e7c2cd 18% 100%);
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.25);
}

/* 磨砂玻璃唱片套（盖住胶片左侧） */
.ss2ab-sleeve {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 80%;
    z-index: 2;
    border-radius: 20px;
    background: var(--ss2ab-sleeve);
    border: 1px solid var(--ss2ab-sleeve-border);
    box-shadow: 0 14px 30px var(--ss2ab-sleeve-shadow), inset 0 1px 0 rgba(255, 255, 255, 0.45);
    -webkit-backdrop-filter: blur(15px) saturate(130%);
    backdrop-filter: blur(15px) saturate(130%);
    overflow: hidden;
}

/* 套上的标签徽标 */
.ss2ab-badge {
    position: absolute;
    top: 9px;
    left: 9px;
    z-index: 3;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 1px;
    padding: 3px 8px;
    border-radius: 8px;
    color: #fff;
    background: var(--ss2ab-accent);
    box-shadow: 0 3px 8px rgba(217, 138, 160, 0.4);
}

/* 装饰：音符 / 爱心（克制，韩风留白） */
.ss2ab-deco {
    position: absolute;
    z-index: 3;
    color: var(--ss2ab-accent);
    opacity: 0.85;
    pointer-events: none;
    line-height: 1;
}
.ss2ab-deco-note {
    left: 10px;
    bottom: 10px;
    font-size: 18px;
}
.ss2ab-deco-heart {
    right: 9px;
    top: 9px;
    font-size: 13px;
}

/* 圆形封面窗（展示用户设为封面的照片 / 最新照片） */
.ss2ab-window {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 64%;
    aspect-ratio: 1 / 1;
    border-radius: 50%;
    overflow: hidden;
    background: var(--ss2ab-window-bg);
    box-shadow: inset 0 0 0 3px rgba(255, 255, 255, 0.6), inset 0 2px 10px rgba(0, 0, 0, 0.12);
}

.ss2ab-window-img {
    position: absolute;
    left: 0;
    top: 0;
    right: 0;
    bottom: 0;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    opacity: 0;
    transition: opacity 0.25s ease;
}
.ss2ab-window.has-cover .ss2ab-window-img {
    opacity: 1;
}

.ss2ab-window-empty {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 26px;
    color: var(--ss2ab-accent);
    opacity: 0.7;
}
.ss2ab-window.has-cover .ss2ab-window-empty {
    opacity: 0;
}

/* 数量角标 */
/* 数量角标：产品要求不在入口展示照片数量 */
.ss2ab-count {
    display: none !important;
}

/* ============ 主界面：全屏相册（滑入） ============ */
.ss2ab-overlay {
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    bottom: 0;
    z-index: 6000;
    display: flex;
    flex-direction: column;
    background: rgba(244, 246, 250, 0.86);
    -webkit-backdrop-filter: blur(22px) saturate(135%);
    backdrop-filter: blur(22px) saturate(135%);
    transform: translateX(100%);
    transition: transform 0.32s cubic-bezier(0.32, 0.72, 0.25, 1);
    will-change: transform;
    color: #3a3742;
}
.ss2ab-overlay.is-open {
    transform: translateX(0);
}

.ss2ab-head {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: max(12px, env(safe-area-inset-top, 0px)) 14px 12px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.ss2ab-back {
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    border: none;
    background: transparent;
    font-size: 22px;
    line-height: 1;
    color: inherit;
    cursor: pointer;
    border-radius: 10px;
    -webkit-tap-highlight-color: transparent;
}
.ss2ab-back:active {
    background: rgba(0, 0, 0, 0.06);
}

.ss2ab-title {
    flex: 1;
    min-width: 0;
    font-size: 17px;
    font-weight: 700;
}
.ss2ab-title small {
    font-size: 12px;
    font-weight: 500;
    opacity: 0.55;
    margin-left: 6px;
}

.ss2ab-grid {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    padding: 12px 10px calc(20px + env(safe-area-inset-bottom, 0px));
    align-content: start;
}

.ss2ab-cell {
    position: relative;
    aspect-ratio: 1 / 1;
    border-radius: 12px;
    overflow: hidden;
    background: rgba(0, 0, 0, 0.05);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
.ss2ab-cell-img {
    position: absolute;
    left: 0;
    top: 0;
    right: 0;
    bottom: 0;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}
.ss2ab-cell:active {
    opacity: 0.9;
}
.ss2ab-cell-flag {
    position: absolute;
    top: 5px;
    left: 5px;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 6px;
    color: #fff;
    background: rgba(217, 138, 160, 0.92);
    display: none;
}
.ss2ab-cell.is-cover .ss2ab-cell-flag {
    display: block;
}

.ss2ab-empty {
    grid-column: 1 / -1;
    padding: 48px 24px;
    text-align: center;
    color: rgba(58, 55, 66, 0.6);
    font-size: 13.5px;
    line-height: 1.9;
}
.ss2ab-empty-emoji {
    font-size: 36px;
    margin-bottom: 10px;
    opacity: 0.8;
}

/* ============ 大图查看器 ============ */
.ss2ab-viewer {
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    bottom: 0;
    z-index: 6100;
    display: flex;
    flex-direction: column;
    background: rgba(12, 12, 16, 0.92);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}
.ss2ab-viewer.is-open {
    opacity: 1;
    pointer-events: auto;
}

.ss2ab-viewer-stage {
    flex: 1;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: max(16px, env(safe-area-inset-top, 0px)) 16px 8px;
}
.ss2ab-viewer-img {
    max-width: 100%;
    max-height: 100%;
    border-radius: 12px;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
    object-fit: contain;
}

.ss2ab-viewer-bar {
    flex-shrink: 0;
    display: flex;
    gap: 10px;
    padding: 12px 16px calc(20px + env(safe-area-inset-bottom, 0px));
    justify-content: center;
}
.ss2ab-viewer-btn {
    flex: 1;
    max-width: 160px;
    padding: 12px;
    border: none;
    border-radius: 13px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    color: #fff;
    background: rgba(255, 255, 255, 0.16);
}
.ss2ab-viewer-btn--primary {
    background: linear-gradient(135deg, #e892a6, #d57890);
}
.ss2ab-viewer-btn--save {
    background: rgba(255, 255, 255, 0.22);
    border: 1px solid rgba(255, 255, 255, 0.34);
}
.ss2ab-viewer-btn--save:active {
    background: rgba(255, 255, 255, 0.3);
}
.ss2ab-viewer-btn--danger {
    background: rgba(231, 76, 92, 0.9);
}
.ss2ab-viewer-close {
    position: absolute;
    top: max(14px, env(safe-area-inset-top, 0px));
    right: 14px;
    width: 38px;
    height: 38px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.18);
    color: #fff;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
}

/* ============ 暗色模式 ============ */
html[data-appearance="dark"] .ss2ab-entry {
    --ss2ab-sleeve: rgba(40, 40, 46, 0.66);
    --ss2ab-sleeve-border: rgba(255, 255, 255, 0.1);
    --ss2ab-sleeve-shadow: rgba(0, 0, 0, 0.5);
    --ss2ab-text: rgba(245, 245, 250, 0.92);
    --ss2ab-accent: #e79ab0;
    --ss2ab-window-bg: rgba(255, 255, 255, 0.08);
}
html[data-appearance="dark"] .ss2ab-overlay {
    background: rgba(24, 24, 28, 0.9);
    color: rgba(245, 245, 250, 0.92);
}
html[data-appearance="dark"] .ss2ab-head {
    border-bottom-color: rgba(255, 255, 255, 0.08);
}
html[data-appearance="dark"] .ss2ab-cell {
    background: rgba(255, 255, 255, 0.06);
}
html[data-appearance="dark"] .ss2ab-empty {
    color: rgba(235, 235, 245, 0.55);
}

/* ============ 全局美化联动（黑色胶片不变） ============ */
html[data-global-beautify="1"] .ss2ab-entry {
    --ss2ab-sleeve: var(--lmg-sub-component-bg);
    --ss2ab-sleeve-border: var(--lmg-border);
    --ss2ab-sleeve-shadow: var(--lmg-shadow);
    --ss2ab-text: var(--lmg-text);
    --ss2ab-accent: var(--lmg-button-text);
    --ss2ab-window-bg: var(--lmg-icon-bg);
}
html[data-global-beautify="1"] .ss2ab-overlay {
    background: var(--lmg-sub-bg);
    color: var(--lmg-text);
}
html[data-global-beautify="1"][data-global-beautify-style="minimal"] .ss2ab-sleeve {
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
}

/* ============ 兼容兜底：不支持 backdrop-filter ============ */
@supports not ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) {
    .ss2ab-sleeve { background: rgba(252, 250, 249, 0.95); }
    .ss2ab-overlay { background: rgba(244, 246, 250, 0.98); }
    html[data-appearance="dark"] .ss2ab-sleeve { background: rgba(42, 42, 48, 0.96); }
    html[data-appearance="dark"] .ss2ab-overlay { background: rgba(24, 24, 28, 0.98); }
}

/* ============ 兼容兜底：不支持 aspect-ratio（老 WebView） ============ */
@supports not (aspect-ratio: 1 / 1) {
    .ss2ab-entry { height: 150px; }
    .ss2ab-disc { height: 84%; width: 126px; }
    .ss2ab-window { width: 96px; height: 96px; }
    .ss2ab-cell { height: 0; padding-bottom: 100%; }
    .ss2ab-cell-img { height: 100%; }
}

/* 窄屏微调 */
@media (max-width: 360px) {
    .ss2ab-entry { width: clamp(150px, 60%, 190px); }
    .ss2ab-grid { grid-template-columns: repeat(3, 1fr); gap: 5px; }
}
