/* ==================== 日常 ==================== */

.gallery-page {
    width: 100%;
}

/* 顶部工具栏（发布按钮） */
.gallery-toolbar {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 14px;
}

.gallery-publish-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: linear-gradient(135deg, var(--accent-light), var(--accent));
    color: #fff;
    border: none;
    border-radius: 999px;
    padding: 8px 20px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 3px 12px rgba(var(--accent-rgb), 0.32);
    transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.gallery-publish-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 5px 16px rgba(var(--accent-rgb), 0.42);
}

.gallery-publish-btn:active {
    transform: translateY(0);
}

/* ==================== 第一条：大图 + 文字 ==================== */
.gallery-feature {
    margin-bottom: 8px;
}

/* 媒体 + 文字的行布局（评论入口/评论窗在卡片内、这一行的下方） */
.gallery-feature-main {
    display: flex;
    gap: 18px;
    align-items: flex-start;
}

/* 卡片内评论：与上方内容留出间距 */
.gallery-feature > .gallery-discuss {
    margin-top: 12px;
}

.gallery-feature-image {
    flex: 0 0 55%;
    max-width: 55%;
    border-radius: 12px;
    overflow: hidden;
    background: #f2f2f2;
}

.gallery-feature-image img {
    display: block;
    width: 100%;
    height: auto;
    cursor: zoom-in;
    transition: transform 0.35s ease;
}

.gallery-feature-image:hover img {
    transform: scale(1.02);
}

.gallery-feature-text {
    flex: 1 1 auto;
    min-width: 0;
}

.gallery-date {
    font-size: 12.5px;
    color: #b0a0aa;
    font-family: Consolas, monospace;
    margin-bottom: 8px;
}

.gallery-text {
    font-size: 15px;
    line-height: 1.85;
    color: #4a4a4a;
    word-break: break-word;
}

/* ==================== 九宫格网格 ==================== */
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    margin-top: 12px;
}

.gallery-cell {
    position: relative;
    border-radius: 8px;
    overflow: hidden;
    background: #f2f2f2;
}

.gallery-cell::before {
    content: '';
    display: block;
    padding-bottom: 100%;   /* 1:1 正方形占位 */
}

.gallery-cell img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    cursor: zoom-in;
    transition: transform 0.35s ease;
}

.gallery-cell:hover img {
    transform: scale(1.05);
}

/* ==================== 发布面板 ==================== */
.gallery-publish-panel {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(20, 22, 28, 0.5);
    z-index: 10000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.gallery-publish-panel.open {
    display: flex;
}

.gallery-panel-box {
    width: 100%;
    max-width: 520px;
    max-height: 88vh;
    overflow-y: auto;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.22);
}

.gallery-panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid #f5e6ee;
    font-weight: 600;
    color: #d94a86;
    font-size: 16px;
}

.gallery-panel-head a {
    color: #bbb;
    font-size: 22px;
    line-height: 1;
    text-decoration: none;
}

.gallery-panel-head a:hover {
    color: var(--accent);
}

.gallery-panel-body {
    padding: 18px 20px;
}

/* 上传区 */
.gallery-upload-zone {
    display: block;
    border: 2px dashed #ffd0e6;
    border-radius: 12px;
    padding: 20px;
    text-align: center;
    cursor: pointer;
    background: #fffafc;
    transition: border-color 0.2s ease, background 0.2s ease;
}

.gallery-upload-zone:hover {
    border-color: var(--accent-light);
    background: #fff5fa;
}

.gallery-upload-zone.has-files {
    padding: 12px;
}

.gallery-upload-hint i {
    font-size: 26px;
    color: var(--accent-light);
}

.gallery-upload-hint p {
    margin-top: 6px;
    font-size: 13.5px;
    color: #a893a0;
}

.gallery-upload-zone.has-files .gallery-upload-hint {
    display: none;
}

.gallery-upload-preview {
    display: none;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
}

.gallery-upload-zone.has-files .gallery-upload-preview {
    display: grid;
}

.gallery-upload-preview .up-item {
    position: relative;
    border-radius: 8px;
    overflow: hidden;
    padding-bottom: 100%;
    background: #f2f2f2;
}

