/*
Theme Name: Moments
Theme URI: https://acrr.cn
Author: 且赴之
Author URI: https://acrr.cn
Description: 微信朋友圈风格 WordPress 主题
Version: 2.1.0
License: GPL v2 or later
Text Domain: moments
*/

:root {
    --bg-body: #e2e2e2;
    --bg-app: #EDEDED;
    --bg-white: #FFFFFF;
    --bg-card: #F7F7F7;
    --bg-overlay: rgba(0,0,0,0.5);
    --text-main: #191919;
    --text-sub: #B2B2B2;
    --text-link: #576B95;
    --border-line: rgba(0,0,0,0.05);
    --border-radius: 8px;
    --avatar-size: 42px;
    --safe-bottom: env(safe-area-inset-bottom);
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);
    --shadow-xl: 0 -4px 20px rgba(0,0,0,0.15);
    --t-fast: 0.15s ease;
    --t-base: 0.25s cubic-bezier(0.32, 0.72, 0, 1);
    --t-slow: 0.4s cubic-bezier(0.19, 1, 0.22, 1);
}

[data-theme="dark"] {
    --bg-body: #080808;
    --bg-app: #111111;
    --bg-white: #1c1c1c;
    --bg-card: #242424;
    --bg-overlay: rgba(0,0,0,0.7);
    --text-main: #E0E0E0;
    --text-sub: #666666;
    --text-link: #7B8FB5;
    --border-line: rgba(255,255,255,0.06);
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.2);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.3);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.4);
    --shadow-xl: 0 -4px 20px rgba(0,0,0,0.5);
}

*, *::before, *::after { box-sizing: border-box; -webkit-tap-highlight-color: transparent; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
    font-family: var(--site-font, -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif);
    background: radial-gradient(ellipse at 50% 30%, var(--bg-app) 0%, var(--bg-body) 70%);
    background-attachment: fixed;
    color: var(--text-main);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}
img { max-width: 100%; height: auto; display: block; }
img[loading="lazy"] { opacity: 0; transition: opacity 0.3s ease; }
img[loading="lazy"].loaded, img[loading="lazy"][src] { opacity: 1; }
a { color: var(--text-link); text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }

.app-wrapper { display: flex; justify-content: center; min-height: 100vh; }
.app-container {
    width: 100%;
    max-width: var(--container-width, 480px);
    background: var(--bg-app);
    min-height: 100vh;
    position: relative;
    box-shadow: 0 0 40px rgba(0,0,0,0.4);
    overflow-x: hidden;
}

/* Loading Bar */
.ajax-progress {
    position: fixed;
    top: 0; left: 50%; transform: translateX(-50%);
    width: 100%; max-width: 480px; height: 3px;
    background: transparent; z-index: 9999;
    overflow: hidden; pointer-events: none;
}
.ajax-progress::after {
    content: ''; display: block; width: 30%; height: 100%;
    background: var(--text-link); transform: translateX(-100%);
}
.ajax-progress.loading::after { animation: ajaxBar 0.8s ease-in-out infinite; }
@keyframes ajaxBar {
    0% { transform: translateX(-100%); }
    50% { transform: translateX(150%); }
    100% { transform: translateX(350%); }
}

