
/* 基础样式 */
body {
    font-family: Arial, sans-serif;
    background-color: #e0e5ec;
    margin: 0;
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* 核心布局 */
.neumorphic {
    border-radius: 15px;
    box-shadow: 7px 7px 15px #a3b1c6, -7px -7px 15px #ffffff;
    padding: 15px;
    margin: 10px;
    background: #e0e5ec;
    width: 90%;
    max-width: 800px;
}

/* 帖子内容样式 */
.post-content {
    font-size: 16px;
    color: #333;
    line-height: 1.5;
    padding: 10px;
    white-space: pre-wrap;
    word-wrap: break-word;
    overflow-wrap: break-word;
    max-width: 100%;
}

.preview-modal {
    display: none; /* 初始隐藏 */
    position: fixed; /* 固定定位，相对于浏览器窗口 */
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.7); /* 半透明背景 */
    z-index: 9999; /* 确保在最顶层 */
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(5px); /* 背景模糊 */
}

/* Markdown通用样式 */

.post-content p,
.comment-content p {
    margin: 0.0000000000001em 0; /* 原为 0.3em 0，大幅减小段落间距 */
    line-height: 1.2; /* 稍微减小行高，使多行文本更紧凑 (可选，原为1.5) */
}

.post-content h1, .post-content h2, .post-content h3, .post-content h4,
.comment-content h1, .comment-content h2, .comment-content h3, .comment-content h4 {
    margin: 0.01em 0 0.01em; /* 原为 0.7em 0 0.4em，减小标题上下间距 */
}

.post-content ul, .post-content ol,
.comment-content ul, .comment-content ol {
    margin: 0.00001em 0; /* 原为 0.5em 0，减小列表整体的上下间距 */
    padding-left: 1.2em;
}

.post-content li,
.comment-content li {
    margin: 0; /* 原为 0.2em 0，完全去除列表项之间的垂直间距 */
    padding-left: 0.3em;
    line-height: 1.4; /* 确保列表项内部行高也紧凑 */
}

.post-content blockquote,
.comment-content blockquote {
    border-left: 4px solid #ddd;
    padding: 0.1em 1em;
    color: #555;
    margin: 0.01em 0; /* 原为 0.5em 0，减小引用块间距 */
    background-color: rgba(221, 221, 221, 0.1);
    border-radius: 0 3px 3px 0;
}

.post-content pre, .post-content code,
.comment-content pre, .comment-content code {
    background: #f5f5f5;
    padding: 0.2em 0.4em;
    border-radius: 3px;
    font-family: monospace;
    font-size: 0.95em;
}

.post-content pre,
.comment-content pre {
    padding: 0.6em;
    border-radius: 5px;
    overflow-x: auto;
    margin: 0.01em 0; /* 原为 0.6em 0，减小代码块间距 */
    font-size: 0.9em;
}

/* 媒体通用样式 */
.post-content img, .post-content video,
.comment-content img, .comment-content video {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 0.6em auto;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

/* 按钮样式 */
button, .btn {
    background: #e0e5ec;
    border: none;
    padding: 8px 15px;
    border-radius: 25px;
    font-size: 14px;
    cursor: pointer;
    margin: 5px;
    box-shadow: 5px 5px 10px #a3b1c6, -5px -5px 10px #ffffff;
    transition: all 0.2s ease;
}

button:hover, .btn:hover {
    box-shadow: 3px 3px 6px #a3b1c6, -3px -3px 6px #ffffff;
}

/* 文件展示 */
.file-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    padding: 3px;
    gap: 15px;
    margin-top: 15px;
}

.file-item {
    text-align: center;
    padding: 3px;
    border-radius: 8px;
    background: #e0e5ec;
    box-shadow: 3px 3px 5px #a3b1c6, -3px -3px 5px #ffffff;
    transition: transform 0.2s ease;
}

.file-item:hover {
    transform: translateY(-2px);
}