.gallery-upload-preview .up-item img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* 文字输入 */
#gallery-text-input {
    display: block;
    width: 100%;
    min-height: 110px;
    margin-top: 14px;
    padding: 12px 14px;
    border: 1px solid #f0dce6;
    border-radius: 10px;
    font-size: 14.5px;
    line-height: 1.7;
    font-family: inherit;
    color: #3a3a3a;
    resize: vertical;
    box-sizing: border-box;
    outline: none;
    transition: border-color 0.2s ease;
}

#gallery-text-input:focus {
    border-color: var(--accent-light);
}

/* 底部 */
.gallery-panel-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 14px 20px 18px;
    border-top: 1px solid #f5e6ee;
}

.gallery-panel-tip {
    font-size: 12px;
    color: #b8a8b2;
}

.gallery-submit-btn {
    background: linear-gradient(135deg, var(--accent-light), var(--accent));
    color: #fff;
    border: none;
    border-radius: 999px;
    padding: 8px 26px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 3px 12px rgba(var(--accent-rgb), 0.3);
    transition: transform 0.18s ease;
    white-space: nowrap;
}

.gallery-submit-btn:hover {
    transform: translateY(-1px);
}

/* ==================== 夜间模式 ==================== */
html.dark-mode .gallery-feature-image,
html.dark-mode .gallery-cell {
    background: rgba(255, 255, 255, 0.06);
}

html.dark-mode .gallery-text {
    color: #c9ccd4;
}

html.dark-mode .gallery-date {
    color: #8a8f9c;
}

html.dark-mode .gallery-panel-box {
    background: #1e212a;
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.6);
}

html.dark-mode .gallery-panel-head {
    border-bottom-color: #2c303a;
    color: var(--accent-light);
}

html.dark-mode .gallery-panel-body {
    background: #1e212a;
}

html.dark-mode .gallery-upload-zone {
    border-color: #3a3f4d;
    background: rgba(var(--accent-light-rgb), 0.04);
}

html.dark-mode .gallery-upload-zone:hover {
    border-color: var(--accent-light);
    background: rgba(var(--accent-light-rgb), 0.08);
}

html.dark-mode .gallery-upload-hint p {
    color: #8a8f9c;
}

html.dark-mode #gallery-text-input {
    background: #171a21;
    border-color: #333743;
    color: #dcdfe6;
}

html.dark-mode #gallery-text-input:focus {
    border-color: var(--accent-light);
}

html.dark-mode .gallery-panel-foot {
    border-top-color: #2c303a;
}

html.dark-mode .gallery-panel-tip {
    color: #7a8290;
}

/* ==================== 手机端 ==================== */
@media (max-width: 768px) {
    .gallery-feature-main {
        flex-direction: column;
        gap: 12px;
    }
    .gallery-feature-image {
        flex: 1 1 auto;
        max-width: 100%;
    }
    .gallery-grid {
        gap: 4px;
    }
    .gallery-cell {
        border-radius: 6px;
    }
    .gallery-panel-box {
        max-height: 92vh;
    }
}

/* ==================== 空状态 / 条目 / 提示条 ==================== */
.gallery-empty {
    text-align: center;
    color: #b8a8b2;
    font-size: 14px;
    padding: 44px 20px;
}

/* 其他动态条目（日期 + 文字 + 九宫格） */
.gallery-entry {
    margin-top: 26px;
}

.gallery-entry .gallery-text {
    margin-bottom: 10px;
}

.gallery-entry .gallery-grid {
    margin-top: 8px;
}

/* 发布结果提示条 */
#gallery-toast {
    position: fixed;
    left: 50%;
    bottom: 9%;
    transform: translateX(-50%) translateY(10px);
    max-width: 84vw;
    background: rgba(40, 44, 54, 0.92);
    color: #fff;
    font-size: 13.5px;
    line-height: 1.6;
    padding: 10px 20px;
    border-radius: 22px;
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.28);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.26s ease, transform 0.26s ease;
    z-index: 100001;
    text-align: center;
}

#gallery-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

#gallery-toast.ok {
    background: linear-gradient(135deg, rgba(var(--accent-light-rgb), 0.96), rgba(var(--accent-rgb), 0.96));
    box-shadow: 0 6px 24px rgba(var(--accent-rgb), 0.4);
}

#gallery-toast.err {
    background: rgba(60, 64, 74, 0.95);
}

/* ==================== 日期行 + 删除按钮 ==================== */
.gallery-date-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 8px;
}

