/* Markdown内容样式 - 专注于表格和分隔线，并为文章正文提供强制样式 */
/* 增加选择器优先级，用于强制覆盖custom.css */
body .article-content table,
body .markdown-content table {
    width: 100% !important;
    max-width: 100% !important;
    margin: 1.5rem 0 !important;
    border: none !important; /* 移除外边框 */
    border-collapse: collapse !important; /* 改为collapse确保无外边框 */
    border-spacing: 0 !important;
    border-radius: 0 !important; /* 移除圆角 */
    overflow: hidden !important;
    box-shadow: none !important; /* 移除阴影 */
    font-family: var(--font-family-base) !important;
    display: table !important;
}

body .article-content table th,
body .article-content table td,
body .markdown-content table th,
body .markdown-content table td {
    padding: 10px 12px !important;
    border: 1px solid #aaaaaa !important;
    text-align: left !important;
    position: relative !important;
}

body .article-content table th,
body .markdown-content table th {
    background-color: #f5f7fa !important;
    color: #3d4852 !important;
    font-weight: 600 !important;
    border-bottom: 2px solid #aaaaaa !important;
}

body .article-content table tr:nth-child(even),
body .markdown-content table tr:nth-child(even) {
    background-color: #f9fafc !important;
}

body .article-content table tr:nth-child(odd),
body .markdown-content table tr:nth-child(odd) {
    background-color: #ffffff !important;
}

body .article-content table tr:hover,
body .markdown-content table tr:hover {
    background-color: #f0f4f8 !important;
}

/* 处理水平分隔线 */
body .article-content hr,
body .markdown-content hr {
    margin: 20px 0 !important;
    border: 0 !important;
    height: 1px !important;
    background-color: #ddd !important;
    display: block !important;
    clear: both !important;
}

/* 针对暗色模式的样式调整 */
body[data-theme="dark"] .article-content table,
body[data-theme="dark"] .markdown-content table {
    border: none !important;
    box-shadow: none !important;
}

body[data-theme="dark"] .article-content table th,
body[data-theme="dark"] .article-content table td,
body[data-theme="dark"] .markdown-content table th,
body[data-theme="dark"] .markdown-content table td {
    border-color: #666666 !important;
}

body[data-theme="dark"] .article-content table th,
body[data-theme="dark"] .markdown-content table th {
    background-color: #2d3748 !important;
    color: #e5e7eb !important;
    font-weight: bold !important;
}

body[data-theme="dark"] .article-content table tr:nth-child(even),
body[data-theme="dark"] .markdown-content table tr:nth-child(even) {
    background-color: #2d3748 !important;
}

body[data-theme="dark"] .article-content hr,
body[data-theme="dark"] .markdown-content hr {
    background-color: #4b5563 !important;
}

/* 表格增强样式 */
.markdown-table {
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    font-family: var(--font-family-base);
    border: 2px solid #e0e0e0 !important;
}

.markdown-table th {
    font-size: 1em;
    letter-spacing: 0.5px;
    background-color: #f5f7fa !important;
    color: #3d4852 !important;
    border-color: #e0e0e0 !important;
}

.markdown-table td {
    color: #4a5568;
    border-color: #e0e0e0 !important;
}

.markdown-table tr:nth-child(odd) {
    background-color: #ffffff;
}

.markdown-table tr:nth-child(even) {
    background-color: #f9fafc;
}

.markdown-table tr:hover td {
    color: #2d3748;
}

/* 深色模式下表格的特殊样式 */
body[data-theme="dark"] .markdown-table {
    border: 2px solid #4b5563 !important;
    box-shadow: 0 1px 5px rgba(0, 0, 0, 0.4);
}

body[data-theme="dark"] .markdown-table th {
    background-color: #2d3748 !important;
    color: #e5e7eb !important;
    border-color: #4b5563 !important;
}

body[data-theme="dark"] .markdown-table td {
    color: #e5e7eb !important;
    border-color: #4b5563 !important;
}

body[data-theme="dark"] .markdown-table tr:nth-child(even) {
    background-color: #2d3748 !important;
}

body[data-theme="dark"] .markdown-table tr:nth-child(odd) {
    background-color: #374151 !important;
}

/* Markdown内容样式 */
body .markdown-content {
    font-family: var(--font-family-base) !important;
    font-size: 16px !important;
    line-height: 1.8 !important;
    color: #2c3e50 !important;
    text-align: justify !important;
    letter-spacing: 0.02em !important;
    word-spacing: 0.05em !important;
    -webkit-font-smoothing: antialiased !important;
    -moz-osx-font-smoothing: grayscale !important;
    text-rendering: optimizeLegibility !important;
    padding-left: 2rem !important; /* 增加左边距 */
    padding-right: 2rem !important; /* 增加右边距 */
}

