/* ============================================================
   社区论坛 - 现代化 UI 样式表 (方案 A：轻量升级)
   ============================================================ */

/* ---------- CSS 变量体系 ---------- */
:root {
    /* 主色调 - 蓝紫渐变 */
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #e0e7ff;
    --primary-gradient: linear-gradient(135deg, #6366f1, #8b5cf6);
    --primary-gradient-hover: linear-gradient(135deg, #4f46e5, #7c3aed);

    /* 辅助色 */
    --accent: #f59e0b;
    --accent-light: #fef3c7;
    --success: #10b981;
    --success-light: #d1fae5;
    --danger: #ef4444;
    --danger-light: #fee2e2;
    --warning: #f59e0b;
    --warning-light: #fef3c7;
    --info: #3b82f6;
    --vip-gradient: linear-gradient(135deg, #f7b733, #fc4a1a);

    /* 中性色 */
    --text: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --bg: #f1f5f9;
    --bg-secondary: #f8fafc;
    --card-bg: #ffffff;
    --border: #e2e8f0;
    --border-light: #f1f5f9;

    /* 阴影 */
    --shadow-xs: 0 1px 2px rgba(0,0,0,0.04);
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --shadow: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -2px rgba(0,0,0,0.05);
    --shadow-md: 0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -4px rgba(0,0,0,0.05);
    --shadow-lg: 0 20px 25px -5px rgba(0,0,0,0.08), 0 8px 10px -6px rgba(0,0,0,0.05);

    /* 圆角 */
    --radius-xs: 6px;
    --radius-sm: 8px;
    --radius: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --radius-full: 9999px;

    /* 间距 */
    --space-xs: 4px;
    --space-sm: 8px;
    --space: 12px;
    --space-md: 16px;
    --space-lg: 20px;
    --space-xl: 24px;
    --space-2xl: 32px;

    /* 过渡 */
    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ---------- 基础重置 ---------- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    /* 锁定页面：禁止过度滚动（橡皮筋）拉出空白 */
    overscroll-behavior: none;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    /* 禁止横向滑动出空白 */
    overflow-x: hidden;
    /* 禁止纵向过度滚动的橡皮筋空白（iOS standalone 主屏模式） */
    overscroll-behavior-y: none;
}

/* standalone 模式（从主屏图标打开）下进一步锁定，彻底消除边界空白 */
@media all and (display-mode: standalone) {
    html, body {
        overscroll-behavior: none;
        overscroll-behavior-y: contain;
    }
}

.container {
    max-width: 480px;
    margin: 0 auto;
    background: var(--card-bg);
    min-height: 100vh;
    position: relative;
    box-shadow: var(--shadow-lg);
}

/* ---------- 头部导航 ---------- */
.header {
    position: fixed;
    top: 0;
    max-width: 480px;
    width: 100%;
    height: 52px;
    /* 顶部避开刘海/状态栏安全区 */
    padding-top: env(safe-area-inset-top, 0);
    height: calc(52px + env(safe-area-inset-top, 0));
    background: rgba(255,255,255,0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding-left: var(--space-md);
    padding-right: var(--space-md);
    z-index: 100;
    transition: background var(--transition), border-color var(--transition);
}

.menu-btn {
    font-size: 22px;
    cursor: pointer;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius);
    transition: background var(--transition);
    color: var(--text);
}

.menu-btn:hover {
    background: var(--bg);
}

.logo {
    flex: 1;
    text-align: center;
    font-size: 17px;
    font-weight: 700;
    letter-spacing: 0.5px;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.user-btn {
    width: 40px;
    height: 40px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.avatar-small {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--border);
    transition: border-color var(--transition), transform var(--transition);
}

.avatar-small:hover {
    border-color: var(--primary);
    transform: scale(1.05);
}

/* ---------- 侧边栏 ---------- */
.sidebar {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 1000;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.sidebar-content {
    position: absolute;
    left: 0;
    top: 0;
    width: 280px;
    height: 100%;
    background: var(--card-bg);
    padding: var(--space-xl);
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    animation: slideIn 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 0 var(--radius-xl) var(--radius-xl) 0;
}

@keyframes slideIn {
    from { transform: translateX(-20px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

.user-info, .guest-info {
    text-align: center;
    padding: var(--space-xl) 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: var(--space);
}

.avatar-large {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    object-fit: cover;
    margin-bottom: var(--space);
    border: 3px solid var(--primary-light);
    box-shadow: var(--shadow);
    transition: transform var(--transition);
}

.avatar-large:hover {
    transform: scale(1.05);
}

.username {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 4px;
    color: var(--text);
}

.gold {
    color: var(--accent);
    font-size: 14px;
    font-weight: 600;
}

.vip-tag {
    display: inline-block;
    background: var(--vip-gradient);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: var(--radius-full);
    margin-left: 6px;
    letter-spacing: 0.5px;
    vertical-align: middle;
    box-shadow: 0 2px 6px rgba(247, 183, 51, 0.3);
}

.sidebar-menu {
    margin-top: var(--space);
}

.menu-item {
    display: flex;
    align-items: center;
    gap: var(--space);
    padding: 14px var(--space-md);
    text-decoration: none;
    color: var(--text);
    border-radius: var(--radius);
    margin-bottom: 2px;
    transition: all var(--transition);
    font-size: 15px;
    font-weight: 500;
}

.menu-item:hover {
    background: var(--primary-light);
    color: var(--primary);
}

.menu-item.admin {
    color: var(--danger);
    font-weight: 600;
}

.menu-item.admin:hover {
    background: var(--danger-light);
}

.menu-item.logout {
    color: var(--text-muted);
}

.menu-item.logout:hover {
    background: var(--bg);
    color: var(--text);
}

/* ---------- 公告 ---------- */
.announcement {
    margin-top: calc(52px + env(safe-area-inset-top, 0));
    padding: 12px 40px 12px var(--space-md);
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: white;
    position: relative;
    font-size: 14px;
    font-weight: 500;
    line-height: 1.4;
}

.announcement-text {
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.close-btn {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 20px;
    cursor: pointer;
    color: white;
    opacity: 0.85;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all var(--transition);
}

.close-btn:hover {
    opacity: 1;
    background: rgba(255,255,255,0.2);
}

/* ---------- 统计 ---------- */
.stats {
    display: flex;
    justify-content: space-around;
    padding: var(--space);
    background: var(--bg-secondary);
    font-size: 14px;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border);
}

/* ---------- 帖子列表 ---------- */
.post-list {
    padding: 0;
}

.post-item {
    background: var(--card-bg);
    border-bottom: 1px solid var(--border-light);
    padding: var(--space-md);
    cursor: pointer;
    transition: all var(--transition);
    position: relative;
}

.post-item:hover {
    background: var(--bg-secondary);
}

.post-item:active {
    transform: scale(0.995);
}

.post-header {
    display: flex;
    align-items: center;
    margin-bottom: var(--space);
}

.avatar-tiny {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
    margin-right: var(--space-sm);
    border: 2px solid var(--border);
}

.post-author {
    font-size: 14px;
    color: var(--text-secondary);
    flex: 1;
    font-weight: 500;
}

.post-time {
    font-size: 12px;
    color: var(--text-muted);
}

.post-title {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: var(--space-sm);
    color: var(--text);
    line-height: 1.4;
}

.post-content-preview {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: var(--space);
    line-height: 1.5;
    word-wrap: break-word;
}

.post-footer {
    display: flex;
    gap: var(--space-md);
    font-size: 13px;
    color: var(--text-muted);
    align-items: center;
}

.post-footer span {
    display: flex;
    align-items: center;
    gap: 3px;
}

.post-price {
    color: var(--accent);
    margin-left: auto;
    font-weight: 600;
}

/* ---------- 分页 ---------- */
.pagination {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    padding: var(--space-xl);
    gap: 6px;
}

.page-btn {
    min-width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    text-decoration: none;
    color: var(--text);
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 500;
    transition: all var(--transition);
    background: var(--card-bg);
}

.page-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-light);
}

.page-btn.active {
    background: var(--primary-gradient);
    color: white;
    border-color: transparent;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}

/* ---------- 登录/注册表单 ---------- */
.form-container {
    padding: var(--space-xl);
    margin-top: calc(52px + env(safe-area-inset-top, 0));
}

.form-title {
    font-size: 24px;
    font-weight: 800;
    margin-bottom: var(--space-2xl);
    text-align: center;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.form-group {
    margin-bottom: var(--space-lg);
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
}

.form-control {
    width: 100%;
    padding: 13px var(--space-md);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    font-size: 15px;
    transition: all var(--transition);
    outline: none;
    background: var(--card-bg);
    color: var(--text);
}

.form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1);
}

.form-control::placeholder {
    color: var(--text-muted);
}

.btn {
    width: 100%;
    padding: 14px;
    background: var(--primary-gradient);
    color: white;
    border: none;
    border-radius: var(--radius);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.25);
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.35);
}

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

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.form-footer {
    margin-top: var(--space-xl);
    text-align: center;
}

.form-footer a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
    transition: color var(--transition);
}

.form-footer a:hover {
    color: var(--primary-dark);
}

/* ---------- 个人中心 ---------- */
.profile-header {
    position: relative;
    height: 200px;
    background-size: cover;
    background-position: center;
    margin-top: calc(52px + env(safe-area-inset-top, 0));
}

.profile-header::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: linear-gradient(transparent, rgba(0,0,0,0.3));
    pointer-events: none;
}

.profile-avatar {
    position: absolute;
    bottom: -40px;
    left: var(--space-lg);
    width: 80px;
    height: 80px;
    border-radius: 50%;
    border: 4px solid white;
    object-fit: cover;
    box-shadow: var(--shadow);
    z-index: 2;
    transition: transform var(--transition);
}

.profile-avatar:hover {
    transform: scale(1.05);
}

.profile-info {
    padding: 50px var(--space-lg) var(--space-lg);
    background: var(--card-bg);
}

.profile-stats {
    display: flex;
    gap: var(--space-xl);
    margin: var(--space-md) 0;
    padding: var(--space-md);
    background: var(--bg-secondary);
    border-radius: var(--radius);
}

.stat-item {
    text-align: center;
    flex: 1;
}

.stat-item.stat-clickable {
    cursor: pointer;
    transition: all var(--transition);
    border-radius: var(--radius-sm);
    padding: var(--space-sm);
}

.stat-item.stat-clickable:hover {
    background: var(--primary-light);
}

.stat-value {
    font-size: 22px;
    font-weight: 800;
    color: var(--primary);
}

.stat-label {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 2px;
}

/* ---------- 发布帖子 ---------- */
.editor-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: var(--space);
    background: var(--bg-secondary);
    border: 2px solid var(--border);
    border-bottom: none;
    border-radius: var(--radius) var(--radius) 0 0;
}