.gallery-date-row .gallery-date {
    margin-bottom: 0;
}

/* 小垃圾桶（仅本机显示；由 JS 决定是否渲染） */
.gallery-del {
    flex: 0 0 auto;
    border: none;
    background: transparent;
    color: #cbb8c2;
    font-size: 13px;
    line-height: 1;
    padding: 5px 7px;
    border-radius: 7px;
    cursor: pointer;
    opacity: 0.5;
    transition: color 0.18s ease, background 0.18s ease, opacity 0.18s ease;
}

.gallery-del:hover {
    color: var(--accent-deep);
    background: rgba(var(--accent-deep-rgb), 0.10);
    opacity: 1;
}

.gallery-del:disabled {
    opacity: 0.3;
    cursor: default;
}

html.dark-mode .gallery-del {
    color: #7a8290;
}

html.dark-mode .gallery-del:hover {
    color: var(--accent-light);
    background: rgba(var(--accent-light-rgb), 0.12);
}

/* ==================== 编辑按钮（与删除按钮同款） ==================== */
.gallery-actions {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    flex: 0 0 auto;
}

.gallery-edit {
    border: none;
    background: transparent;
    color: #cbb8c2;
    font-size: 12px;
    line-height: 1;
    padding: 5px 7px;
    border-radius: 7px;
    cursor: pointer;
    opacity: 0.5;
    transition: color 0.18s ease, background 0.18s ease, opacity 0.18s ease;
}

.gallery-edit:hover {
    color: var(--accent-deep);
    background: rgba(var(--accent-deep-rgb), 0.10);
    opacity: 1;
}

.gallery-edit:disabled {
    opacity: 0.3;
    cursor: default;
}

html.dark-mode .gallery-edit {
    color: #7a8290;
}

html.dark-mode .gallery-edit:hover {
    color: var(--accent-light);
    background: rgba(var(--accent-light-rgb), 0.12);
}

/* ==================== 长文折叠（方案 A：纯渐隐） ==================== */
/* 文字自身透明度渐变：最后几行越来越淡，不模糊、不叠色 */
.gallery-text.is-folded {
    /* --fold-lines 由 JS 注入（默认 10） */
    max-height: calc(var(--fold-lines, 20) * 1.85em);
    overflow: hidden;
    -webkit-mask-image: linear-gradient(to bottom,
        #000 50%,
        rgba(0, 0, 0, 0.55) 76%,
        rgba(0, 0, 0, 0.18) 92%,
        transparent 100%);
    mask-image: linear-gradient(to bottom,
        #000 50%,
        rgba(0, 0, 0, 0.55) 76%,
        rgba(0, 0, 0, 0.18) 92%,
        transparent 100%);
}

/* 展开 / 收起按钮 */
.gallery-more {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    margin-top: 9px;
    padding: 5px 14px;
    border: 1px solid rgba(var(--accent-light-rgb), 0.35);
    border-radius: 20px;
    background: rgba(var(--accent-light-rgb), 0.08);
    color: var(--accent-deep);
    font-size: 12.5px;
    line-height: 1.4;
    cursor: pointer;
    transition: background 0.18s ease, color 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
}

.gallery-more:hover {
    background: linear-gradient(135deg, var(--accent-light), var(--accent));
    color: #fff;
    border-color: transparent;
    transform: translateY(-1px);
}

.gallery-more i {
    font-size: 11px;
}

html.dark-mode .gallery-more {
    color: var(--accent-light);
    border-color: rgba(var(--accent-light-rgb), 0.28);
    background: rgba(var(--accent-light-rgb), 0.10);
}

/* ==================== 日常分页 ==================== */
#gallery-pager {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    margin: 22px 0 10px;
    flex-wrap: wrap;
}

.pg-btn,
.pg-num {
    border: 1px solid rgba(var(--accent-rgb), 0.28);
    background: rgba(var(--accent-rgb), 0.06);
    color: var(--accent-deep);
    font-size: 13px;
    line-height: 1;
    padding: 7px 13px;
    border-radius: 9px;
    cursor: pointer;
    transition: background 0.18s ease, color 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
    -webkit-tap-highlight-color: transparent;
}