/* 确保markdown内容中的所有元素都继承字体 */
body .markdown-content * {
    font-family: inherit !important;
}

/* 标题样式 */
body .markdown-content h1,
body .markdown-content h2,
body .markdown-content h3,
body .markdown-content h4,
body .markdown-content h5,
body .markdown-content h6 {
    font-family: var(--font-family-base) !important;
    font-weight: 600 !important;
    line-height: 1.5 !important;
    margin-top: 2.5rem !important;
    margin-bottom: 1.5rem !important;
    color: #2c3e50 !important;
}

/* 代码样式增强 */
body .article-content code,
body .markdown-content code {
    font-family: var(--font-family-code) !important;
    font-size: 1.0em !important;
    padding: 0.2em 0.4em !important;
    margin: 0 0.2em !important;
    background-color: transparent !important; /* 移除背景色 */
    border-radius: 3px !important;
    color: #476582 !important;
    border: 1px solid #e2e8f0 !important;
}

/* 添加专门针对代码中中文字符的字体设置 */
body .article-content code:lang(zh),
body .markdown-content code:lang(zh),
body .article-content pre code:lang(zh),
body .markdown-content pre code:lang(zh),
body .article-content code:not([lang]),
body .markdown-content code:not([lang]) {
    font-family: var(--font-family-code), "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif !important;
}

/* 确保代码中的中文字符使用无衬线字体 */
body .article-content code *:lang(zh),
body .markdown-content code *:lang(zh),
body .article-content pre code *:lang(zh),
body .markdown-content pre code *:lang(zh) {
    font-family: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif !important;
}

body .article-content pre,
body .markdown-content pre {
    margin: 1.5rem 0 !important;
    padding: 1rem !important;
    background-color: transparent !important; /* 移除背景色 */
    border-radius: 6px !important;
    overflow-x: auto !important;
    position: relative !important;
    border: 1px solid #e2e8f0 !important; /* 添加边框代替背景色 */
}

body .article-content pre code,
body .markdown-content pre code {
    font-family: var(--font-family-code), "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif !important;
    font-size: 1.0em !important;
    padding: 0 !important;
    margin: 0 !important;
    background-color: transparent !important;
    border: none !important;
    color: #333333 !important; /* 更改为深灰色，适合无背景时阅读 */
    display: block !important;
    line-height: 1.6 !important;
    tab-size: 4 !important;
}

/* 段落和列表 */
body .markdown-content p,
body .markdown-content li,
body .article-content p,
body .article-content li,
body .markdown-content ul li,
body .markdown-content ol li,
body .article-content ul li,
body .article-content ol li {
    margin-bottom: 0 !important; /* 修改为0，让行高由line-height控制 */
    line-height: 1.8 !important; /* 确保与正文一致的行高 */
    padding-bottom: 0 !important; /* 确保没有额外的底部内边距 */
    margin-top: 0 !important; /* 确保没有额外的顶部外边距 */
}

body .markdown-content ul,
body .markdown-content ol,
body .article-content ul,
body .article-content ol {
    margin-bottom: 1.5rem !important;
    padding-left: 2rem !important;
    line-height: 1.8 !important; /* 确保与正文一致的行高 */
}

/* 有序列表使用圆圈数字 */
.custom-circle-numbers,
body .markdown-content ol.custom-circle-numbers,
body .article-content ol.custom-circle-numbers {
    list-style-type: none !important;
    counter-reset: item !important;
    padding-left: 2rem !important;
}

.custom-circle-numbers li,
body .markdown-content ol.custom-circle-numbers li,
body .article-content ol.custom-circle-numbers li {
    counter-increment: item !important;
    position: relative !important;
    padding-left: 0.5rem !important;
}

.custom-circle-numbers li::before,
body .markdown-content ol.custom-circle-numbers li::before,
body .article-content ol.custom-circle-numbers li::before {
    position: absolute !important;
    left: -1.5rem !important;
    width: 1.5rem !important;
    text-align: center !important;
    font-family: var(--font-family-base) !important;
    font-weight: normal !important;
}

/* 为不同的序号设置不同的圆圈数字 */
.custom-circle-numbers li:nth-of-type(1)::before,
body .markdown-content ol.custom-circle-numbers li:nth-of-type(1)::before,
body .article-content ol.custom-circle-numbers li:nth-of-type(1)::before {
    content: "①" !important;
}