.tool-btn {
    padding: 8px 14px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: all var(--transition);
    color: var(--text-secondary);
}

.tool-btn:hover {
    background: var(--primary-light);
    border-color: var(--primary);
    color: var(--primary);
}

.post-content-editor {
    width: 100%;
    min-height: 200px;
    padding: var(--space-md);
    border: 2px solid var(--border);
    border-top: none;
    border-radius: 0 0 var(--radius) var(--radius);
    font-size: 15px;
    line-height: 1.6;
    resize: vertical;
    outline: none;
    transition: border-color var(--transition);
    font-family: inherit;
    color: var(--text);
}

.post-content-editor:focus {
    border-color: var(--primary);
}

/* ---------- 帖子详情 ---------- */
.post-detail {
    margin-top: calc(52px + env(safe-area-inset-top, 0));
    padding: var(--space-xl);
}

.detail-header {
    margin-bottom: var(--space-xl);
}

.detail-title {
    font-size: 22px;
    font-weight: 800;
    margin: var(--space) 0;
    line-height: 1.4;
    color: var(--text);
}

.detail-meta {
    display: flex;
    align-items: center;
    gap: var(--space);
    color: var(--text-secondary);
    font-size: 14px;
}

.detail-content {
    font-size: 16px;
    line-height: 1.8;
    margin: var(--space-xl) 0;
    word-wrap: break-word;
    color: var(--text);
}