/* 评论区 */
#comments {
    margin-top: 30px;
    width: 94%;
    max-width: 800px;
}

.comment {
    background: #e0e5ec;
    padding: 10px;
    margin-bottom: 15px;
    border-radius: 10px;
    box-shadow: 5px 5px 10px #a3b1c6, -5px -5px 10px #ffffff;
}

.comment-content {
    margin-bottom: 6px;
    font-size: 14px;
    line-height: 1.5;
}

.comment-info {
    font-size: 12px;
    color: #777;
    margin-bottom: 8px;
}

.comment-actions {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

.comment-actions button {
    font-size: 12px;
    padding: 5px 10px;
}

/* 编辑模式 */
#post-edit-mode {
    display: none;
}

.edit-form {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.edit-form textarea {
    width: 100%;
    min-height: 300px;
    padding: 15px;
    border-radius: 10px;
    background: #e0e5ec;
    box-shadow: inset 7px 7px 10px #a3b1c6, inset -7px -7px 10px #ffffff;
    resize: vertical;
    font-family: monospace;
}

.markdown-preview {
    background: #f5f5f5;
    padding: 15px;
    border-radius: 10px;
    border: 1px solid #ddd;
    min-height: 100px;
    max-height: 300px;
    overflow-y: auto;
}

/* 分页 */
.pagination {
    display: flex;
    justify-content: center;
    margin-top: 20px;
    gap: 10px;
}

.pagination a, .pagination strong {
    display: inline-block;
    padding: 8px 15px;
    background: #e0e5ec;
    border-radius: 15px;
    text-decoration: none;
    color: #333;
    box-shadow: 5px 5px 10px #a3b1c6, -5px -5px 10px #ffffff;
}

.pagination a:hover {
    box-shadow: 3px 3px 6px #a3b1c6, -3px -3px 6px #ffffff;
}

.pagination strong {
    box-shadow: inset 3px 3px 6px #a3b1c6, inset -3px -3px 6px #ffffff;
}

/* 元数据与徽章 */
.post-meta, .comment-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    color: #666;
    margin: 5px 0 15px;
    font-size: 14px;
}

.author-info {
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.badge {
    font-size: 0.8em;
    padding: 3px 8px;
    border-radius: 10px;
    box-shadow: 2px 2px 4px #a3b1c6, -2px -2px 4px #ffffff;
}

.bg-info {
    background-color: #4a69bd;
    color: white;
}

.bg-success {
    background-color: #28a745;
    color: white;
}

.level-badge, .level {
    font-size: 0.9em;
    color: #4a69bd;
    font-weight: bold;
}

/* 链接样式 */
.back-link {
    display: inline-block;
    padding: 10px 20px;
    border-radius: 15px;
    text-decoration: none;
    color: #333;
    font-size: 16px;
    margin-top: 20px;
    box-shadow: 5px 5px 10px #a3b1c6, -5px -5px 10px #ffffff;
}

.username-link {
    text-decoration: none;
    color: #333;
    font-weight: bold;
}

/* 用户提及 */
.user-mention {
    color: #2b6cb0;
    font-weight: bold;
}

/* 消息提示 */
#flash-messages {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
    max-width: 300px;
}

.flash-alert {
    padding: 15px;
    margin-bottom: 10px;
    border-radius: 5px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
    animation: slideIn 0.3s ease-out;
    transition: opacity 0.5s;
    border: 2px solid transparent;
    font-weight: bold;
}

.flash-success {
    background: #d4edda;
    color: #155724;
    border-color: #28a745;
}

.flash-danger {
    background: #f8d7da;
    color: #721c24;
    border-color: #dc3545;
}

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

.error-field {
    border: 2px solid #ff4444 !important;
    box-shadow: 0 0 5px rgba(255, 0, 0, 0.5) !important;
}

/* 举报对话框 */
#report-dialog {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1000;
    padding: 20px;
}