.pg-num {
    min-width: 34px;
    padding: 7px 8px;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

.pg-btn:hover:not(:disabled),
.pg-num:hover {
    background: rgba(var(--accent-rgb), 0.14);
    transform: translateY(-1px);
}

.pg-num.current {
    background: linear-gradient(135deg, var(--accent-light), var(--accent));
    color: #fff;
    border-color: transparent;
    font-weight: 600;
    cursor: default;
    transform: none;
}

.pg-btn:disabled {
    opacity: 0.35;
    cursor: default;
}

.pg-nums {
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.pg-gap {
    color: #b8a8b2;
    padding: 0 2px;
    user-select: none;
}

html.dark-mode .pg-btn,
html.dark-mode .pg-num {
    color: #ff9acb;
    border-color: rgba(255, 154, 203, 0.26);
    background: rgba(255, 154, 203, 0.07);
}

html.dark-mode .pg-btn:hover:not(:disabled),
html.dark-mode .pg-num:hover {
    background: rgba(255, 154, 203, 0.16);
}

html.dark-mode .pg-gap {
    color: #6f6879;
}

@media (max-width: 480px) {
    .pg-btn { padding: 7px 10px; font-size: 12px; }
    .pg-num { min-width: 30px; padding: 6px 6px; font-size: 12px; }
    #gallery-pager { gap: 4px; }
}

/* ==================== 短视频 ==================== */
/* 结构：.vwrap（相对定位容器）> video.vvideo + .vplay（播放钮）+ .vdur（时长角标）
   行为：进入视口自动静音循环播放（预览感）；点击进入完整播放（有声 + 控制条） */
.vwrap {
    position: relative;
    display: block;
    line-height: 0;
    cursor: pointer;
    background: #0d1016;
    overflow: hidden;
}

.vwrap .vvideo {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* 自动播放中：隐藏播放钮（画面在动本身就是提示） */
.vwrap.playing .vplay {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.7);
}

/* 用户点击进入完整播放：隐藏覆盖元素，画面完整显示（不裁切） */
.vwrap.user-mode {
    cursor: default;
}

.vwrap.user-mode .vplay,
.vwrap.user-mode .vdur {
    display: none;
}

.vwrap.user-mode .vvideo {
    object-fit: contain;
}

/* 中央播放钮 */
.vplay {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 58px;
    height: 58px;
    border-radius: 50%;
    background: rgba(14, 18, 26, 0.62);   /* 不用 backdrop-filter：滚动时模糊重算很吃性能 */
    border: 1.5px solid rgba(255, 255, 255, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 20px;
    padding-left: 4px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
    transition: transform 0.22s ease, background 0.22s ease, opacity 0.22s ease;
    pointer-events: none;
    z-index: 2;
}

.vwrap:hover .vplay {
    transform: translate(-50%, -50%) scale(1.12);
    background: rgba(var(--accent-rgb), 0.85);
    border-color: transparent;
}

/* 右下角时长角标 */
.vdur {
    position: absolute;
    right: 9px;
    bottom: 9px;
    font-size: 11px;
    color: #fff;
    font-weight: 600;
    background: rgba(12, 16, 22, 0.78);
    padding: 2px 7px;
    border-radius: 6px;
    letter-spacing: 0.5px;
    font-variant-numeric: tabular-nums;
    z-index: 2;
}

/* 九宫格内的视频格：铺满方形格子，播放钮/角标缩小 */
.gallery-cell.is-video .vwrap {
    position: absolute;
    inset: 0;
}

.gallery-cell .vplay {
    width: 34px;
    height: 34px;
    font-size: 12px;
    padding-left: 2px;
}

.gallery-cell .vdur {
    right: 5px;
    bottom: 5px;
    font-size: 9.5px;
    padding: 1px 5px;
    border-radius: 5px;
}

/* 首条大图位若是视频：固定 16:9，避免竖屏/横屏把版面撑得参差 */
.gallery-feature-image.is-video {
    background: #0d1016;
}

.gallery-feature-image.is-video .vwrap {
    aspect-ratio: 16 / 9;
    width: 100%;
}

/* 夜间模式 */
html.dark-mode .vwrap,
html.dark-mode .gallery-feature-image.is-video {
    background: #0a0c11;
}

/* 发布面板：视频预览项（首帧 + 时长角标） */
.gallery-upload-preview .up-item.up-video {
    position: relative;
}

.gallery-upload-preview .up-item.up-video video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    border-radius: inherit;
}

.up-video-tag {
    position: absolute;
    left: 4px;
    bottom: 4px;
    font-size: 10px;
    line-height: 1.5;
    color: #fff;
    font-weight: 600;
    background: rgba(var(--accent-rgb), 0.85);
    padding: 1px 6px;
    border-radius: 5px;
    pointer-events: none;
}

.up-video-tag.over {
    background: rgba(220, 60, 80, 0.88);
}

/* ==================== 每条动态 = 独立的块 ==================== */
/* 每条（含置顶大图条）包成一张淡色卡片，块与块之间留出间距 */
.gallery-feature,
.gallery-entry {
    background: rgba(var(--accent-rgb), 0.032);
    border: 1px solid rgba(var(--accent-rgb), 0.10);
    border-radius: 16px;
    padding: 17px 19px;
}

/* 块间距（feed 的直接子元素之间） */
#gallery-feed > .gallery-feature,
#gallery-feed > .gallery-entry,
#gallery-feed > .gallery-grid {
    margin-top: 15px;
}

#gallery-feed > *:first-child {
    margin-top: 0;
}

