.feed-card {
    margin-top: 6px;
    margin-bottom: 14px;
}

/* ───── 缩略图网格（外圈圆角，仅在 ≥2 张时） ───── */
.feed-media-grid {
    --gap: 4px;
    --tile-ratio: 100%; /* 默认方形高度比例 */
    display: grid;
    gap: var(--gap);

    /* 默认：不圆角（单图/未知张数时） */
    border-radius: 10px;
    overflow: visible;
    background: transparent; /* 让 gap 处透出页面背景 */
}

/* 桌面：6 列；移动/平板：3 列 */
@media (min-width: 1200px) {
    .feed-media-grid {
        grid-template-columns: repeat(6, 1fr);
    }
}

@media (max-width: 1199.98px) {
    .feed-media-grid {
        grid-template-columns: repeat(3, 1fr);
        --tile-ratio: 100%; /* 保持正方形 */
        --gap: 3px; /* 略收紧间距 */
    }
}

/* 多图：给容器加圆角并裁剪（保持你原来的规则） */
.feed-media-grid:has(.media + .media) {
    border-radius: 12px;
    overflow: hidden;
}

/* 单图：给唯一的 .media 本身加圆角并裁剪 */
.feed-media-grid:has(.media):not(:has(.media + .media)) .media {
    border-radius: 12px;
    overflow: hidden;
}

/* 兼容无 :has() 的情况：用你的 count-1 兜底 */
.feed-media-grid.count-1 .media,
.feed-media-grid[class*="count-1"] .media {
    border-radius: 12px;
    overflow: hidden;
}

/* 子项统一无圆角，让“内缝”全是直角 */
.feed-media-grid .media {
    position: relative;
    width: 100%;
    padding-bottom: var(--tile-ratio, 100%);
    overflow: hidden;
    cursor: pointer;
}

.feed-media-grid .media img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* ① 现代浏览器：当容器里“至少两张图”时，给容器加外圈圆角并裁剪 */
.feed-media-grid:has(.media + .media) {
    overflow: hidden;
}

/* ② 兜底（无 :has 时）：你已有的 count-* 类
   - count-1：单图，不圆角
   - 其它（count-2、count-3…）：视为多图，给容器圆角
*/
.feed-media-grid[class*="count-"]:not(.count-0):not(.count-1) {
    border-radius: 12px;
    overflow: hidden;
}

/* +N 遮罩（由容器裁剪外圈即可，不依赖子项圆角） */
.more-mask {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, .55);
    backdrop-filter: blur(2px);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 26px;
    font-weight: 600;
}

/* 悬浮放大 icon；带遮罩的不出现 */
.media::after {
    font-family: "Font Awesome 5 Pro";
    content: "\f424";
    font-weight: 900;
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: #fff;
    background: rgba(0, 0, 0, .35);
    opacity: 0;
    transition: opacity .25s;
}

.media:not(:has(.more-mask)):hover::after {
    opacity: 1;
}

/* ───── 画廊 overlay（原样保留） ───── */
.gallery-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(0, 0, 0, .88);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
}

/* 顶部条容器，固定在 overlay 顶部 */
.gallery-topbar {
    position: absolute;
    top: 16px;
    left: 16px;
    right: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    pointer-events: none; /* 不挡点 */
}

.gallery-counter {
    pointer-events: none;
    color: #fff;
    font-size: 16px;
    font-weight: 600;
    opacity: .9;
}

.gallery-meta {
    pointer-events: none;
    color: #fff;
    font-size: 14px;
    text-align: right;
    opacity: .9;
    line-height: 1.4;
}

.gallery-img {
    border-radius: 0;
    box-shadow: 0 0 8px rgba(0, 0, 0, .6);
    max-width: 100%;
    max-height: 100%;
    margin-top: 10px;
    margin-bottom: 15px;
}

.gallery-controls {
    display: flex;
    gap: 46px;
    align-items: center;
}

.gallery-arrow {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: rgba(255, 255, 255, .18);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    color: #fff;
    cursor: pointer;
    transition: background .25s;
}

.gallery-secure-btn {
    width: 48px;
    height: 48px;
    font-size: 22px;
}

.gallery-arrow:hover {
    background: rgba(255, 255, 255, .32);
}

.gallery-arrow.disabled {
    color: rgba(255, 255, 255, .18);
    cursor: default;
}

.gallery-arrow.disabled:hover {
    background: rgba(255, 255, 255, .08);
}

/* 统一重置 overlay 内按钮，避免 UA/全局样式干扰 */
.gallery-overlay button {
    font: inherit;
    border: none;
    outline: none;
    background: transparent;
    -webkit-appearance: none;
    appearance: none;
    color: #fff;
}

/* 关闭按钮 */
.gallery-close {
    position: absolute;
    top: 22px;
    right: 28px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: transparent;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background .2s, transform .08s;
    box-shadow: none;
}

.gallery-close:hover {
    background: rgba(255, 255, 255, .18);
}

.gallery-close:active {
    transform: scale(.96);
}

.gallery-close i {
    font-size: 28px;
    line-height: 1;
    color: #fff;
    background: none;
    pointer-events: none;
}

.gallery-stage{
    display:inline-flex;
    flex-direction:column;
    align-items:stretch;
    max-width:90vw;
    max-height:82vh;
}

/* 底部一行，默认居中（无 secure） */
.gallery-bottombar{
    display:flex;
    align-items:center;
    gap:16px;
    justify-content:center;
}

.gallery-secure-btn{
    min-width: 88px !important;
    width: auto;
    margin-left: 10px;
}

/* 有 secure 时，左侧按钮 + 右侧箭头/计数 */
.gallery-overlay.has-secure .gallery-bottombar{
    justify-content:space-between;
}

/* 右侧控件内部保持原来的间距 */
.gallery-controls{
    display:flex;
    align-items:center;
    gap:46px;
}

/* 可选：小屏收紧 */
@media (max-width: 768px){
    .gallery-controls{ gap:20px; }
}