@media (max-width: 768px) {
    /* 确保折叠内容不会溢出 */
    details {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        max-width: 100%;
    }
    
    details > *:not(summary) {
        max-width: 100%;
        box-sizing: border-box;
    }
    
    details pre {
        max-width: 100%;
        overflow-x: auto;
        word-wrap: break-word;
    }
    
    details table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }

    details .post-content li,
    details .comment-content li {
        margin: 0.000001em 0 !important;   /*列表li间距*/
    }
    
    details .post-content blockquote,
    details .comment-content blockquote {
        margin: 0.3em 0 !important;     /* 引用块间距 */
        padding: 0.1em 0.5em !important;    /* 内边距 */
    }
    
    details .post-content blockquote p,
    details .comment-content blockquote p {
        margin: 0.1em 0 !important;   /* 引用块内段落间距 */
    }
}

    /* 折叠内容间距 */
    details .post-content p,
    details .comment-content p {
        margin: 0.2em 0 !important;
        word-wrap: break-word;
        overflow-wrap: break-word;
    }
    
    details .post-content h1, details .post-content h2, details .post-content h3, details .post-content h4,
    details .comment-content h1, details .comment-content h2, details .comment-content h3, details .comment-content h4 {
        margin: 0.4em 0 0.2em !important;
    }
    
    details .post-content ul, details .post-content ol,
    details .comment-content ul, details .comment-content ol {
        margin: 0.3em 0 !important;
        padding-left: 1em !important;
    }
    
    details p, details li, details td {
        word-wrap: break-word;
        overflow-wrap: break-word;
    }

/* 媒体统一正方形样式 */
.media-container {
    position: relative;
    width: 80%;
    margin: 0 auto;
    aspect-ratio: 1/1; /* 正方形比例 */
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.media-container img,
.media-container video {
    width: 100%;
    height: 100%;
    object-fit: contain; /* 保持比例，可能有黑边但不变形 */
}

/* 弹窗样式 */
.media-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    z-index: 2000;
    align-items: center;
    justify-content: center;
}

.modal-content {
    max-width: 90%;
    max-height: 90%;
    position: relative;
}

.modal-content img,
.modal-content video {
    max-width: 100%;
    max-height: 85vh;
    display: block;
}

.close-modal {
    position: absolute;
    top: -40px;
    right: 0;
    color: white;
    font-size: 30px;
    cursor: pointer;
}

/* 电脑端附件文件名重叠显示 */
@media (min-width: 768px) {
    .file-item {
        position: relative;
    }
    
    .file-name {
        position: absolute;
        bottom: 0;
        left: 0;
        right: 0;
        background-color: rgba(0, 0, 0, 0.6);
        color: white;
        padding: 5px;
        font-size: 12px;
        border-radius: 0 0 8px 8px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    
    .media-container .video-play-icon {
        position: absolute;
        width: 60px;
        height: 60px;
        background-color: rgba(0, 0, 0, 0.5);
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
    }
    
    .media-container .video-play-icon::after {
        content: "";
        width: 0;
        height: 0;
        border-style: solid;
        border-width: 15px 0 15px 25px;
        border-color: transparent transparent transparent white;
        margin-left: 5px;
    }
}

/* Markdown插入媒体样式 */
.post-content img, 
.post-content video,
.comment-content img {
    width: 30%;
}
.comment-content video {
    width: 50%;
    aspect-ratio: 1/1;
    object-fit: contain;
    display: block;
    margin: 0.6em auto;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    cursor: pointer;
}

/* 移动端样式 */
@media (max-width: 768px) {
    body { padding: 8px 5px; }
    
    .neumorphic {
        width: 94%;
        margin: 10px 0;
        padding: 12px;
        border-radius: 10px;
    }

    article#post h2 { font-size: 1.1rem; }
    
    /* 强制移动端内容换行防止撑开 */
    .post-content pre, details pre {
        white-space: pre-wrap;
        word-break: break-all;
    }
}