html.dark-mode .gallery-feature,
html.dark-mode .gallery-entry {
    background: rgba(var(--accent-rgb), 0.055);
    border-color: rgba(var(--accent-rgb), 0.14);
}

/* ==================== 进场动画 ==================== */
/* 进入日常页 / 翻页时，每条依次淡入上浮（错开出现） */
@keyframes galleryIn {
    from { opacity: 0; transform: translateY(24px) scale(0.985); }
    to   { opacity: 1; transform: none; }
}

/* 进入视口时播放（JS 加 .in-view 类；离开视口复位，滚回来重播）
   错开延迟由 JS 按"同批进入"动态设置，单条滚回时不延迟 */
#gallery-feed > .in-view {
    animation: galleryIn 0.58s cubic-bezier(0.22, 1, 0.36, 1) both;
}

/* 日期行：颜色加深 + 小圆点，让"每条从日期开始"的节奏更清楚 */
.gallery-date-row .gallery-date {
    position: relative;
    padding-left: 13px;
    color: #8d7a86;
    font-weight: 600;
}

.gallery-date-row .gallery-date::before {
    content: '';
    position: absolute;
    left: 1px;
    top: 50%;
    transform: translateY(-50%);
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--accent);
    opacity: 0.85;
}

/* 夜间模式（分隔线颜色通用，仅日期文字提亮） */
html.dark-mode .gallery-date-row .gallery-date {
    color: #b9aeb8;
}

/* ==================== 日常正文里的 Markdown 元素 ==================== */
/* 日常是轻内容，样式比文章正文更紧凑一点，与整体协调 */

.gallery-text > *:first-child { margin-top: 0; }
.gallery-text > *:last-child { margin-bottom: 0; }

.gallery-text p {
    margin: 0 0 0.6em;
    line-height: 1.85;
}

.gallery-text h1,
.gallery-text h2,
.gallery-text h3,
.gallery-text h4 {
    margin: 1em 0 0.5em;
    font-weight: 600;
    line-height: 1.5;
    color: #3d4a57;
}

.gallery-text h1 { font-size: 1.35em; }
.gallery-text h2 { font-size: 1.2em; }
.gallery-text h3 { font-size: 1.08em; }
.gallery-text h4 { font-size: 1em; }

html.dark-mode .gallery-text h1,
html.dark-mode .gallery-text h2,
html.dark-mode .gallery-text h3,
html.dark-mode .gallery-text h4 {
    color: #dde2ea;
}

.gallery-text ul,
.gallery-text ol {
    margin: 0 0 0.6em;
    padding-left: 1.45em;
    line-height: 1.85;
}

.gallery-text li { margin-bottom: 0.18em; }

.gallery-text blockquote {
    margin: 0.7em 0;
    padding: 0.45em 0.95em;
    border-left: 3px solid rgba(var(--accent-rgb), 0.42);
    background: rgba(var(--accent-rgb), 0.05);
    border-radius: 0 8px 8px 0;
    color: #68757f;
}

html.dark-mode .gallery-text blockquote {
    color: #a9b0bb;
    background: rgba(var(--accent-rgb), 0.09);
}