.custom-circle-numbers li:nth-of-type(2)::before,
body .markdown-content ol.custom-circle-numbers li:nth-of-type(2)::before,
body .article-content ol.custom-circle-numbers li:nth-of-type(2)::before {
    content: "②" !important;
}

.custom-circle-numbers li:nth-of-type(3)::before,
body .markdown-content ol.custom-circle-numbers li:nth-of-type(3)::before,
body .article-content ol.custom-circle-numbers li:nth-of-type(3)::before {
    content: "③" !important;
}

.custom-circle-numbers li:nth-of-type(4)::before,
body .markdown-content ol.custom-circle-numbers li:nth-of-type(4)::before,
body .article-content ol.custom-circle-numbers li:nth-of-type(4)::before {
    content: "④" !important;
}

.custom-circle-numbers li:nth-of-type(5)::before,
body .markdown-content ol.custom-circle-numbers li:nth-of-type(5)::before,
body .article-content ol.custom-circle-numbers li:nth-of-type(5)::before {
    content: "⑤" !important;
}

.custom-circle-numbers li:nth-of-type(6)::before,
body .markdown-content ol.custom-circle-numbers li:nth-of-type(6)::before,
body .article-content ol.custom-circle-numbers li:nth-of-type(6)::before {
    content: "⑥" !important;
}

.custom-circle-numbers li:nth-of-type(7)::before,
body .markdown-content ol.custom-circle-numbers li:nth-of-type(7)::before,
body .article-content ol.custom-circle-numbers li:nth-of-type(7)::before {
    content: "⑦" !important;
}

.custom-circle-numbers li:nth-of-type(8)::before,
body .markdown-content ol.custom-circle-numbers li:nth-of-type(8)::before,
body .article-content ol.custom-circle-numbers li:nth-of-type(8)::before {
    content: "⑧" !important;
}

.custom-circle-numbers li:nth-of-type(9)::before,
body .markdown-content ol.custom-circle-numbers li:nth-of-type(9)::before,
body .article-content ol.custom-circle-numbers li:nth-of-type(9)::before {
    content: "⑨" !important;
}

.custom-circle-numbers li:nth-of-type(10)::before,
body .markdown-content ol.custom-circle-numbers li:nth-of-type(10)::before,
body .article-content ol.custom-circle-numbers li:nth-of-type(10)::before {
    content: "⑩" !important;
}

/* 恢复无序列表样式 */
body .markdown-content ul,
body .article-content ul {
    list-style-type: disc !important; /* 恢复默认圆点样式 */
    padding-left: 2rem !important;
}

body .markdown-content ul li,
body .article-content ul li {
    position: relative !important;
    padding-left: 0 !important; /* 移除额外的内边距 */
}

body .markdown-content li,
body .article-content li {
    margin-bottom: 0 !important; /* 修改为0，由line-height控制间距 */
    line-height: 1.8 !important; /* 确保与正文一致的行高 */
    padding-bottom: 0 !important; /* 确保没有额外的底部内边距 */
}

body .markdown-content li p,
body .article-content li p {
    margin-bottom: 0 !important; /* 修改为0，避免额外的间距 */
    line-height: 1.8 !important; /* 确保与正文一致的行高 */
}

/* 引用块 */
.markdown-content blockquote {
    margin: 1.5rem 0;
    padding: 0.5rem 1.5rem;
    border-left: 4px solid #3a7b99;
    background-color: #f8f8f8;
    color: #666;
    font-style: italic;
}

.markdown-content blockquote p {
    margin-bottom: 0;
}

/* 链接 */
.markdown-content a {
    color: #3a7b99;
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: border-color 0.3s;
}

.markdown-content a:hover {
    border-bottom-color: #3a7b99;
    text-decoration: none;
}

/* 图片样式优化 */
body .article-content img,
body .markdown-content img {
    max-width: 100% !important; /* 确保不会溢出容器 */
    height: auto !important;
    margin: 1rem auto !important;
    display: block !important;
    border-radius: 8px !important; /* 添加圆角 */
    box-shadow: 0 2px 8px rgba(0,0,0,0.1) !important; /* 添加轻微阴影增强效果 */
    transition: transform 0.2s ease, box-shadow 0.2s ease !important; /* 添加过渡效果 */
    box-sizing: border-box !important; /* 确保边框和内边距计入宽度 */
}

/* 图片容器确保不会溢出 */
body .article-content div,
body .markdown-content div {
    max-width: 100% !important;
    overflow: hidden !important;
}