.paid-content {
    background: linear-gradient(135deg, #fff7ed, #fffbeb);
    border: 2px solid var(--accent);
    border-radius: var(--radius-lg);
    padding: var(--space-2xl);
    text-align: center;
    margin: var(--space-xl) 0;
}

.paid-message {
    color: var(--danger);
    font-size: 18px;
    font-weight: 600;
    margin-bottom: var(--space-md);
}

.unlock-btn {
    background: var(--accent);
    color: white;
    border: none;
    padding: 12px 32px;
    border-radius: var(--radius);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    box-shadow: 0 2px 8px rgba(245, 158, 11, 0.3);
}

.unlock-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.4);
}

/* ---------- 评论区 ---------- */
.comments-section {
    margin-top: var(--space-2xl);
}

.comment-item {
    padding: var(--space-md);
    border-bottom: 1px solid var(--border-light);
    transition: background var(--transition);
}

.comment-item:hover {
    background: var(--bg-secondary);
}

.comment-header {
    display: flex;
    align-items: center;
    margin-bottom: var(--space-sm);
    flex-wrap: wrap;
    gap: 6px;
}

.comment-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    margin-right: var(--space);
    object-fit: cover;
    border: 2px solid var(--border);
    cursor: pointer;
    transition: border-color var(--transition);
}