.gallery-text code {
    padding: 0.12em 0.42em;
    border-radius: 5px;
    background: rgba(var(--accent-rgb), 0.10);
    font-family: 'JetBrains Mono', Consolas, monospace;
    font-size: 0.9em;
    color: var(--accent-deep);
}

html.dark-mode .gallery-text code {
    background: rgba(var(--accent-rgb), 0.16);
    color: var(--accent-light);
}

.gallery-text pre {
    margin: 0.7em 0;
    padding: 11px 14px;
    border-radius: 11px;
    background: #282c34;
    overflow-x: auto;
}

.gallery-text pre code {
    padding: 0;
    background: transparent;
    color: #abb2bf;
    font-size: 0.86em;
    line-height: 1.65;
}

.gallery-text a {
    color: var(--accent-deep);
    text-decoration: none;
    border-bottom: 1px solid rgba(var(--accent-rgb), 0.35);
}

.gallery-text a:hover {
    border-bottom-color: var(--accent);
}

html.dark-mode .gallery-text a { color: var(--accent-light); }

.gallery-text hr {
    margin: 1.1em 0;
    border: none;
    border-top: 1px solid rgba(var(--accent-rgb), 0.22);
}

.gallery-text table {
    width: 100%;
    margin: 0.7em 0;
    border-collapse: collapse;
    font-size: 0.93em;
}

.gallery-text th,
.gallery-text td {
    padding: 6px 10px;
    border: 1px solid rgba(var(--accent-rgb), 0.18);
    text-align: left;
}

.gallery-text th {
    background: rgba(var(--accent-rgb), 0.07);
    font-weight: 600;
}

html.dark-mode .gallery-text th {
    background: rgba(var(--accent-rgb), 0.12);
}

.gallery-text img {
    max-width: 100%;
    border-radius: 10px;
    margin: 0.4em 0;
}

.gallery-text strong { font-weight: 600; }

