/* ========== 帖子页样式 ========== */



/* 容器布局 */
.posts-container {
    display: flex;
    justify-content: center;
    max-width: 900px;
    margin: 24px auto;
    padding: 0 24px;
    gap: 24px;
    min-height: calc(100vh - 120px);
}

/* 全局盒模型防爆仓 */
.posts-container, .boards-sidebar, .posts-main, .post-card, .modal-container, .selected-users, .search-results {
    box-sizing: border-box !important;
}

/* ========== 左侧板块侧边栏 ========== */
.boards-sidebar {
    width: 260px;
    flex-shrink: 0;
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 20px 0;
    box-shadow: var(--shadow-sm);
    height: fit-content;
    position: sticky;
    top: 24px;
    z-index: 10;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px 16px;
    border-bottom: 1px solid var(--border);
}

.sidebar-header h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 650;
    color: var(--text);
}

.create-board-btn {
    width: 28px;
    height: 28px;
    border-radius: var(--radius-sm);
    background: var(--accent);
    color: white;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
}

.create-board-btn:hover {
    background: var(--accent-hover);
}

.boards-list {
    padding: 12px 8px;
}

.board-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 12px;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: background 0.15s;
    margin-bottom: 4px;
}

.board-item:hover {
    background: var(--surface-2);
}

.board-item.active {
    background: var(--accent-soft);
    border-left: 3px solid var(--accent);
}

.board-icon {
    font-size: 1.2rem;
}

.board-name {
    flex: 1;
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.board-item.active .board-name {
    color: var(--accent);
    font-weight: 600;
}

.board-post-count {
    font-size: 0.75rem;
    color: var(--text-muted);
    background: var(--surface-2);
    padding: 2px 8px;
    border-radius: var(--radius-lg);
}

.sidebar-footer {
    padding: 16px 16px 0;
    border-top: 1px solid var(--border);
    margin-top: 12px;
}

.discover-btn {
    width: 100%;
    padding: 10px;
    background: transparent;
    border: 1px dashed var(--border);
    border-radius: var(--radius-md);
    color: var(--text-muted);
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.15s;
}

.discover-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--surface-2);
}

/* ========== 右侧主内容区 ========== */
.posts-main {
    flex: 1;
    background: transparent;
    border-radius: 0;
    padding: 0;
    box-shadow: none;
    min-width: 0; /* 🚨 刚性：防止 Flex 容器下长文本横向爆仓撑变形 */
}

/* 板块头部 */
.current-board-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
    gap: 12px;
}

.board-info {
    display: flex;
    align-items: baseline;
    gap: 12px;
}

.board-info h2 {
    margin: 0;
    font-size: 1.6rem;
    font-weight: 650;
    color: var(--text);
}

.board-member-count {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.board-actions {
    display: flex;
    gap: 12px;
}

.join-board-btn {
    padding: 10px 20px;
    background: var(--surface);
    border: 1.5px solid var(--accent);
    border-radius: var(--radius-pill);
    color: var(--accent);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}

.join-board-btn:hover {
    background: var(--accent-soft);
}

.new-post-btn {
    padding: 10px 24px;
    background: var(--accent);
    border: none;
    border-radius: var(--radius-pill);
    color: white;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
    white-space: nowrap;
}

.new-post-btn:hover {
    background: var(--accent-hover);
}

/* 工具栏 */
.posts-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    gap: 12px;
}

.sort-tabs {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    scrollbar-width: none;
}
.sort-tabs::-webkit-scrollbar { display: none; }

.sort-tab {
    padding: 8px 18px;
    background: transparent;
    border: none;
    border-radius: var(--radius-pill);
    font-size: 0.9rem;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}

.sort-tab:hover {
    background: var(--surface-2);
}

.sort-tab.active {
    background: #1e293b;
    color: white;
}

.time-filter {
    padding: 8px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
    font-size: 0.9rem;
    color: var(--text);
    background: var(--surface);
    cursor: pointer;
    outline: none;
    -webkit-appearance: none; /* 清除 iOS 默认内阴影 */
}

/* 帖子列表 */
.posts-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
    min-height: 300px;
}

/* 帖子卡片 */
.post-card {
    padding: 20px;
    background: #fafafa;
    border-radius: 16px;
    transition: box-shadow 0.15s, background-color 0.15s;
    cursor: pointer;
}

.post-card:hover {
    box-shadow: var(--shadow-sm);
    background: var(--surface);
}