.comment-avatar:hover {
    border-color: var(--primary);
}

.comment-author {
    font-weight: 700;
    font-size: 14px;
    color: var(--text);
    cursor: pointer;
}

.comment-author:hover {
    color: var(--primary);
}

.comment-time {
    font-size: 12px;
    color: var(--text-muted);
}

.comment-content {
    margin-left: 44px;
    font-size: 14px;
    line-height: 1.6;
    word-wrap: break-word;
    color: var(--text);
}

.comment-actions {
    margin-left: 44px;
    margin-top: var(--space-sm);
    font-size: 13px;
    display: flex;
    gap: var(--space-md);
}

.reply-btn {
    color: var(--primary);
    cursor: pointer;
    font-weight: 500;
    transition: color var(--transition);
}

.reply-btn:hover {
    color: var(--primary-dark);
}

.replies-section {
    margin-left: 44px;
    margin-top: var(--space);
    padding-left: var(--space-md);
    border-left: 2px solid var(--primary-light);
}

.reply-item {
    padding: var(--space) 0;
}

.more-replies {
    color: var(--primary);
    cursor: pointer;
    font-size: 13px;
    margin: 6px 0;
    font-weight: 500;
    transition: color var(--transition);
}

.more-replies:hover {
    color: var(--primary-dark);
}

/* ---------- 后台管理 ---------- */
.admin-container {
    margin-top: calc(52px + env(safe-area-inset-top, 0));
    padding: var(--space-xl);
}

.admin-tabs {
    display: flex;
    border-bottom: 2px solid var(--border);
    margin-bottom: var(--space-xl);
    gap: 0;
}

.admin-tab {
    padding: var(--space) var(--space-xl);
    cursor: pointer;
    font-weight: 500;
    color: var(--text-secondary);
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all var(--transition);
}

.admin-tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.admin-tab:hover {
    color: var(--primary);
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
}

.admin-table th,
.admin-table td {
    padding: var(--space) var(--space-md);
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.admin-table th {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ---------- 蓝V认证徽章 ---------- */
.bluev-cert {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    background: linear-gradient(135deg, #1d9bf0, #0ea5e9);
    color: white;
    border-radius: 50%;
    font-size: 11px;
    font-weight: 700;
    font-style: italic;
    margin-left: 4px;
    vertical-align: middle;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(29, 155, 240, 0.35);
    transition: transform var(--transition);
}

.bluev-cert:hover {
    transform: scale(1.2);
}

/* ---------- 作者徽章 ---------- */
.author-badge {
    background: var(--accent);
    color: #fff;
    font-size: 10px;
    padding: 2px 8px;
    border-radius: var(--radius-full);
    font-weight: 600;
    margin-left: 4px;
    white-space: nowrap;
}

/* ---------- Toast 消息 ---------- */
.custom-toast {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(30, 41, 59, 0.9);
    color: white;
    padding: 14px 28px;
    border-radius: var(--radius);
    font-size: 15px;
    z-index: 10000;
    animation: toastInOut 2.2s cubic-bezier(0.4, 0, 0.2, 1);
    max-width: 80%;
    text-align: center;
    box-shadow: var(--shadow-lg);
    backdrop-filter: blur(8px);
    font-weight: 500;
}

.custom-toast.success {
    background: rgba(16, 185, 129, 0.92);
}

.custom-toast.error {
    background: rgba(239, 68, 68, 0.92);
}

.custom-toast.warning {
    background: rgba(245, 158, 11, 0.92);
}

@keyframes toastInOut {
    0% { opacity: 0; transform: translate(-50%, -50%) scale(0.9); }
    10% { opacity: 1; transform: translate(-50%, -50%) scale(1.02); }
    15% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
    80% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
    100% { opacity: 0; transform: translate(-50%, -50%) scale(0.95); }
}

/* ---------- 通用动画 ---------- */
@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* ---------- 响应式 ---------- */
@media (max-width: 480px) {
    .container {
        width: 100%;
    }
}

/* ---------- 安全区适配（刘海屏 / 主屏独立模式）---------- */
/* 主屏独立模式：内容底部留出 Home 指示条空间，避免被遮挡 */
@media all and (display-mode: standalone) {
    .container {
        padding-bottom: env(safe-area-inset-bottom, 0);
    }
}
/* 内容区顶部偏移补偿（header 已含 safe-area-inset-top）*/
.content {
    padding-bottom: env(safe-area-inset-bottom, 0);
}