/* 导入按钮（发布面板内） */
.gallery-text-tools {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.gallery-import-md {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    border: 1px solid rgba(var(--accent-rgb), 0.28);
    border-radius: 9px;
    background: rgba(var(--accent-rgb), 0.06);
    color: var(--accent-deep);
    font-size: 12.5px;
    cursor: pointer;
    transition: background 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
}

.gallery-import-md:hover {
    background: rgba(var(--accent-rgb), 0.13);
    transform: translateY(-1px);
}

.gallery-import-md i { font-size: 12px; }

.gallery-text-hint {
    font-size: 11.5px;
    color: #a8b4c0;
}

html.dark-mode .gallery-import-md {
    color: var(--accent-light);
    border-color: rgba(var(--accent-rgb), 0.3);
}

html.dark-mode .gallery-text-hint { color: #78808c; }

/* ==================== 统一布局：媒体区（左）内的九宫格 ==================== */
.gallery-feature-image .gallery-grid {
    margin: 0;
}

/* 多媒体（九宫格）时去掉灰底与圆角（格子自带圆角，灰底会从缝隙透出） */
.gallery-feature-image.is-multi {
    background: transparent;
    border-radius: 0;
}

/* 悬停放大只作用于"直接子图"（避免九宫格里的每张小图都触发） */
.gallery-feature-image:hover > img {
    transform: scale(1.02);
}

/* ==================== A 方案：媒体区滚动跟随（桌面端） ==================== */
/* 文字长时，媒体（图/视频）粘在视口顶部：读完文字之前它始终在场。
   纯 CSS sticky，无脚本计算、零卡顿；移动端保持原来的纵向排列 */
@media (min-width: 769px) {
    .gallery-feature-image {
        position: sticky;
        /* 导航栏滚动时不固定（会滚走），粘住位置贴近视口顶部即可 */
        top: 24px;
    }


    /* 媒体比视口还高时不粘（JS 按实际高度打标，避免底部看不到） */
    .gallery-feature-image.no-sticky {
        position: static;
    }
}

/* ==================== 加载骨架（fetch 数据期间显示，渲染后被替换） ==================== */
.gallery-skeleton {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.sk-card {
    display: flex;
    gap: 18px;
    padding: 17px 19px;
    border-radius: 16px;
    background: rgba(var(--accent-rgb), 0.032);
    border: 1px solid rgba(var(--accent-rgb), 0.10);
}

.sk-img {
    flex: 0 0 55%;
    max-width: 55%;
    aspect-ratio: 3 / 2;
    border-radius: 12px;
}

.sk-lines {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    gap: 13px;
    padding-top: 4px;
    min-width: 0;
}

.sk-lines i {
    display: block;
    height: 13px;
    border-radius: 6px;
}

.sk-lines i:nth-child(1) { width: 38%; }
.sk-lines i:nth-child(2) { width: 94%; }
.sk-lines i:nth-child(3) { width: 76%; }

.sk-img,
.sk-lines i {
    background: linear-gradient(90deg,
        rgba(var(--accent-rgb), 0.055) 25%,
        rgba(var(--accent-rgb), 0.115) 50%,
        rgba(var(--accent-rgb), 0.055) 75%);
    background-size: 220% 100%;
    animation: skShimmer 1.5s ease-in-out infinite;
}

@keyframes skShimmer {
    0% { background-position: 210% 0; }
    100% { background-position: -110% 0; }
}

@media (max-width: 768px) {
    .sk-card { flex-direction: column; }
    .sk-img { flex: 0 0 auto; max-width: 100%; width: 100%; }
}

html.dark-mode .sk-card {
    background: rgba(var(--accent-rgb), 0.055);
    border-color: rgba(var(--accent-rgb), 0.14);
}

/* ==================== 日常页：隐藏页面级元信息 ==================== */
/* 动态流不需要"作者 / 发布于 / 更新于 / 许可协议"这块（文章页照常保留） */
body:has(#gallery-page) .article-licensing {
    display: none !important;
}

/* ==================== 日常页：每条动态的评论区（Twikoo） ==================== */
.gallery-discuss {
    margin-top: 10px;
}

.gallery-discuss-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 2px;
    border: none;
    background: transparent;
    color: #9aa0ab;
    font-size: 13px;
    font-family: inherit;
    cursor: pointer;
    transition: color 0.18s ease;
}

.gallery-discuss-toggle:hover,
.gallery-discuss-toggle.is-open {
    color: var(--accent);
}

.gallery-discuss-toggle i {
    font-size: 13px;
}

.gallery-discuss-box {
    margin-top: 8px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.6);
    border: 1px solid rgba(var(--accent-rgb), 0.14);
    overflow: hidden;
}

/* 评论 iframe：独立环境加载 Twikoo（规避同页多实例冲突）
   就绪前收起透明，就绪后（box.is-ready）淡入 */
.gallery-discuss-frame {
    display: block;
    width: 100%;
    height: 0;
    border: 0;
    background: transparent;
    opacity: 0;
    transition: opacity 0.35s ease;
}

.gallery-discuss-box.is-ready .gallery-discuss-frame {
    height: 320px;          /* 初始高度；随后由 iframe 内脚本上报的内容高度校准 */
    opacity: 1;
}

/* 展开后、内容就绪前的占位骨架 */
.gallery-discuss-skeleton {
    display: block;
    padding: 14px 4px 16px;
}

.gallery-discuss-skeleton i {
    display: block;
    height: 12px;
    margin-bottom: 10px;
    border-radius: 6px;
    background: linear-gradient(90deg,
        rgba(var(--accent-rgb), 0.07) 25%,
        rgba(var(--accent-rgb), 0.15) 50%,
        rgba(var(--accent-rgb), 0.07) 75%);
    background-size: 200% 100%;
    animation: gcShimmer 1.3s ease-in-out infinite;
}

.gallery-discuss-skeleton i:nth-child(1) { width: 42%; }
.gallery-discuss-skeleton i:nth-child(2) { width: 84%; }
.gallery-discuss-skeleton i:nth-child(3) { width: 63%; }

.gallery-discuss-skeleton::after {
    content: '评论加载中…';
    display: block;
    margin-top: 6px;
    font-size: 12px;
    color: #9aa0ab;
}

@keyframes gcShimmer {
    0% { background-position: 160% 0; }
    100% { background-position: -60% 0; }
}

.gallery-discuss-box.is-ready .gallery-discuss-skeleton {
    display: none;
}

html.dark-mode .gallery-discuss-toggle {
    color: #7d8695;
}

html.dark-mode .gallery-discuss-toggle:hover,
html.dark-mode .gallery-discuss-toggle.is-open {
    color: var(--accent-light);
}

html.dark-mode .gallery-discuss-box {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(var(--accent-rgb), 0.2);
}