/* 图片悬停效果 */
body .article-content img:hover,
body .markdown-content img:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.15) !important;
    cursor: pointer !important;
}

/* 暗色模式下的图片样式 */
body[data-theme="dark"] .article-content img,
body[data-theme="dark"] .markdown-content img {
    box-shadow: 0 2px 8px rgba(0,0,0,0.2) !important;
}

body[data-theme="dark"] .article-content img:hover,
body[data-theme="dark"] .markdown-content img:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.3) !important;
}

/* 分割线 */
.markdown-content hr {
    margin: 2rem 0;
    border: 0;
    border-top: 1px solid #eaecef;
}

/* 暗色模式适配 */
body[data-theme="dark"] .markdown-content {
    color: #e5e7eb;
}

body[data-theme="dark"] .markdown-content h1,
body[data-theme="dark"] .markdown-content h2,
body[data-theme="dark"] .markdown-content h3,
body[data-theme="dark"] .markdown-content h4,
body[data-theme="dark"] .markdown-content h5,
body[data-theme="dark"] .markdown-content h6 {
    color: #e5e7eb;
}

body[data-theme="dark"] .markdown-content h2 {
    border-bottom-color: #4b5563;
}

body[data-theme="dark"] .markdown-content blockquote {
    background-color: #2d3748;
    border-left-color: #3a7b99;
    color: #9ca3af;
}

body[data-theme="dark"] .markdown-content code {
    background-color: #2d3748;
    border-color: #4b5563;
    color: #9ca3af;
}

body[data-theme="dark"] .markdown-content pre {
    background-color: #1a1d24;
}

body[data-theme="dark"] .markdown-content pre code {
    color: #abb2bf;
}

body[data-theme="dark"] .markdown-content table {
    border-color: #4b5563;
}

body[data-theme="dark"] .markdown-content table th,
body[data-theme="dark"] .markdown-content table td {
    border-color: #4b5563;
    color: #e5e7eb;
}

body[data-theme="dark"] .markdown-content table th {
    background-color: #2d3748;
}

body[data-theme="dark"] .markdown-content table tr:nth-child(even) {
    background-color: #2d3748;
}

body[data-theme="dark"] .markdown-content table tr:hover {
    background-color: #374151;
}

body[data-theme="dark"] .markdown-content hr {
    border-color: #4b5563;
}

/* 移动端适配 */
@media (max-width: 768px) {
    .markdown-content {
        font-size: 15px !important;
    }

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

    .markdown-content h2 {
        font-size: 1.5rem;
    }

    .markdown-content h3 {
        font-size: 1.25rem;
    }

    .markdown-content blockquote {
        margin: 1rem 0;
        padding: 0.5rem 1rem;
    }

    .markdown-content table th,
    .markdown-content table td {
        padding: 0.5rem 0.75rem;
    }
}

/* 代码语法高亮主题 */
.markdown-content .hljs-keyword,
.markdown-content .hljs-selector-tag,
.markdown-content .hljs-title,
.markdown-content .hljs-section,
.markdown-content .hljs-doctag,
.markdown-content .hljs-name,
.markdown-content .hljs-strong {
    color: #c678dd;
}

.markdown-content .hljs-comment {
    color: #5c6370;
    font-style: italic;
}

.markdown-content .hljs-string,
.markdown-content .hljs-title,
.markdown-content .hljs-section,
.markdown-content .hljs-built_in,
.markdown-content .hljs-literal,
.markdown-content .hljs-type,
.markdown-content .hljs-addition,
.markdown-content .hljs-tag,
.markdown-content .hljs-quote,
.markdown-content .hljs-name,
.markdown-content .hljs-selector-id,
.markdown-content .hljs-selector-class {
    color: #98c379;
}

.markdown-content .hljs-meta,
.markdown-content .hljs-subst,
.markdown-content .hljs-symbol,
.markdown-content .hljs-regexp,
.markdown-content .hljs-attribute,
.markdown-content .hljs-deletion,
.markdown-content .hljs-variable,
.markdown-content .hljs-template-variable,
.markdown-content .hljs-link,
.markdown-content .hljs-bullet {
    color: #3a7b99;
}

.markdown-content .hljs-emphasis {
    font-style: italic;
}

