/* 
   紧急代码块样式覆盖 - 深色主题
   使用极高优先级确保样式生效
*/

/* 重置所有可能的代码块样式，但排除内层pre.highlight避免双重渲染 */
* .markdown-body .highlight,
* .markdown-body pre,
* .highlight,
* pre:not(.highlight) {
    background-color: #1e1e1e !important;
    background: #1e1e1e !important;
    border: 1px solid #333 !important;
    border-radius: 8px !important;
    padding: 16px !important;
    overflow: auto !important;
    font-size: 14px !important;
    line-height: 1.5 !important;
    font-family: 'JetBrains Mono', 'Fira Code', 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace !important;
    color: #d4d4d4 !important;
}

/* 特殊处理：只给外层div.highlight中的pre应用样式，但排除本身有highlight类的pre */
* .markdown-body .highlight pre:not(.highlight),
* .highlight pre:not(.highlight) {
    background-color: #1e1e1e !important;
    background: #1e1e1e !important;
    border: 1px solid #333 !important;
    border-radius: 8px !important;
    padding: 16px !important;
    overflow: auto !important;
    font-size: 14px !important;
    line-height: 1.5 !important;
    font-family: 'JetBrains Mono', 'Fira Code', 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace !important;
    color: #d4d4d4 !important;
}

/* 强制覆盖代码元素，包括内层pre.highlight中的代码 */
* .markdown-body .highlight pre code,
* .markdown-body pre code,
* .highlight pre code,
* pre code,
* pre.highlight code {
    background-color: transparent !important;
    background: transparent !important;
    color: #d4d4d4 !important;
    border: none !important;
    padding: 0 !important;
    font-family: 'JetBrains Mono', 'Fira Code', 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace !important;
}

/* 行内代码样式 */
* .markdown-body code:not(pre code) {
    background-color: rgba(45, 45, 45, 0.8) !important;
    color: #f92672 !important;
    padding: 2px 6px !important;
    border-radius: 4px !important;
    border: none !important;
    font-family: 'JetBrains Mono', 'Fira Code', monospace !important;
}

/* VS Code 语法高亮颜色 */
.highlight .c, .highlight .c1, .highlight .cm { color: #6A9955 !important; font-style: italic; }
.highlight .s, .highlight .s1, .highlight .s2 { color: #CE9178 !important; }
.highlight .k, .highlight .kd, .highlight .kn { color: #569CD6 !important; }
.highlight .nf { color: #DCDCAA !important; }
.highlight .n, .highlight .nb, .highlight .nx { color: #9CDCFE !important; }
.highlight .m, .highlight .mi, .highlight .mf { color: #B5CEA8 !important; }
.highlight .gp { color: #4EC9B0 !important; font-weight: bold; }

/* 代码块容器设置 */
.highlight {
    position: relative;
}

/* 强制隐藏内层pre.highlight元素 - 最高优先级 */
* pre.highlight,
* pre.highlight *,
html body pre.highlight,
html body pre.highlight *,
.markdown-body pre.highlight,
.markdown-body pre.highlight *,
div.highlight pre.highlight,
.highlight pre.highlight {
    background-color: transparent !important;
    background: transparent !important;
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    padding: 0 !important;
    margin: 0 !important;
    outline: none !important;
    display: block !important;
    width: auto !important;
    height: auto !important;
    max-width: none !important;
    min-width: 0 !important;
    float: none !important;
    clear: none !important;
    position: static !important;
    top: auto !important;
    left: auto !important;
    right: auto !important;
    bottom: auto !important;
    z-index: auto !important;
    opacity: 1 !important;
    transform: none !important;
    transition: none !important;
    animation: none !important;
}

/* 移除内层pre.highlight中的复制按钮 */
pre.highlight .copy-button,
pre.highlight button.copy-button,
.highlight pre.highlight .copy-button,
.highlight pre.highlight button.copy-button {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

/* 修复Rouge代码高亮器的所有span标签问题 */
.highlight code span,
.markdown-body .highlight code span,
pre code span,
code span {
    display: inline !important;
    white-space: normal !important;
    font-size: inherit !important;
    line-height: inherit !important;
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    background: transparent !important;
    vertical-align: baseline !important;
}

/* 特别处理.w span标签 */
.highlight .w,
.markdown-body .highlight .w,
pre .w,
code .w {
    display: inline !important;
    white-space: normal !important;
    font-size: inherit !important;
    line-height: inherit !important;
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    background: transparent !important;
    vertical-align: baseline !important;
}

/* 确保代码块中的空格和换行正确显示 */
.highlight pre,
.markdown-body .highlight pre,
.markdown-body pre {
    white-space: pre !important;
    word-spacing: normal !important;
    letter-spacing: normal !important;
    word-break: normal !important;
    overflow-wrap: normal !important;
    word-wrap: normal !important;
    font-family: 'JetBrains Mono', 'Fira Code', 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace !important;
}

/* 确保代码元素不换行 */
.highlight pre code,
.markdown-body pre code,
pre code {
    white-space: pre !important;
    word-wrap: normal !important;
    word-break: normal !important;
    overflow-wrap: normal !important;
    display: inline !important;
}

/* 特殊处理：保持换行符的正确显示，但移除Rouge插入的额外换行 */
.highlight pre,
.markdown-body .highlight pre,
.markdown-body pre,
pre {
    white-space: pre !important;
    word-wrap: normal !important;
    word-break: normal !important;
    overflow-wrap: normal !important;
    font-family: 'JetBrains Mono', 'Fira Code', 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace !important;
}

/* 移除.w span标签中的换行符 */
.highlight .w,
.markdown-body .highlight .w,
pre .w,
code .w {
    display: inline !important;
    white-space: normal !important;
    font-size: inherit !important;
    line-height: inherit !important;
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    background: transparent !important;
    vertical-align: baseline !important;
}

/* 确保其他span标签不引入额外换行 */
.highlight code span:not(.w),
.markdown-body .highlight code span:not(.w),
pre code span:not(.w),
code span:not(.w) {
    display: inline !important;
    white-space: normal !important;
    font-size: inherit !important;
    line-height: inherit !important;
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    background: transparent !important;
    vertical-align: baseline !important;
}

/* 移除代码块中不必要的伪元素换行 */
.highlight pre code:after,
.markdown-body pre code:after,
pre code:after,
.highlight pre code:before,
.markdown-body pre code:before,
pre code:before {
    content: none !important;
    display: none !important;
}

/* 隐藏导致换行问题的空白字符span标签 */
.highlight .w,
.markdown-body .w {
    display: inline !important;
    visibility: visible !important;
    opacity: 1 !important;
    font-size: inherit !important;
    line-height: inherit !important;
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    background: transparent !important;
}

/* 确保代码块中的内容正确显示 */
.highlight pre,
.markdown-body pre {
    white-space: pre !important;
    word-wrap: normal !important;
    word-break: normal !important;
    overflow-wrap: normal !important;
    font-family: 'JetBrains Mono', 'Fira Code', 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace !important;
}