.post-card.pinned {
    border-left: 3px solid var(--accent);
    background: var(--surface-2);
}

.post-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.post-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--accent, #228be6);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
    font-size: 1rem;
    flex-shrink: 0;
    overflow: hidden;
}

.post-author-info {
    flex: 1;
}

.post-author {
    font-weight: 600;
    color: var(--text);
    margin-bottom: 2px;
}

.post-meta {
    display: flex;
    gap: 12px;
    font-size: 0.75rem;
    color: var(--text-muted);
    flex-wrap: wrap;
}

.post-badge {
    padding: 2px 8px;
    border-radius: var(--radius-lg);
    font-size: 0.7rem;
    font-weight: 500;
    white-space: nowrap;
}

.post-badge.pinned-badge {
    background: var(--accent);
    color: white;
}

.post-badge.locked-badge {
    background: #f59e0b;
    color: white;
}

.post-title {
    font-size: 1.15rem;
    font-weight: 650;
    color: #0f172a;
    margin-bottom: 10px;
    line-height: 1.4;
    word-break: break-word;
}

.post-content-preview {
    color: var(--text-2);
    font-size: 0.9rem;
    line-height: 1.6;
    margin-bottom: 16px;
    display: -webkit-box;
    -webkit-line-clamp: 3;  
    -webkit-box-orient: vertical;
    overflow: hidden;
    word-break: break-word;
}

.post-footer {
    display: flex;
    gap: 24px;
}

.post-stat {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* 空状态 */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-icon {
    font-size: 3rem;
    margin-bottom: 16px;
}

/* 分页器 */
.pagination {
    display: flex;
    justify-content: center;
    gap: 6px;
    margin-top: 32px;
    flex-wrap: wrap;
}

.page-btn {
    min-width: 38px;
    height: 38px;
    padding: 0 10px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text);
    cursor: pointer;
    transition: all 0.15s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.page-btn:hover:not(:disabled) {
    border-color: var(--accent);
    color: var(--accent);
}

.page-btn.active {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}

.page-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* ========== 弹窗样式 ========== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000; /* 高于一切，压在移动端底部菜单上方 */
    backdrop-filter: blur(4px);
    padding: 14px;
}

.modal-container {
    background: var(--surface);
    border-radius: 24px;
    width: 100%;
    max-width: 560px;
    max-height: 85vh;
    overflow: hidden;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.modal-header h3 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 650;
    color: var(--text);
}

.modal-close {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: transparent;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-muted);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover { background: var(--surface-2); }

.modal-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-2);
    margin-bottom: 8px;
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 12px 16px;
    border: 1.5px solid #e2e8f0;
    border-radius: 14px;
    font-size: 0.95rem;
    outline: none;
    transition: border-color 0.15s;
    font-family: inherit;
    box-sizing: border-box;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    border-color: var(--accent);
}

.form-group textarea {
    resize: vertical;
}

/* 用户搜索与可见范围样式加固 */
.user-search-box {
    display: flex;
    gap: 8px;
}

.search-btn {
    padding: 10px 18px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 600;
    white-space: nowrap;
}

.search-results {
    margin-top: 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    max-height: 160px;
    overflow-y: auto;
    background: var(--surface);
    box-shadow: var(--shadow-sm);
}

.search-result-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
}

.selected-users {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    min-height: 40px;
    padding: 10px 14px;
    border: 1.5px solid #e2e8f0;
    border-radius: var(--radius-md);
    background: var(--surface-2);
}

.user-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #e0e7ff;
    color: var(--accent);
    padding: 6px 12px;
    border-radius: var(--radius-lg);
    font-size: 0.85rem;
    font-weight: 500;
}

.form-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 24px;
}

.cancel-btn, .submit-btn {
    padding: 12px 24px;
    border-radius: var(--radius-pill);
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    white-space: nowrap;
}

.cancel-btn {
    background: var(--surface);
    border: 1.5px solid #e2e8f0;
    color: var(--text-muted);
}

.submit-btn {
    background: var(--accent);
    border: none;
    color: white;
}