/* 最强优先级表格边框样式 - 确保四边灰色边框显示 */
.article-content table,
.markdown-content table,
article table,
.article table,
.post table,
div.article-content > table,
div.markdown-content > table {
    width: 100% !important;
    max-width: 100% !important;
    margin: 1.5rem 0 !important;
    border: none !important; /* 移除外边框 */
    border-collapse: collapse !important; /* 改为collapse确保无外边框 */
    border-spacing: 0 !important;
    border-radius: 0 !important; /* 移除圆角 */
    overflow: hidden !important;
    box-shadow: none !important; /* 移除阴影 */
    font-family: var(--font-family-base) !important;
    display: table !important;
    table-layout: fixed !important; /* 固定表格布局 */
}

/* 确保表格内所有单元格都有边框 */
.article-content table th,
.markdown-content table th,
.article-content table td,
.markdown-content table td,
article table th,
article table td,
.article table th,
.article table td,
.post table th,
.post table td,
div.article-content > table th,
div.article-content > table td,
div.markdown-content > table th,
div.markdown-content > table td {
    border: 1px solid #aaaaaa !important; /* 统一为灰色边框 */
    padding: 10px 12px !important;
    text-align: left !important;
    position: relative !important;
}

/* 暗色模式下的表格边框 */
body[data-theme="dark"] .article-content table,
body[data-theme="dark"] .markdown-content table,
body[data-theme="dark"] article table,
body[data-theme="dark"] .article table,
body[data-theme="dark"] .post table,
body[data-theme="dark"] div.article-content > table,
body[data-theme="dark"] div.markdown-content > table {
    border: none !important;
    box-shadow: none !important;
}

body[data-theme="dark"] .article-content table th,
body[data-theme="dark"] .markdown-content table th,
body[data-theme="dark"] .article-content table td,
body[data-theme="dark"] .markdown-content table td,
body[data-theme="dark"] article table th,
body[data-theme="dark"] article table td,
body[data-theme="dark"] .article table th,
body[data-theme="dark"] .article table td,
body[data-theme="dark"] .post table th,
body[data-theme="dark"] .post table td {
    border-color: #666666 !important;
}

/* 暗色模式下的代码样式 */
body[data-theme="dark"] .article-content code,
body[data-theme="dark"] .markdown-content code {
    background-color: transparent !important; /* 保持透明背景 */
    border-color: #4b5563 !important;
    color: #e2e8f0 !important;
}

/* 单行代码块(内联代码)在暗色模式下的特殊样式 */
body[data-theme="dark"] .article-content code:not(pre code),
body[data-theme="dark"] .markdown-content code:not(pre code) {
    background-color: #2d3748 !important; /* 暗色模式下单行代码的背景色 */
    color: #fef08a !important; /* 暗色模式下代码文本颜色 */
    border: 1px solid #4b5563 !important;
    /* 为中文设置特殊字体，英文保持编程字体 */
    font-family: "JetBrains Mono", "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace, "Noto Serif SC", "Source Han Serif SC", "Source Han Serif CN", -apple-system, "PingFang SC", "Microsoft YaHei" !important;
    font-size: 1.0em !important; /* 统一字体大小与浅色模式一致 */
    font-weight: 500 !important; /* 适当加粗 */
    letter-spacing: 0.01em !important; /* 增加字母间距 */
}

/* 专门为内联代码中的中文字符设置字体 */
body[data-theme="dark"] .article-content code:not(pre code):lang(zh),
body[data-theme="dark"] .markdown-content code:not(pre code):lang(zh),
body[data-theme="dark"] .article-content code:not(pre code) :lang(zh),
body[data-theme="dark"] .markdown-content code:not(pre code) :lang(zh) {
    font-family: "Noto Serif SC", "Source Han Serif SC", "Source Han Serif CN", -apple-system, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Helvetica, Arial, sans-serif !important;
}

body[data-theme="dark"] .article-content pre,
body[data-theme="dark"] .markdown-content pre {
    border-color: #4b5563 !important;
    background-color: transparent !important;
}

/* 添加回代码块内代码的样式 */
body[data-theme="dark"] .article-content pre code,
body[data-theme="dark"] .markdown-content pre code {
    font-family: var(--font-family-code), "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif !important;
    color: #e1e1e1 !important;
    background-color: transparent !important; /* 确保代码块内的代码背景保持透明 */
    border: none !important; /* 确保代码块内的代码没有边框 */
}

/* 同样为浅色模式的内联代码中文设置字体 */
body .article-content code:not(pre code):lang(zh),
body .markdown-content code:not(pre code):lang(zh),
body .article-content code:not(pre code) :lang(zh),
body .markdown-content code:not(pre code) :lang(zh) {
    font-family: "Noto Serif SC", "Source Han Serif SC", "Source Han Serif CN", -apple-system, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Helvetica, Arial, sans-serif !important;
}