/* Header */
.profile-header {
    position: relative; height: 260px;
    background-size: cover; background-position: center;
    margin-bottom: 60px;
}
.profile-header::after {
    content: ''; position: absolute; bottom: 0; left: 0; right: 0;
    height: 100px; background: linear-gradient(to bottom, transparent, rgba(0,0,0,0.4)); z-index: 1;
}
.cover-bg {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    background-size: cover; background-position: center;
}
.cover-video {
    position: absolute; top: 0; left: 0;
    width: 100%; height: 100%;
    object-fit: cover; z-index: 0;
}
.user-info-bar {
    position: absolute; bottom: -28px; right: 20px;
    display: flex; align-items: flex-end; gap: 16px; z-index: 10;
}
.user-info-text {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
}
.user-name {
    font-weight: 700; font-size: 20px; color: #fff;
    text-shadow: 0 1px 4px rgba(0,0,0,0.5); letter-spacing: 0.5px;
    text-align: right;
}
.user-bio {
    font-size: 13px; color: rgba(255,255,255,0.9);
    text-shadow: 0 1px 3px rgba(0,0,0,0.4);
    text-align: right;
    max-width: 220px;
    line-height: 1.4;
}
.profile-avatar-lg {
    width: 76px; height: 76px; border-radius: 8px;
    border: 2px solid rgba(255,255,255,0.3); background: var(--bg-white);
    object-fit: cover; box-shadow: var(--shadow-md); flex-shrink: 0;
    position: relative; z-index: 15;
}
.header-actions {
    position: absolute; top: 16px; right: 16px;
    display: flex; gap: 12px; z-index: 20;
}
.header-btn {
    width: 40px; height: 40px; border-radius: 50%;
    background: rgba(0,0,0,0.3); backdrop-filter: blur(10px);
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-size: 20px; transition: background var(--t-fast);
}
.header-btn:hover { background: rgba(0,0,0,0.5); }
.header-btn:active { transform: scale(0.95); }
.theme-toggle .icon-sun { display: none; }
[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
[data-theme="dark"] .theme-toggle .icon-sun { display: block; }

/* Feed */
.moments-feed { padding: 0 18px; padding-bottom: calc(30px + var(--safe-bottom)); }

.moment-item {
    display: flex; padding: 14px 0; position: relative;
    opacity: 0; transform: translateY(20px);
    transition: opacity 0.4s var(--t-base), transform 0.4s var(--t-base);
}
.moment-item.is-visible {
    opacity: 1; transform: translateY(0);
}
.moment-item::after {
    content: ''; position: absolute;
    left: calc(var(--avatar-size) + 12px); right: -18px; bottom: 0;
    height: 1px; background: var(--border-line); transform: scaleY(0.5);
}

.avatar-box {
    width: var(--avatar-size); height: var(--avatar-size);
    margin-right: 12px; flex-shrink: 0;
    position: relative; z-index: 30;
}
.author-bio-inline {
    font-size: 12px;
    color: var(--text-sub);
    line-height: 1.3;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.avatar {
    width: 100%; height: 100%; border-radius: 6px;
    object-fit: cover; display: block; background: var(--bg-card);
}
.content-box { flex: 1; min-width: 0; position: relative; z-index: 5; }

.nickname-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 2px;
}
.nickname {
    color: var(--text-link); font-weight: 600; font-size: 16px;
    line-height: 1.2; cursor: pointer;
}
.author-bio {
    font-size: 12px; color: var(--text-sub);
    margin-bottom: 8px; line-height: 1.4;
}
.post-text {
    font-size: 15px; line-height: 1.55; color: var(--text-main);
    margin-bottom: 4px; word-wrap: break-word;
}
.post-text:empty, .post-text p:empty { display: none !important; }

/* Media Grid */
.media-grid { display: grid; gap: 4px; margin-top: 4px; width: fit-content; }
.media-item {
    background: var(--bg-card); border-radius: 3px;
    cursor: pointer; display: block; object-fit: cover;
    transition: opacity var(--t-fast);
}
.media-item:active { opacity: 0.7; }
.grid-1 .media-item { width: 200px; height: auto; max-height: 280px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-2 .media-item { width: 120px; height: 120px; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-3 .media-item { width: 78px; height: 78px; }
.grid-4 { grid-template-columns: repeat(2, 1fr); }
.grid-4 .media-item { width: 115px; height: 115px; }
.grid-5, .grid-6, .grid-7, .grid-8, .grid-9 { grid-template-columns: repeat(3, 1fr); }
.grid-5 .media-item, .grid-6 .media-item, .grid-7 .media-item, .grid-8 .media-item, .grid-9 .media-item { width: 78px; height: 78px; }

/* Actions */
.meta-info { display: flex; justify-content: space-between; align-items: center; margin-top: 10px; }
.post-time { font-size: 13px; color: var(--text-sub); }
.moment-actions { display: flex; gap: 20px; align-items: center; }
.action-like, .action-comment {
    display: flex; align-items: center; gap: 4px;
    font-size: 13px; color: var(--text-sub); cursor: pointer;
    padding: 4px 8px; border-radius: 12px;
    transition: all var(--t-fast); background: transparent;
}
.action-like:hover, .action-comment:hover { background: var(--bg-card); color: var(--text-link); }
.action-like:active, .action-comment:active { transform: scale(0.95); }
.action-like i, .action-comment i { font-size: 16px; }
.action-like.liked { color: #E64A4A; }

/* Comments inline */
.comments-area {
    background: var(--bg-card); border-radius: 4px;
    margin-top: 8px; padding: 8px 12px; font-size: 14px;
    position: relative; line-height: 1.6; display: none;
}
.comments-area.show { display: block; animation: fadeIn 0.3s ease; }
.comments-area::before {
    content: ''; position: absolute; top: -5px; left: 10px;
    width: 0; height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-bottom: 5px solid var(--bg-card);
}
.comment-item { margin-bottom: 4px; }
.comment-item:last-child { margin-bottom: 0; }
.user-link { color: var(--text-link); font-weight: 500; }
.comment-text { color: var(--text-main); }
.comment-text img.emoji-inline {
    width: 18px; height: 18px; display: inline-block;
    vertical-align: middle; margin: 0 1px;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* Article Card */
.article-inline {
    margin-top: 4px; background: var(--bg-white); border-radius: var(--border-radius);
    overflow: hidden; cursor: pointer; box-shadow: var(--shadow-sm);
    transition: transform var(--t-fast), box-shadow var(--t-fast);
}
.article-inline:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.article-inline:active { transform: scale(0.98); }
.article-cover { width: 100%; height: 170px; object-fit: cover; display: block; }
.article-inline.no-cover { padding: 14px 16px; }
.article-inline.no-cover .article-body { padding: 0; }
.article-body { padding: 14px 16px; }
.article-title { font-size: 17px; font-weight: 700; line-height: 1.4; margin-bottom: 8px; color: var(--text-main); }
.article-excerpt { font-size: 14px; color: #666; line-height: 1.6; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.article-footer { display: flex; justify-content: space-between; align-items: center; margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--border-line); font-size: 12px; color: var(--text-sub); }
.read-more-btn { color: var(--text-link); font-weight: 500; display: flex; align-items: center; gap: 4px; font-size: 13px; }

/* Reading Modal */
.reading-modal {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: var(--bg-white); z-index: 1000;
    display: flex; flex-direction: column;
    transform: translateY(100%); transition: transform var(--t-base);
    will-change: transform;
}
.reading-modal.active { transform: translateY(0); }
.modal-backdrop {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: var(--bg-overlay); z-index: 900;
    opacity: 0; pointer-events: none; transition: opacity 0.3s;
}
.modal-backdrop.active { opacity: 1; pointer-events: auto; }
.reader-header {
    height: 52px; display: flex; align-items: center; justify-content: space-between;
    padding: 0 16px; border-bottom: 1px solid var(--border-line);
    background: rgba(255,255,255,0.95); backdrop-filter: blur(10px);
    flex-shrink: 0; position: sticky; top: 0; z-index: 10;
}
.reader-actions { display: flex; gap: 16px; color: var(--text-main); }
.reader-actions i { font-size: 22px; cursor: pointer; padding: 4px; }
.reader-actions i.liked { color: #E64A4A; }
.close-btn { font-size: 24px; cursor: pointer; color: var(--text-main); padding: 8px; margin: -8px; }
.reader-content { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.reader-scroll { max-width: 680px; margin: 0 auto; padding: 24px 20px calc(40px + var(--safe-bottom)); }
.reader-title { font-size: 24px; font-weight: 700; margin-bottom: 16px; line-height: 1.35; color: var(--text-main); }
.reader-meta { font-size: 14px; color: var(--text-sub); margin-bottom: 32px; display: flex; gap: 10px; align-items: center; }
.reader-meta img { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; }
.reader-body { font-size: 17px; line-height: 1.8; color: var(--text-main); }
.reader-body p { margin-bottom: 20px; text-align: justify; word-break: break-word; }
.reader-body h2, .reader-body h3 { margin: 32px 0 16px; font-weight: 700; }
.reader-body h2 { font-size: 22px; }
.reader-body h3 { font-size: 19px; }
.reader-body ul, .reader-body ol { margin-bottom: 20px; padding-left: 24px; }
.reader-body li { margin-bottom: 8px; }
.reader-body blockquote { border-left: 4px solid var(--text-link); padding-left: 16px; margin: 20px 0; color: var(--text-sub); font-style: italic; }
.reader-img { width: 100%; border-radius: var(--border-radius); margin: 16px 0; display: block; }
.reader-tags { margin-top: 32px; padding-top: 20px; border-top: 1px solid var(--border-line); display: flex; gap: 8px; flex-wrap: wrap; }
.tag { background: var(--bg-card); color: var(--text-sub); padding: 5px 12px; border-radius: 20px; font-size: 13px; }

/* Image Preview */
.image-preview {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.92); z-index: 2000;
    display: flex; align-items: center; justify-content: center;
    opacity: 0; pointer-events: none; transition: opacity 0.3s; padding: 20px;
    will-change: opacity;
}
.image-preview.active { opacity: 1; pointer-events: auto; }
.image-preview img { max-width: 100%; max-height: 85vh; object-fit: contain; border-radius: 4px; transform: scale(0.9); transition: transform 0.3s var(--t-base); }
.image-preview.active img { transform: scale(1); }
.preview-close { position: absolute; top: 20px; right: 20px; color: #fff; font-size: 28px; cursor: pointer; z-index: 10; }
.preview-counter { position: absolute; bottom: 30px; left: 50%; transform: translateX(-50%); color: rgba(255,255,255,0.8); font-size: 14px; background: rgba(0,0,0,0.4); padding: 4px 16px; border-radius: 20px; }

/* Comment Modal */
.comment-modal {
    position: fixed; bottom: 0; left: 50%;
    transform: translateX(-50%) translateY(100%);
    width: 100%; max-width: 480px; height: 75vh;
    background: var(--bg-white); border-radius: 16px 16px 0 0;
    z-index: 1100; display: flex; flex-direction: column;
    transition: transform var(--t-base); box-shadow: var(--shadow-xl);
    will-change: transform;
}
.comment-modal.show { transform: translateX(-50%) translateY(0); }
.comment-modal-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 20px; border-bottom: 1px solid var(--border-line); flex-shrink: 0;
}
.comment-modal-title { font-size: 17px; font-weight: 700; color: var(--text-main); }
.comment-modal-close { font-size: 24px; color: var(--text-sub); cursor: pointer; padding: 4px; }
.comment-modal-body { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 0 20px; }

.comment-empty { text-align: center; padding: 60px 20px; color: var(--text-sub); }
.comment-empty i { font-size: 48px; margin-bottom: 16px; opacity: 0.4; }
.comment-empty p { font-size: 15px; margin-bottom: 8px; }
.comment-empty .sub { font-size: 13px; opacity: 0.7; }

.comment-list { padding: 16px 0; }
.comment-list-item { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border-line); }
.comment-list-item:last-child { border-bottom: none; }
.comment-list-avatar { width: 36px; height: 36px; border-radius: 6px; object-fit: cover; flex-shrink: 0; }
.comment-list-content { flex: 1; }
.comment-list-author { font-size: 14px; font-weight: 600; color: var(--text-link); margin-bottom: 4px; }
.comment-list-text { font-size: 14px; color: var(--text-main); line-height: 1.5; word-break: break-word; }
.comment-list-text img.emoji-inline { width: 20px; height: 20px; display: inline-block; vertical-align: middle; margin: 0 2px; }
.comment-list-time { font-size: 12px; color: var(--text-sub); margin-top: 4px; }

.comment-input-area {
    padding: 12px 20px calc(12px + var(--safe-bottom));
    border-top: 1px solid var(--border-line); background: var(--bg-white); flex-shrink: 0;
}
.comment-input-wrapper { display: flex; gap: 10px; align-items: flex-end; }
.comment-input-wrapper input {
    flex: 1; border: none; background: var(--bg-card); border-radius: 20px;
    padding: 10px 16px; font-size: 15px; outline: none; font-family: inherit; color: var(--text-main);
}
.comment-input-wrapper input::placeholder { color: var(--text-sub); }
.comment-input-wrapper button {
    background: var(--text-link); color: #fff; border: none; border-radius: 16px;
    padding: 10px 20px; font-size: 14px; font-weight: 500; cursor: pointer; white-space: nowrap;
}
.comment-input-wrapper button:disabled { background: var(--text-sub); }

.emoji-toggle { color: var(--text-sub); font-size: 22px; padding: 6px; cursor: pointer; flex-shrink: 0; }
.emoji-toggle:hover { color: var(--text-link); }

.emoji-picker {
    display: none; padding: 12px 0; border-top: 1px solid var(--border-line);
    margin-top: 8px; max-height: 180px; overflow-y: auto; -webkit-overflow-scrolling: touch;
}
.emoji-picker.show { display: block; }
.emoji-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; padding: 4px; }
.emoji-grid img { width: 100%; aspect-ratio: 1; object-fit: contain; cursor: pointer; padding: 4px; border-radius: 8px; transition: transform var(--t-fast), background var(--t-fast); }
.emoji-grid img:hover { background: var(--bg-card); transform: scale(1.15); }
.emoji-grid img:active { transform: scale(0.9); }

/* Friends Modal */
.friends-modal {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    z-index: 1000; display: flex; flex-direction: column;
    transform: translateY(100%); transition: transform var(--t-base); background: var(--bg-app);
}
.friends-modal.active { transform: translateY(0); }
.friends-header { height: 52px; display: flex; align-items: center; justify-content: space-between; padding: 0 16px; border-bottom: 1px solid var(--border-line); background: var(--bg-white); flex-shrink: 0; }
.friends-title { font-size: 18px; font-weight: 700; color: var(--text-main); }
.friends-body { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 16px; }
.friend-group { margin-bottom: 24px; }
.friend-group-title { font-size: 13px; color: var(--text-sub); margin-bottom: 12px; padding-left: 8px; text-transform: uppercase; letter-spacing: 0.5px; }
.friend-item { display: flex; align-items: center; gap: 12px; padding: 10px 8px; border-radius: var(--border-radius); transition: background var(--t-fast); cursor: pointer; }
.friend-item:hover { background: var(--bg-card); }
.friend-avatar { width: 44px; height: 44px; border-radius: 6px; object-fit: cover; background: var(--bg-card); }
.friend-info { flex: 1; }
.friend-name { font-size: 15px; font-weight: 600; color: var(--text-main); margin-bottom: 2px; }
.friend-desc { font-size: 13px; color: var(--text-sub); }
.friend-link { color: var(--text-sub); font-size: 18px; padding: 4px; }

/* Toast */
#toast {
    position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);
    background: rgba(0,0,0,0.8); color: #fff; padding: 12px 24px;
    border-radius: 8px; font-size: 14px; opacity: 0; pointer-events: none;
    transition: opacity 0.3s; z-index: 3000; backdrop-filter: blur(4px);
    max-width: 280px; text-align: center;
}

/* Code Highlight */
pre[class*="language-"] { background: var(--bg-card) !important; border-radius: var(--border-radius); padding: 16px; margin: 16px 0; overflow-x: auto; font-size: 14px; line-height: 1.6; border: 1px solid var(--border-line); max-height: 480px; overflow-y: auto; white-space: pre; word-wrap: normal; word-break: normal; tab-size: 4; }
code[class*="language-"] { font-family: 'SF Mono', 'Fira Code', Consolas, Monaco, monospace; font-size: 14px; }
:not(pre) > code { background: var(--bg-card); padding: 2px 6px; border-radius: 4px; font-size: 0.9em; color: var(--text-link); font-family: 'SF Mono', 'Fira Code', Consolas, Monaco, monospace; }

/* Shortcodes */
/* Alert */
.moments-alert { display: flex; align-items: flex-start; gap: 12px; padding: 14px 16px; border-radius: var(--border-radius); margin: 16px 0; font-size: 14px; line-height: 1.6; background: var(--bg-card); border: 1px solid var(--border-line); }
.moments-alert > i { font-size: 20px; flex-shrink: 0; margin-top: 1px; }
.moments-alert-info { background: rgba(87,107,149,0.08); border-color: rgba(87,107,149,0.2); color: var(--text-main); }
.moments-alert-info > i { color: var(--text-link); }
.moments-alert-success { background: rgba(76,175,80,0.08); border-color: rgba(76,175,80,0.2); color: var(--text-main); }
.moments-alert-success > i { color: #4CAF50; }
.moments-alert-warning { background: rgba(255,152,0,0.08); border-color: rgba(255,152,0,0.2); color: var(--text-main); }
.moments-alert-warning > i { color: #FF9800; }
.moments-alert-error { background: rgba(244,67,54,0.08); border-color: rgba(244,67,54,0.2); color: var(--text-main); }
.moments-alert-error > i { color: #F44336; }

/* Spoiler */
.moments-spoiler { border: 1px solid var(--border-line); border-radius: var(--border-radius); margin: 16px 0; overflow: hidden; }
.moments-spoiler-header { padding: 12px 16px; background: var(--bg-card); cursor: pointer; display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 14px; transition: background var(--t-fast); }
.moments-spoiler-header:hover { background: var(--bg-white); }
.moments-spoiler-header .spoiler-icon { transition: transform var(--t-fast); font-size: 16px; }
.moments-spoiler.open .spoiler-icon { transform: rotate(90deg); }
.moments-spoiler-content { max-height: 0; overflow: hidden; transition: max-height 0.3s var(--t-base), padding 0.3s var(--t-base); padding: 0 16px; font-size: 14px; line-height: 1.6; }
.moments-spoiler.open .moments-spoiler-content { max-height: 2000px; padding: 16px; }

/* Gallery */
.moments-gallery { display: grid; gap: 8px; margin: 16px 0; }
.moments-gallery-2 { grid-template-columns: repeat(2, 1fr); }
.moments-gallery-3 { grid-template-columns: repeat(3, 1fr); }
.moments-gallery-4 { grid-template-columns: repeat(2, 1fr); }
.moments-gallery-item { position: relative; border-radius: 6px; overflow: hidden; cursor: pointer; aspect-ratio: 1; }
.moments-gallery-item img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform 0.3s var(--t-base); }
.moments-gallery-item:hover img { transform: scale(1.05); }
.moments-gallery-overlay { position: absolute; inset: 0; background: rgba(0,0,0,0.3); display: flex; align-items: center; justify-content: center; opacity: 0; transition: opacity 0.3s; }
.moments-gallery-item:hover .moments-gallery-overlay { opacity: 1; }
.moments-gallery-overlay i { color: #fff; font-size: 24px; }

/* Code Block */
.moments-code-block { border-radius: var(--border-radius); overflow: hidden; margin: 16px 0; border: 1px solid var(--border-line); background: var(--bg-card); }
.moments-code-header { display: flex; justify-content: space-between; align-items: center; padding: 8px 14px; background: rgba(0,0,0,0.03); border-bottom: 1px solid var(--border-line); font-size: 12px; }
.moments-code-lang { font-weight: 600; color: var(--text-sub); text-transform: uppercase; letter-spacing: 0.5px; }
.moments-code-copy { font-size: 12px; color: var(--text-link); background: transparent; border: 1px solid var(--border-line); border-radius: 4px; padding: 2px 10px; cursor: pointer; transition: all var(--t-fast); }
.moments-code-copy:hover { background: var(--text-link); color: #fff; border-color: var(--text-link); }
.moments-code-copy.copied { color: #4CAF50; border-color: #4CAF50; }
.moments-code-block pre[class*="language-"] { margin: 0; border: none; border-radius: 0; }

/* Music Player */
.moments-music { display: flex; align-items: center; gap: 14px; padding: 12px 14px; background: var(--bg-card); border-radius: var(--border-radius); margin: 16px 0; border: 1px solid var(--border-line); transition: box-shadow var(--t-fast); }
.moments-music:hover { box-shadow: var(--shadow-md); }
.music-cover { position: relative; width: 56px; height: 56px; flex-shrink: 0; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); border-radius: 50%; overflow: hidden; }
.music-cover img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; display: block; transition: transform 0.6s linear; }
.moments-music.playing .music-cover img { animation: musicRotate 8s linear infinite; }
@keyframes musicRotate { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
.music-play-btn { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(0,0,0,0.35); border-radius: 6px; cursor: pointer; opacity: 0; transition: opacity 0.2s; }
.music-cover:hover .music-play-btn, .moments-music.playing .music-play-btn { opacity: 1; }
.music-play-btn i { color: #fff; font-size: 24px; }
.music-info { flex: 1; min-width: 0; }
.music-title { font-weight: 600; font-size: 14px; color: var(--text-main); margin-bottom: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.music-artist { font-size: 12px; color: var(--text-sub); margin-bottom: 6px; }
.music-progress { height: 3px; background: var(--border-line); border-radius: 2px; overflow: hidden; cursor: pointer; }
.music-progress-bar { height: 100%; width: 0%; background: var(--text-link); border-radius: 2px; transition: width 0.1s linear; }
.music-time { display: flex; justify-content: space-between; font-size: 11px; color: var(--text-sub); margin-top: 4px; }

/* Load More */
.load-more-wrap { text-align: center; padding: 24px 0; }
.load-more-btn { display: inline-flex; align-items: center; gap: 8px; padding: 10px 24px; background: var(--bg-white); color: var(--text-main); border-radius: 24px; font-size: 14px; font-weight: 500; box-shadow: var(--shadow-sm); transition: all var(--t-fast); cursor: pointer; }
.load-more-btn:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.load-more-btn:active { transform: scale(0.96); }
.load-more-btn.loading { opacity: 0.6; pointer-events: none; }
.load-more-btn i { animation: spin 1s linear infinite; display: none; }
.load-more-btn.loading i { display: inline-block; }
@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

/* Back to Top */
.back-to-top {
    position: fixed; bottom: calc(20px + var(--safe-bottom)); right: 20px;
    width: 44px; height: 44px; border-radius: 50%;
    background: var(--bg-white); color: var(--text-main);
    display: flex; align-items: center; justify-content: center;
    font-size: 20px; box-shadow: var(--shadow-md);
    cursor: pointer; opacity: 0; transform: translateY(20px);
    transition: all var(--t-base); z-index: 500; pointer-events: none;
    border: 1px solid var(--border-line);
}
.back-to-top.visible { opacity: 1; transform: translateY(0); pointer-events: auto; }
.back-to-top:active { transform: scale(0.9); }

/* Like Heartbeat */
@keyframes likeHeartbeat {
    0% { transform: scale(1); }
    25% { transform: scale(1.25); }
    50% { transform: scale(0.95); }
    75% { transform: scale(1.15); }
    100% { transform: scale(1); }
}
.action-like.liked i { animation: likeHeartbeat 0.4s var(--t-base); }

/* Toast Slide */
#toast { transform: translate(-50%, -40%); }
#toast.show { transform: translate(-50%, -50%); }

/* Ripple feedback for buttons */
.action-like, .action-comment, .header-btn, .video-play-btn, .music-play-btn {
    position: relative; overflow: hidden;
}
.action-like::after, .action-comment::after, .header-btn::after, .video-play-btn::after, .music-play-btn::after {
    content: ''; position: absolute; inset: 0; background: currentColor; opacity: 0;
    transition: opacity 0.3s; border-radius: inherit; pointer-events: none;
}
.action-like:active::after, .action-comment:active::after, .header-btn:active::after { opacity: 0.08; }
.video-play-btn:active::after, .music-play-btn:active::after { opacity: 0.15; }

/* Skeleton for images */
img[src=""], img:not([src]) { background: linear-gradient(90deg, var(--bg-card) 25%, var(--bg-white) 50%, var(--bg-card) 75%); background-size: 200% 100%; animation: skeletonShine 1.5s infinite; }
@keyframes skeletonShine { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
img.loaded, img[loading="lazy"][src] { animation: none; background: none; }

/* Empty */
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-sub); }
.empty-state i { font-size: 48px; margin-bottom: 16px; opacity: 0.5; }

/* Responsive */
@media (max-width: 480px) {
    /* 基础容器 */
    .app-container { max-width: 100%; }
    html { font-size: 15px; }

    /* 首页头部 */
    .profile-header { height: 200px; margin-bottom: 48px; }
    .user-name { font-size: 17px; }
    .user-bio { font-size: 12px; max-width: 160px; }
    .profile-avatar-lg { width: 64px; height: 64px; }
    .user-info-bar { right: 14px; gap: 10px; }
    .header-actions { top: 12px; right: 12px; gap: 8px; }
    .header-btn { width: 36px; height: 36px; font-size: 18px; }

    /* Feed 列表 */
    .moments-feed { padding: 0 14px; padding-bottom: calc(20px + var(--safe-bottom)); }
    .moment-item { padding: 12px 0; }
    .moment-item::after { left: calc(var(--avatar-size) + 10px); right: -14px; }
    .avatar-box { margin-right: 10px; }
    :root { --avatar-size: 40px; }
    .nickname { font-size: 15px; }
    .author-bio { font-size: 11px; margin-bottom: 6px; }
    .author-bio-inline { max-width: 140px; }
    .post-text { font-size: 14px; line-height: 1.5; }

    /* 媒体网格 - 使用相对宽度 */
    .media-grid { width: 100%; }
    .grid-1 .media-item { width: 100%; max-width: 280px; height: auto; max-height: 240px; }
    .grid-2 .media-item { width: 100%; height: auto; aspect-ratio: 1; }
    .grid-3 .media-item { width: 100%; height: auto; aspect-ratio: 1; }
    .grid-4 .media-item { width: 100%; height: auto; aspect-ratio: 1; }
    .grid-5 .media-item, .grid-6 .media-item, .grid-7 .media-item, .grid-8 .media-item, .grid-9 .media-item { width: 100%; height: auto; aspect-ratio: 1; }

    /* 操作按钮 */
    .moment-actions { gap: 12px; }
    .action-like, .action-comment { font-size: 12px; padding: 3px 6px; }
    .meta-info { margin-top: 8px; }

    /* 文章卡片 */
    .article-inline.no-cover { padding: 12px 14px; }
    .article-body { padding: 12px 14px; }
    .article-title { font-size: 15px; margin-bottom: 6px; }
    .article-excerpt { font-size: 13px; }
    .article-cover { height: 140px; }
    .article-footer { margin-top: 10px; padding-top: 8px; }

    /* 评论弹窗 - 修复发送按钮溢出 */
    .comment-modal { height: 85vh; border-radius: 12px 12px 0 0; }
    .comment-modal-header { padding: 12px 14px; }
    .comment-modal-title { font-size: 15px; }
    .comment-modal-body { padding: 0 14px; }
    .comment-input-area { padding: 10px 12px calc(10px + var(--safe-bottom)); }
    .comment-input-wrapper { gap: 6px; }
    .comment-input-wrapper input { padding: 8px 12px; font-size: 14px; border-radius: 16px; }
    .comment-input-wrapper button { padding: 8px 14px; font-size: 13px; border-radius: 14px; }
    .emoji-toggle { font-size: 18px; padding: 4px; }
    .emoji-grid { gap: 6px; padding: 2px; }
    .emoji-picker { padding: 10px 0; max-height: 160px; }

    /* 阅读弹窗 */
    .reading-modal { border-radius: 0; }
    .reader-header { height: 48px; padding: 0 12px; }
    .reader-scroll { padding: 16px 16px calc(24px + var(--safe-bottom)); }
    .reader-title { font-size: 20px; margin-bottom: 12px; }
    .reader-body { font-size: 16px; line-height: 1.7; }
    .reader-body p { margin-bottom: 16px; }
    .reader-body h2 { font-size: 19px; margin: 24px 0 12px; }
    .reader-body h3 { font-size: 17px; margin: 20px 0 10px; }
    .reader-body ul, .reader-body ol { padding-left: 20px; }
    .reader-meta { margin-bottom: 24px; }

    /* 图片预览 */
    .image-preview { padding: 10px; }
    .preview-close { top: 12px; right: 12px; font-size: 24px; }
    .preview-nav { width: 36px; height: 36px; font-size: 18px; }
    .preview-prev { left: 8px; }
    .preview-next { right: 8px; }
    .preview-counter { font-size: 12px; padding: 3px 12px; }

    /* 视频播放器 */
    .video-controls { gap: 6px; padding: 8px 10px calc(8px + env(safe-area-inset-bottom)); }
    .video-play-btn { width: 48px; height: 48px; font-size: 20px; }
    .video-play { font-size: 16px; }
    .video-time { font-size: 11px; }
    .video-fullscreen { font-size: 16px; }

    /* 音乐播放器 */
    .moments-music { gap: 10px; padding: 10px 12px; }
    .music-cover { width: 48px; height: 48px; }
    .music-title { font-size: 13px; }
    .music-artist { font-size: 11px; margin-bottom: 4px; }
    .music-play-btn i { font-size: 20px; }

    /* 友联弹窗 */
    .friends-header { height: 48px; padding: 0 14px; }
    .friends-body { padding: 12px; }
    .friend-item { padding: 8px 6px; gap: 10px; }
    .friend-avatar { width: 40px; height: 40px; }
    .friend-name { font-size: 14px; }
    .friend-desc { font-size: 12px; }

    /* 代码块 */
    pre[class*="language-"] { padding: 12px; font-size: 13px; max-height: 360px; }
    .moments-code-header { padding: 6px 12px; }

    /* Gallery */
    .moments-gallery { gap: 4px; }
    .moments-gallery-item { border-radius: 4px; }

    /* Toast */
    #toast { font-size: 13px; padding: 10px 18px; max-width: 240px; }

    /* 回到顶部 */
    .back-to-top { width: 40px; height: 40px; font-size: 18px; bottom: calc(12px + var(--safe-bottom)); right: 12px; }

    /* 短代码 */
    .moments-alert { padding: 12px 14px; font-size: 13px; }
    .moments-spoiler-header { padding: 10px 14px; font-size: 13px; }
    .moments-spoiler-content { font-size: 13px; }
    .moments-spoiler.open .moments-spoiler-content { padding: 14px; }

    /* 空状态 */
    .empty-state { padding: 40px 16px; }
    .empty-state i { font-size: 40px; }

    /* Alert Spoiler Gallery 等 */
    .moments-gallery-overlay i { font-size: 20px; }
}

@media (min-width: 768px) { .app-container { max-width: var(--container-width-pc, 520px); border-radius: 12px; margin: 20px 0; min-height: calc(100vh - 40px); } body { align-items: flex-start; } .comment-modal { height: 65vh; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; } }


/* ========== UI 风格切换 ========== */

/* --- UI-2 卡片风 --- */
.ui-style-card .moment-item {
    background: var(--bg-white);
    border-radius: 16px;
    padding: 16px;
    margin-bottom: 12px;
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.3s var(--t-base), transform 0.3s var(--t-base);
}
.ui-style-card .moment-item.is-visible:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}
.ui-style-card .moment-item::after { display: none; }
.ui-style-card .avatar { border-radius: 50%; }
.ui-style-card .profile-avatar-lg { border-radius: 50%; }
.ui-style-card .article-inline { border-radius: 12px; }
.ui-style-card .media-grid .media-item { border-radius: 8px; }
.ui-style-card .article-inline:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }
.ui-style-card .action-like, .ui-style-card .action-comment {
    background: var(--bg-card);
    padding: 6px 12px;
    border-radius: 20px;
}
.ui-style-card .action-like:hover, .ui-style-card .action-comment:hover {
    background: var(--bg-white);
    box-shadow: var(--shadow-sm);
}

/* --- UI-3 极简风 --- */
.ui-style-minimal .moment-item {
    flex-direction: row-reverse;
    padding: 20px 0;
}
.ui-style-minimal .avatar-box {
    margin-right: 0;
    margin-left: 12px;
}
.ui-style-minimal .avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
}
.ui-style-minimal .nickname-wrap {
    justify-content: flex-end;
    text-align: right;
}
.ui-style-minimal .post-text {
    font-size: 16px;
    line-height: 1.7;
    text-align: right;
}
.ui-style-minimal .moment-item::after { display: none; }
.ui-style-minimal .meta-info {
    justify-content: flex-end;
    gap: 16px;
}
.ui-style-minimal .article-inline {
    border-radius: 12px;
}
.ui-style-minimal .article-body { padding: 16px 18px; }
.ui-style-minimal .article-title { font-size: 18px; }
.ui-style-minimal .article-excerpt { font-size: 15px; }
.ui-style-minimal .moments-feed { padding: 0 14px; }
.ui-style-minimal .profile-avatar-lg { border-radius: 50%; }
/* ========== 说说图片更多遮罩 ========== */
.media-item-wrapper { position: relative; }
.media-more-overlay {
    position: absolute; inset: 0; background: rgba(0,0,0,0.45);
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-size: 18px; font-weight: 700; border-radius: 3px;
    pointer-events: none;
}

/* ========== 图片预览灯箱增强 ========== */
.preview-nav {
    position: absolute; top: 50%; transform: translateY(-50%);
    width: 44px; height: 44px; border-radius: 50%;
    background: rgba(255,255,255,0.15); backdrop-filter: blur(4px);
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-size: 22px; cursor: pointer; z-index: 10;
    transition: background 0.2s; user-select: none;
}
.preview-nav:hover { background: rgba(255,255,255,0.3); }
.preview-nav:active { transform: translateY(-50%) scale(0.92); }
.preview-prev { left: 12px; }
.preview-next { right: 12px; }
#previewImg { transition: opacity 0.2s ease, transform 0.3s var(--t-base); }
#previewImg.switching { opacity: 0.5; transform: scale(0.95); }

/* ========== 视频播放器 ========== */
.moments-video-player { position: relative; border-radius: var(--border-radius); overflow: hidden; background: #000; margin: 16px 0; aspect-ratio: 16/9; }
.moments-video-player video { width: 100%; height: 100%; object-fit: cover; display: block; }
.video-overlay { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(0,0,0,0.25); transition: opacity 0.3s; pointer-events: none; }
.moments-video-player.playing .video-overlay { opacity: 0; }
.moments-video-player.paused .video-overlay { opacity: 1; pointer-events: auto; }
.video-play-btn { width: 56px; height: 56px; border-radius: 50%; background: rgba(255,255,255,0.95); display: flex; align-items: center; justify-content: center; color: var(--text-main); font-size: 24px; cursor: pointer; transition: transform 0.2s, opacity 0.2s; pointer-events: auto; }
.video-play-btn:active { transform: scale(0.9); }
.video-controls { position: absolute; bottom: 0; left: 0; right: 0; display: flex; align-items: center; gap: 10px; padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); background: linear-gradient(to top, rgba(0,0,0,0.6), transparent); opacity: 0; transition: opacity 0.3s; }
.moments-video-player:hover .video-controls, .moments-video-player.paused .video-controls { opacity: 1; }
.video-play { color: #fff; font-size: 18px; background: none; border: none; cursor: pointer; padding: 4px; display: flex; align-items: center; justify-content: center; }
.video-progress-wrap { flex: 1; }
.video-progress { height: 4px; background: rgba(255,255,255,0.3); border-radius: 2px; cursor: pointer; position: relative; }
.video-progress-bar { height: 100%; width: 0%; background: #fff; border-radius: 2px; position: relative; transition: width 0.1s linear; }
.video-progress-bar::after { content: ''; position: absolute; right: -5px; top: 50%; transform: translateY(-50%); width: 10px; height: 10px; background: #fff; border-radius: 50%; opacity: 0; transition: opacity 0.2s; }
.video-progress:hover .video-progress-bar::after { opacity: 1; }
.video-time { color: rgba(255,255,255,0.9); font-size: 12px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.video-fullscreen { color: #fff; font-size: 18px; background: none; border: none; cursor: pointer; padding: 4px; display: flex; align-items: center; justify-content: center; }