.submit-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ========== 深色模式适配 ========== */
.dark .boards-sidebar, .dark .modal-container, .dark .search-results { background: #1e293b; }
.dark .sidebar-header h3, .dark .board-name, .dark .board-info h2, .dark .post-author, .dark .post-title { color: #f1f5f9; }
.dark .board-item:hover { background: #334155; }
.dark .board-item.active { background: #1e3a5f; }
.dark .board-post-count { background: #334155; color: var(--text-muted); }
.dark .post-card { background: #0f172a; }
.dark .post-card:hover { background: #1e293b; }
.dark .post-card.pinned { background: #1e3a5f; }
.dark .post-content-preview { color: var(--text-muted); }
.dark .sort-tab.active { background: var(--accent); }
.dark .form-group input, .dark .form-group textarea, .dark .form-group select, .dark .user-search-box input { background: #0f172a; border-color: var(--text-2); color: #f1f5f9; }
.dark .modal-header, .dark .sidebar-header, .dark .current-board-header, .dark .search-result-item { border-bottom-color: var(--text-2); }
.dark .cancel-btn { background: #1e293b; border-color: var(--text-2); color: #e2e8f0; }
.dark .selected-users { background: #0f172a; border-color: var(--text-2); }

/* ========== 📱 移动端自适应黑科技级重构补丁 ========== */
@media (max-width: 768px) {
    .posts-container {
        flex-direction: column;  /* 强行切为纵向单列 */
        padding: 0 12px;
        margin: 12px auto;
        gap: 16px;
    }
    
    /* 🌟【灵魂手术】：电脑端侧边栏在手机端横向解封，秒变横向滚动 Tabs */
    .boards-sidebar {
        width: 100% !important;
        position: static !important; /* 解除固定置顶 */
        padding: 0 !important;
        background: transparent !important; /* 去掉大底色，保持空气感 */
        box-shadow: none !important;
        border-radius: 0;
    }

    /* 隐藏对手机没用的侧边栏头部和页脚，极大地省出首屏空间 */
    .sidebar-header, .sidebar-footer {
        display: none !important;
    }

    /* 将垂直列表激活为单行横向流式滚动 */
    .boards-list {
        display: flex !important;
        flex-direction: row !important;
        gap: 8px !important;
        overflow-x: auto !important;     /* 允许手机指尖无感横向轻刷 */
        padding: 4px 0 12px 0 !important;
        scrollbar-width: none;           /* 抹除火狐滚动条 */
        -webkit-overflow-scrolling: touch;
    }
    .boards-list::-webkit-scrollbar { display: none; } /* 抹除谷歌滚动条 */

    /* 改造单个板块气泡卡片：紧凑横排 */
    .board-item {
        flex-shrink: 0 !important;      /* 强行锁死，不允许被弹性挤压 */
        padding: 8px 16px !important;   /* 缩减间距 */
        background: var(--surface-2);            /* 手机端未激活气泡色 */
        border-radius: var(--radius-pill) !important;  /* 胶囊形状 */
        margin-bottom: 0 !important;
        gap: 6px !important;
    }
    .dark .board-item { background: #0f172a; }

    .board-item.active {
        background: var(--accent) !important; /* 激活时变主蓝色 */
        border-left: none !important;  /* 清除电脑端的左侧竖线 */
    }

    .board-item.active .board-name {
        color: white !important;       /* 激活后文字反白 */
    }
    
    .board-post-count {
        background: rgba(255, 255, 255, 0.25) !important; /* 数量角标在气泡里无感融合 */
        color: inherit !important;
    }

    /* 右侧主贴子流底座填满 */
    .posts-main {
        width: 100% !important;
        padding: 16px;
        border-radius: var(--radius-lg);
    }
    
    /* 当前板块名称区域自适应 */
    .current-board-header {
        flex-direction: row !important; /* 保持横向，防止发帖按钮孤零零掉下去 */
        justify-content: space-between;
        align-items: center;
        margin-bottom: 16px;
        padding-bottom: 12px;
    }
    
    .board-info h2 { font-size: 1.3rem; }
    .join-board-btn { padding: 8px 14px; font-size: 0.85rem; }
    .new-post-btn { padding: 8px 18px; font-size: 0.85rem; }
    
    /* 工具栏单列堆叠 */
    .posts-toolbar {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 12px;
        margin-bottom: 16px;
    }

    .sort-tabs {
        width: 100%;
        padding-bottom: 2px;
    }

    .time-filter {
        width: 100%; /* 让时间选择框在手机上独占整行，放大触控面 */
        text-align: center;
    }

    /* 帖子卡片内间距优化 */
    .post-card { padding: 16px; border-radius: 14px; }
    .post-title { font-size: 1.05rem; margin-bottom: 6px; }
    .post-content-preview { font-size: 0.88rem; margin-bottom: 12px; }
    .post-footer { gap: 18px; }

    /* 弹窗响应式极致防出界 */
    .modal-container {
        max-height: 82vh;
    }
    .modal-body {
        padding: 16px;
    }
    .form-actions {
        margin-top: 16px;
    }

    /* 联动底部常驻底栏防阻挡 */
    body {
        padding-bottom: 85px !important;
    }
}

/* 顶部缓存状态同步条说明 */
.cache-notice-bar {
    padding: 10px 16px;
    margin-bottom: 16px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    display: flex;
    align-items: center;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02);
    box-sizing: border-box;
}

.cache-notice-bar.waiting {
    background-color: #fff9db;
    color: #f59f00;
    border: 1px solid #ffe066;
    animation: pulseNotice 2s infinite ease-in-out;
}

.cache-notice-bar.success {
    background-color: #e6fcf5;
    color: #0ca678;
    border: 1px solid #96f2d7;
}

@keyframes pulseNotice {
    0% { opacity: 0.85; }
    50% { opacity: 1; }
    100% { opacity: 0.85; }
}

/* Minimal page theme */
.posts-container {
    max-width: 1120px;
    gap: 20px;
}

.boards-sidebar,
.modal-container,
.search-results,
.selected-users {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-soft);
}

.boards-sidebar {
    padding: 14px 0;
}

.sidebar-header,
.sidebar-footer,
.current-board-header,
.modal-header,
.search-result-item {
    border-color: var(--border);
}

.sidebar-header h3,
.board-name,
.board-info h2,
.post-author,
.post-title,
.modal-header h3 {
    color: var(--text);
}

.board-member-count,
.board-post-count,
.post-meta,
.post-stat,
.empty-state,
.form-group label,
.no-users-hint {
    color: var(--muted);
}

.board-item,
.post-card,
.time-filter,
.sort-tab,
.page-btn,
.cancel-btn,
.form-group input,
.form-group textarea,
.form-group select {
    background: var(--surface);
    border-color: var(--border);
    color: var(--text);
}

.board-item {
    border-radius: var(--radius-md);
}

.board-item:hover,
.post-card:hover,
.sort-tab:hover,
.modal-close:hover {
    background: var(--surface-2);
}

.board-item.active,
.post-card.pinned {
    background: var(--accent-soft);
    border-left-color: var(--accent);
}

.board-item.active .board-name,
.post-card.pinned .post-title {
    color: var(--accent);
}

.board-post-count,
.selected-users,
.user-tag {
    background: var(--surface-2);
}

.post-card {
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: none;
}

.post-content-preview {
    color: var(--text-soft);
}

.post-badge.pinned-badge,
.search-btn,
.submit-btn,
.new-post-btn,
.create-board-btn,
.page-btn.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #ffffff;
}

.post-badge.locked-badge {
    background: rgba(217, 119, 6, 0.14);
    color: var(--warning);
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus,
.time-filter:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.user-tag {
    color: var(--accent);
    border: 1px solid var(--border);
}

.modal-overlay {
    background: rgba(15, 17, 21, 0.52);
}

@media (max-width: 768px) {
    .boards-sidebar {
        border: 0;
        background: transparent;
        box-shadow: none;
    }

    .board-item {
        background: var(--surface);
        border: 1px solid var(--border);
    }

    .board-item.active {
        background: var(--accent);
        border-color: var(--accent);
    }
}

/* Mobile posts layout repair */
@media (max-width: 768px) {
    .posts-container {
        width: 100%;
        max-width: none;
        margin: 14px auto 0;
        padding: 0 14px;
        overflow-x: hidden;
    }

    .posts-main {
        padding: 16px;
        border-radius: var(--radius-lg);
    }

    .current-board-header {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 14px;
    }

    .board-info {
        display: flex;
        align-items: center;
        justify-content: space-between;
        flex-wrap: wrap;
        gap: 8px;
    }

    .board-info h2 {
        font-size: 1.28rem;
        line-height: 1.35;
    }

    .board-actions {
        width: 100%;
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(118px, 1fr));
        gap: 10px;
    }

    .join-board-btn,
    .new-post-btn {
        width: 100%;
        min-height: 40px;
        padding: 10px 12px;
    }

    .posts-toolbar {
        align-items: stretch !important;
    }

    .filter-options,
    .time-filter {
        width: 100%;
    }

    .post-card {
        margin: 0 !important;
        padding: 16px !important;
    }

    .post-title {
        font-size: 1.05rem;
    }

    .post-footer {
        flex-wrap: wrap;
        gap: 12px;
    }

    .modal-container {
        max-width: calc(100vw - 24px);
        max-height: calc(100dvh - 96px);
        border-radius: var(--radius-lg);
    }

    .modal-body {
        max-height: calc(100dvh - 170px);
    }

    .form-actions {
        display: grid;
        grid-template-columns: 1fr 1fr;
    }

    .cancel-btn,
    .submit-btn {
        width: 100%;
        padding: 12px;
    }
}

/* Markdown editor modal */
.modal-container.editor-modal-container {
    width: min(1400px, 96vw);
    max-width: none;
    height: 90vh;
    max-height: 90vh;
}

.editor-modal-container .modal-header {
    gap: 16px;
}

.editor-header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.preview-toggle-btn {
    min-height: 36px;
    padding: 8px 16px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface-2);
    color: var(--text);
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}

.preview-toggle-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.editor-modal-body {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    max-height: none;
    overflow: hidden;
}

.editor-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 24px;
    flex: 1 1 auto;
    min-height: 0;
}

.editor-layout.preview-closed {
    grid-template-columns: minmax(0, 1fr);
}

.editor-pane,
.preview-pane {
    min-width: 0;
    min-height: 0;
}

.editor-pane {
    display: flex;
    flex-direction: column;
}

.editor-content-group {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    min-height: 0;
    margin-bottom: 0;
}

.editor-content-group textarea {
    flex: 1 1 auto;
    width: 100%;
    height: 100%;
    min-height: 520px;
    resize: none;
    overflow: auto;
    line-height: 1.7;
}

.preview-pane {
    overflow-y: auto;
    padding: 20px;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface-2);
}

.preview-pane.preview-hidden {
    display: none;
}

.preview-document {
    max-width: 900px;
}

.preview-empty {
    color: var(--muted);
}

.mobile-preview-back {
    display: none;
}

/* Markdown rendering */
.markdown-body {
    color: var(--text-soft);
    line-height: 1.75;
    word-break: break-word;
    overflow-wrap: anywhere;
}

.markdown-body > :first-child {
    margin-top: 0;
}

.markdown-body > :last-child {
    margin-bottom: 0;
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4 {
    color: var(--text);
    line-height: 1.35;
    margin: 1.2em 0 0.55em;
}

.markdown-body h1 {
    font-size: 1.75rem;
}

.markdown-body h2 {
    font-size: 1.38rem;
}

.markdown-body h3 {
    font-size: 1.14rem;
}

.markdown-body h4 {
    font-size: 1rem;
}

.markdown-body p {
    margin: 0.75em 0;
}

.markdown-body a {
    color: var(--accent);
    text-decoration: none;
    overflow-wrap: anywhere;
}

.markdown-body a:hover {
    text-decoration: underline;
}

.markdown-body ul,
.markdown-body ol {
    margin: 0.75em 0;
    padding-left: 1.45em;
}

.markdown-body li + li {
    margin-top: 0.25em;
}

.markdown-body blockquote {
    margin: 1em 0;
    padding: 0.1em 0 0.1em 1em;
    border-left: 4px solid var(--accent);
    color: var(--muted);
    background: color-mix(in srgb, var(--accent-soft) 55%, transparent);
}

.markdown-body code {
    padding: 0.15em 0.35em;
    border-radius: 6px;
    background: rgba(15, 23, 42, 0.08);
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
    font-size: 0.92em;
}

.markdown-body pre {
    max-width: 100%;
    margin: 1em 0;
    padding: 14px;
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: #0f172a;
    color: #e2e8f0;
}

.markdown-body pre code {
    padding: 0;
    border-radius: 0;
    background: transparent;
    color: inherit;
    white-space: pre;
}

.markdown-body table {
    display: block;
    width: 100%;
    max-width: 100%;
    margin: 1em 0;
    overflow-x: auto;
    border-collapse: collapse;
}

.markdown-body th,
.markdown-body td {
    padding: 9px 12px;
    border: 1px solid var(--border);
    white-space: nowrap;
}

.markdown-body th {
    background: var(--surface-2);
    color: var(--text);
    font-weight: 650;
}

.markdown-body hr {
    height: 1px;
    margin: 1.5em 0;
    border: 0;
    background: var(--border);
}

.dark .preview-pane {
    background: #0f172a;
}

.dark .markdown-body code {
    background: rgba(226, 232, 240, 0.12);
}

.dark .markdown-body pre {
    border-color: var(--text-2);
    background: #020617;
}

@media (max-width: 768px) {
    .modal-container.editor-modal-container {
        width: 100vw;
        max-width: 100vw;
        height: 100%;
        max-height: 100%;
        border-radius: 0;
        margin: 0;
    }
    .modal-overlay:has(.editor-modal-container) {
        padding: 0;
    }

    .editor-modal-body {
        max-height: none;
        padding: 16px;
        padding-bottom: calc(24px + env(safe-area-inset-bottom));
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .editor-layout {
        display: block;
        min-height: 0;
        flex: 0 0 auto;
    }

    .editor-pane {
        display: block;
    }

    .editor-content-group {
        display: block;
        margin-bottom: 20px;
    }

    .editor-content-group textarea {
        height: 44dvh;
        min-height: 280px;
        max-height: none;
        resize: vertical;
    }

    #postModal .editor-layout {
        margin-bottom: 18px;
    }

    #postModal .editor-modal-body > .form-group {
        padding-top: 4px;
    }

    #postModal #specificUsersArea {
        padding-bottom: 4px;
    }

    .editor-modal-body .form-actions {
        position: sticky;
        bottom: calc(-24px - env(safe-area-inset-bottom, 0px)); 
        margin-bottom: calc(-24px - env(safe-area-inset-bottom, 0px));
        background: var(--card-bg, #fff);
        padding: 16px;
        margin-left: -16px;
        margin-right: -16px;
        margin-top: 18px;
        z-index: 100;
        border-top: 1px solid var(--glass-border, #e2e8f0);
        backdrop-filter: blur(var(--blur-amount, 24px));
    }

    .preview-pane {
        display: none;
    }

    .preview-pane.mobile-preview-open {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 10050;
        padding: 72px 18px 28px;
        border: 0;
        border-radius: 0;
        background: var(--surface);
        overflow-y: auto;
    }

    .preview-pane.mobile-preview-open::before {
        content: none;
        display: none;
    }

    .preview-pane.mobile-preview-open .mobile-preview-back {
        position: fixed;
        top: max(12px, env(safe-area-inset-top));
        left: 16px;
        z-index: 1000;
        display: inline-flex;
        align-items: center;
        min-height: 40px;
        padding: 9px 14px;
        border: 1px solid var(--glass-border, #e2e8f0);
        border-radius: 999px;
        background: var(--card-bg, #fff);
        color: var(--text-primary, #000);
        font-weight: 650;
        box-shadow: var(--shadow-sm, 0 4px 6px -1px rgba(0, 0, 0, 0.4));
    }

    .preview-document {
        max-width: none;
    }

    .markdown-body h1 {
        font-size: 1.45rem;
    }

    .markdown-body h2 {
        font-size: 1.24rem;
    }
}

/* ========== 帖子墙专属样式 ========== */
.posts-wall-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 24px;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.8), rgba(255, 255, 255, 0.5));
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: 24px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.04);
    margin-bottom: 24px;
    gap: 16px;
    box-sizing: border-box;
}

.wall-title-area {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.wall-title {
    margin: 0;
    font-size: 1.8rem;
    font-weight: 800;
    background: linear-gradient(135deg, #1e293b 0%, #3b82f6 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.wall-subtitle {
    margin: 0;
    font-size: 0.95rem;
    color: var(--text-muted);
}

.new-post-btn-pill {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    color: white;
    border: none;
    border-radius: var(--radius-pill);
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(59, 130, 246, 0.2);
    transition: all 0.2s ease;
    white-space: nowrap;
}

.new-post-btn-pill:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(59, 130, 246, 0.3);
}

.new-post-btn-pill:active {
    transform: translateY(0);
}

/* 帖子卡片美化微调 */
.post-card {
    border: 1px solid rgba(0, 0, 0, 0.03);
    border-radius: var(--radius-lg);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.02);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.post-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: rgba(59, 130, 246, 0.1);
}

@media (max-width: 900px) {
    .posts-main,
    .posts-layout,
    .posts-content {
        width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
        border: none !important;
        border-radius: 0 !important;
        box-shadow: none !important;
    }

    .post-card {
        width: 100% !important;
        margin: 0 !important;
        border-radius: 0 !important;
        box-shadow: none !important;
        border-top: none !important;
        border-left: none !important;
        border-right: none !important;
        border-bottom: 1px solid var(--border) !important;
        padding: 14px 16px !important;
        box-sizing: border-box !important;
        background: var(--surface) !important;
    }
}

