/* 知识库内容富文本样式 - 基于todo_list项目优化 */

.knowledge-content {
    font-size: 16px;
    line-height: 1.8;
    color: var(--text-primary);
    word-break: break-all;
    overflow-wrap: break-word;
    /* 不在根级初始化计数器，让第一个标题来初始化 */
}

/* 段落样式 */
.knowledge-content p {
    margin: 0.25rem 0;
}

.knowledge-content p:last-child {
    margin-bottom: 0;
}

/* 只包含br标签的元素统一高度为0.5rem，上下边距为0 */
.knowledge-content p:has(> br:only-child),
.knowledge-content h1:has(> br:only-child),
.knowledge-content h2:has(> br:only-child),
.knowledge-content h3:has(> br:only-child),
.knowledge-content h4:has(> br:only-child),
.knowledge-content h5:has(> br:only-child),
.knowledge-content h6:has(> br:only-child),
.knowledge-content div:has(> br:only-child) {
    height: 1rem !important;
    line-height: 1rem !important;
    margin: 0 !important;
    padding: 0 !important;
    min-height: 1rem !important;
    max-height: 1rem !important;
}

@media screen and (max-width: 1023px) {

    /* 只包含br标签的元素统一高度为0.5rem，上下边距为0 */
    .knowledge-content p:has(> br:only-child),
    .knowledge-content h1:has(> br:only-child),
    .knowledge-content h2:has(> br:only-child),
    .knowledge-content h3:has(> br:only-child),
    .knowledge-content h4:has(> br:only-child),
    .knowledge-content h5:has(> br:only-child),
    .knowledge-content h6:has(> br:only-child),
    .knowledge-content div:has(> br:only-child) {
        height: 0.5rem !important;
        line-height: 0.5rem !important;
        margin: 0 !important;
        padding: 0 !important;
        min-height: 0.5rem !important;
        max-height: 0.5rem !important;
    }
}

/* 标题样式 */
.knowledge-content h1,
.knowledge-content h2,
.knowledge-content h3,
.knowledge-content h4,
.knowledge-content h5,
.knowledge-content h6 {
    margin: 0.25rem 0;
    font-weight: 600;
    color: var(--text-primary);
}

/* 标题后面的第一个有序列表只重置一级计数器 */
.knowledge-content h1+ol,
.knowledge-content h2+ol,
.knowledge-content h3+ol,
.knowledge-content h4+ol,
.knowledge-content h5+ol,
.knowledge-content h6+ol,
.knowledge-content h1+*+ol,
.knowledge-content h2+*+ol,
.knowledge-content h3+*+ol,
.knowledge-content h4+*+ol,
.knowledge-content h5+*+ol,
.knowledge-content h6+*+ol {
    counter-reset: level1 !important;
}

.knowledge-content h1:first-child,
.knowledge-content h2:first-child,
.knowledge-content h3:first-child,
.knowledge-content h4:first-child,
.knowledge-content h5:first-child,
.knowledge-content h6:first-child {
    margin-top: 0;
}

.knowledge-content h1 {
    font-size: 2em !important;
}

.knowledge-content h2 {
    font-size: 1.6em !important;
}

.knowledge-content h3 {
    font-size: 1.25em !important;
}

.knowledge-content h4 {
    font-size: 1em !important;
}

.knowledge-content h5 {
    font-size: 0.8em !important;
}

.knowledge-content h6 {
    font-size: 0.65em !important;
}

/* 链接样式 */
.knowledge-content a {
    color: #3b82f6;
    text-decoration: underline;
}

.knowledge-content a:hover {
    color: #2563eb;
}

/* 重置所有列表样式 */
.knowledge-content ol,
.knowledge-content ul {
    list-style: none !important;
    margin: 0 !important;
    padding: 0 !important;
}

/* 新的一级有序列表实现 - 只有h标签后才重置计数器 */

/* 所有一级有序列表项目都增加计数器 */
.knowledge-content li[data-list="ordered"]:not(.ql-indent-1):not(.ql-indent-2):not(.ql-indent-3):not(.ql-indent-4):not(.ql-indent-5) {
    counter-increment: level1;
    /* 每个一级项都重置所有下级计数器 */
    counter-reset: level2 level3 level4 level5 level6;
    display: list-item !important;
    list-style: none !important;
    margin-left: 2em !important;
    margin-bottom: 0.5rem;
    line-height: 1.6;
}

.knowledge-content li[data-list="ordered"]:not(.ql-indent-1):not(.ql-indent-2):not(.ql-indent-3):not(.ql-indent-4):not(.ql-indent-5)::before {
    content: counter(level1) ". ";
    font-weight: inherit;
    margin-left: -1.5em;
    display: inline-block;
    width: 1.5em;
}

/* 标题元素创建新的计数器作用域 */
.knowledge-content h1,
.knowledge-content h2,
.knowledge-content h3,
.knowledge-content h4,
.knowledge-content h5,
.knowledge-content h6 {
    counter-reset: level1;
}

/* 关键修复：强制覆盖浏览器默认的ol计数器重置行为 */
.knowledge-content ol {
    counter-reset: none !important;
}

/* 只有第一个ol才初始化计数器（无h标签场景） */
.knowledge-content ol:first-of-type {
    counter-reset: level1 !important;
}

/* 二级有序列表 - 重置所有下级计数器 */
.knowledge-content li[data-list="ordered"].ql-indent-1 {
    counter-increment: level2;
    counter-reset: level3 level4 level5 level6;
    /* 每个二级项都重置所有下级计数器 */
    display: list-item !important;
    list-style: none !important;
    margin-left: 1em !important;
    margin-bottom: 0.5rem;
    line-height: 1.6;
}

.knowledge-content li[data-list="ordered"].ql-indent-1::before {
    content: counter(level2, lower-alpha) ". ";
    font-weight: inherit;
    margin-left: -2em;
    display: inline-block;
    width: 2em;
}

/* 三级有序列表 - 重置所有下级计数器 */
.knowledge-content li[data-list="ordered"].ql-indent-2 {
    counter-increment: level3;
    counter-reset: level4 level5 level6;
    /* 每个三级项都重置所有下级计数器 */
    display: list-item !important;
    list-style: none !important;
    margin-left: 0em !important;
    margin-bottom: 0.5rem;
    line-height: 1.6;
}

.knowledge-content li[data-list="ordered"].ql-indent-2::before {
    content: counter(level3, lower-roman) ". ";
    font-weight: inherit;
    margin-left: -2em;
    display: inline-block;
    width: 2em;
}

/* 四级有序列表 - 重置所有下级计数器 */
.knowledge-content li[data-list="ordered"].ql-indent-3 {
    counter-increment: level4;
    counter-reset: level5 level6;
    /* 每个四级项都重置所有下级计数器 */
    display: list-item !important;
    list-style: none !important;
    margin-left: 8em !important;
    margin-bottom: 0.5rem;
    line-height: 1.6;
}

.knowledge-content li[data-list="ordered"].ql-indent-3::before {
    content: counter(level4, upper-alpha) ". ";
    font-weight: inherit;
    margin-left: -2em;
    display: inline-block;
    width: 2em;
}

/* 五级有序列表 - 重置六级计数器 */
.knowledge-content li[data-list="ordered"].ql-indent-4 {
    counter-increment: level5;
    counter-reset: level6;
    /* 每个五级项都重置六级计数器 */
    display: list-item !important;
    list-style: none !important;
    margin-left: 10em !important;
    margin-bottom: 0.5rem;
    line-height: 1.6;
}

.knowledge-content li[data-list="ordered"].ql-indent-4::before {
    content: counter(level5) ". ";
    font-weight: inherit;
    margin-left: -2em;
    display: inline-block;
    width: 2em;
}

/* 六级有序列表 */
.knowledge-content li[data-list="ordered"].ql-indent-5 {
    counter-increment: level6;
    display: list-item !important;
    list-style: none !important;
    margin-left: 12em !important;
    margin-bottom: 0.5rem;
    line-height: 1.6;
}

.knowledge-content li[data-list="ordered"].ql-indent-5::before {
    content: counter(level6, lower-alpha) ". ";
    font-weight: inherit;
    margin-left: -2em;
    display: inline-block;
    width: 2em;
}

/* 无序列表样式 - 使用伪元素与有序列表保持一致对齐 */
.knowledge-content li[data-list="bullet"] {
    display: list-item !important;
    list-style: none !important;
    margin-left: 2em !important;
    margin-bottom: 0.5rem;
    line-height: 1.6;
}

.knowledge-content li[data-list="bullet"]::before {
    content: "•";
    font-weight: inherit;
    margin-left: -1.5em;
    display: inline-block;
    width: 1.5em;
}

.knowledge-content li[data-list="bullet"].ql-indent-1 {
    margin-left: 1em !important;
}

.knowledge-content li[data-list="bullet"].ql-indent-1::before {
    content: "◦";
    font-weight: inherit;
    margin-left: -2em;
    display: inline-block;
    width: 2em;
}

.knowledge-content li[data-list="bullet"].ql-indent-2 {
    margin-left: 0em !important;
}

.knowledge-content li[data-list="bullet"].ql-indent-2::before {
    content: "▪";
    font-weight: inherit;
    margin-left: -2em;
    display: inline-block;
    width: 2em;
}

.knowledge-content li[data-list="bullet"].ql-indent-3 {
    margin-left: 8em !important;
}

.knowledge-content li[data-list="bullet"].ql-indent-3::before {
    content: "•";
    font-weight: inherit;
    margin-left: -2em;
    display: inline-block;
    width: 2em;
}

/* 通用列表项样式 */
.knowledge-content li {
    margin-bottom: 0.5rem;
    line-height: 1.6;
}

.knowledge-content li:last-child {
    margin-bottom: 0;
}

.knowledge-content li p {
    margin-bottom: 0.5rem;
}

.knowledge-content li p:last-child {
    margin-bottom: 0;
}

/* 行内代码样式 */
.knowledge-content code {
    background-color: rgba(0, 0, 0, 0.05);
    border-radius: 3px;
    padding: 0.15em 0.25em;
    font-family: monospace;
}

/* 代码块包装器样式 - 外层容器，负责定位复制按钮 */
.knowledge-content .code-block-wrapper {
    position: relative;
    margin: 1rem 0;
    background: #2d3748;
    border-radius: 6px;
    overflow: hidden;
    /* 添加触摸滚动支持 - 确保iPad横屏模式（桌面端布局）下能正常工作 */
    -webkit-overflow-scrolling: touch;
    touch-action: pan-x pan-y;
}

/* 内层滚动容器 - 负责代码内容的滚动 */
.knowledge-content .code-scroll-container {
    overflow-x: auto;
    padding: 0rem;
    /* 添加触摸滚动支持 - 确保iPad横屏模式（桌面端布局）下能正常工作 */
    -webkit-overflow-scrolling: touch;
    touch-action: pan-x pan-y;
}

/* 确保所有可能的代码块容器都具有相对定位和触摸滚动支持 */
.knowledge-content .ql-code-block-container,
.knowledge-content pre {
    position: relative;
    /* 添加触摸滚动支持 - 确保iPad横屏模式（桌面端布局）下能正常工作 */
    -webkit-overflow-scrolling: touch;
    touch-action: pan-x pan-y;
}

.knowledge-content .code-scroll-container::-webkit-scrollbar {
    display: none;
    /* 隐藏滚动条 */
}

/* 可选：为了确保在所有 WebKit 浏览器中都能正常工作 */
.knowledge-content .code-scroll-container {
    -ms-overflow-style: none;
    /* IE 和 Edge */
    scrollbar-width: none;
    /* Firefox */
}

/* 复制按钮样式 - 确保固定在容器右上角 */
.knowledge-content .code-copy-btn {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    padding: 0.4rem 0.6rem;
    font-size: 0.75rem;
    color: #e2e8f0;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    min-height: 28px;
    width: 28px;
    height: 28px;
    z-index: 15;
    /* 提高层级，确保在滚动内容之上 */
    /* 确保复制按钮不会跟随内容滚动 */
    pointer-events: auto;
    /* 确保按钮可点击 */
}

.knowledge-content .code-copy-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.3);
    transform: translateY(-1px);
}

.knowledge-content .code-copy-btn.copied {
    background: rgba(34, 197, 94, 0.8);
    border-color: rgba(34, 197, 94, 1);
    color: white;
}

.knowledge-content .code-copy-btn i {
    font-size: 14px;
}

/* 语言标签样式 */
.knowledge-content .code-language-label {
    position: absolute;
    top: 0.5rem;
    left: 0.5rem;
    background: rgba(0, 0, 0, 0.3);
    color: #e2e8f0;
    padding: 0.2rem 0.5rem;
    border-radius: 3px;
    font-size: 0.7rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    z-index: 5;
}

/* Highlight.js 主题适配 - 覆盖默认主题 */
.knowledge-content .hljs {
    /* background: #1a202c !important; */
    color: #e2e8f0 !important;
}

/* 保持现有的语法高亮颜色定义，但优先级更高 */
.knowledge-content .hljs-keyword,
.knowledge-content .ql-code-block .hljs-keyword,
.knowledge-content .ql-syntax .hljs-keyword {
    color: #a78bfa !important;
    font-weight: 600;
}

.knowledge-content .hljs-string,
.knowledge-content .ql-code-block .hljs-string,
.knowledge-content .ql-syntax .hljs-string {
    color: #34d399 !important;
}

.knowledge-content .hljs-number,
.knowledge-content .ql-code-block .hljs-number,
.knowledge-content .ql-syntax .hljs-number {
    color: #fbbf24 !important;
}

.knowledge-content .hljs-comment,
.knowledge-content .ql-code-block .hljs-comment,
.knowledge-content .ql-syntax .hljs-comment {
    color: #6b7280 !important;
    font-style: italic;
}

.knowledge-content .hljs-function,
.knowledge-content .ql-code-block .hljs-function,
.knowledge-content .ql-syntax .hljs-function {
    color: #60a5fa !important;
}

.knowledge-content .hljs-variable,
.knowledge-content .ql-code-block .hljs-variable,
.knowledge-content .ql-syntax .hljs-variable {
    color: #f87171 !important;
}

.knowledge-content .hljs-tag,
.knowledge-content .ql-code-block .hljs-tag,
.knowledge-content .ql-syntax .hljs-tag {
    color: #fb7185 !important;
}

.knowledge-content .hljs-attr,
.knowledge-content .hljs-attribute,
.knowledge-content .ql-code-block .hljs-attr,
.knowledge-content .ql-syntax .hljs-attr {
    color: #fcd34d !important;
}

/* 额外的highlight.js语法元素 */
.knowledge-content .hljs-built_in,
.knowledge-content .hljs-builtin-name {
    color: #8b5cf6 !important;
}

.knowledge-content .hljs-type,
.knowledge-content .hljs-class {
    color: #f59e0b !important;
}

.knowledge-content .hljs-title,
.knowledge-content .hljs-title.class_,
.knowledge-content .hljs-title.function_ {
    color: #60a5fa !important;
    font-weight: 600;
}

.knowledge-content .hljs-params {
    color: #e2e8f0 !important;
}

.knowledge-content .hljs-meta,
.knowledge-content .hljs-meta-keyword {
    color: #a78bfa !important;
}

.knowledge-content .hljs-doctag {
    color: #34d399 !important;
}

.knowledge-content .hljs-section {
    color: #60a5fa !important;
    font-weight: 600;
}

.knowledge-content .hljs-selector-tag,
.knowledge-content .hljs-selector-id,
.knowledge-content .hljs-selector-class {
    color: #fb7185 !important;
}

.knowledge-content .hljs-regexp,
.knowledge-content .hljs-literal {
    color: #34d399 !important;
}

.knowledge-content .hljs-operator,
.knowledge-content .hljs-punctuation {
    color: #e2e8f0 !important;
}

.knowledge-content .hljs-deletion {
    background: rgba(239, 68, 68, 0.2) !important;
    color: #fca5a5 !important;
}

.knowledge-content .hljs-addition {
    background: rgba(34, 197, 94, 0.2) !important;
    color: #86efac !important;
}

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

.knowledge-content .hljs-strong {
    font-weight: 700;
}

/* 引用样式 - 与摘要样式保持一致，支持连续引用合并 */
.knowledge-content blockquote,
.ql-editor blockquote,
.quill-editor blockquote,
blockquote {
    margin: 0 !important;
    margin-top: 0 !important;
    margin-bottom: 0 !important;
    padding: 1rem;
    background: rgba(156, 163, 175, 0.05);
    border-left: 3px solid #c4c9d0;
    /* var(--primary-color); */
    border-radius: 4px;
    color: var(--text-secondary);
    font-style: italic;
    font-size: 0.875rem;
    line-height: 1.6;
    position: relative;
}

/* 连续的引用块合并样式 */
.knowledge-content blockquote+blockquote {
    margin-top: 0;
    border-top-left-radius: 0;
    border-top-right-radius: 0;
    padding-top: 0.2rem;
}

/* 浏览器支持:has()的情况 */
@supports selector(:has(+ *)) {
    .knowledge-content blockquote:has(+ blockquote) {
        margin-bottom: 0;
        border-bottom-left-radius: 0;
        border-bottom-right-radius: 0;
        padding-bottom: 0.2rem;
    }
}

/* 浏览器不支持:has()的情况，使用JS类名控制 */
.knowledge-content .blockquote-group {
    margin: 0 !important;
    margin-top: 0 !important;
    margin-bottom: 0 !important;
    background: rgba(156, 163, 175, 0.1);
    border-left: 3px solid var(--primary-color);
    border-radius: 4px;
    overflow: hidden;
}

.knowledge-content .blockquote-group blockquote {
    margin: 0;
    border: none;
    background: transparent;
    border-radius: 0;
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
}

.knowledge-content .blockquote-group blockquote+blockquote {
    margin-top: 0;
    padding-top: 0.75rem;
}

/* 支持暗色主题的背景色 */
[data-theme="dark"] .knowledge-content blockquote,
.theme-dark .knowledge-content blockquote {
    background: rgba(75, 85, 99, 0.2);
}

[data-theme="dark"] .knowledge-content .blockquote-group,
.theme-dark .knowledge-content .blockquote-group {
    background: rgba(75, 85, 99, 0.2);
    border-left-color: var(--primary-color);
}

@media (prefers-color-scheme: dark) {
    .knowledge-content blockquote {
        background: rgba(75, 85, 99, 0.2);
    }

    .knowledge-content .blockquote-group {
        background: rgba(75, 85, 99, 0.2);
        border-left-color: c4c9d0;
        /* var(--primary-color); */
    }
}

/* 图片样式 */
.knowledge-content img {
    max-width: 100%;
    height: auto;
    border-radius: 3px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.knowledge-content img:hover {
    opacity: 0.8;
    transform: scale(1.02);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* Quill编辑器特有的代码块样式 */
.knowledge-content .ql-code-block-container {
    margin: 0 !important;
    padding: 0.75rem !important;
    border-radius: 6px;
    overflow: hidden;
    background: #2d3748;
    position: relative;
    /* 添加触摸滚动支持 - 确保iPad横屏模式（桌面端布局）下能正常工作 */
    -webkit-overflow-scrolling: touch;
    touch-action: pan-x pan-y;
}

/* 确保容器内的代码块也能获得高亮样式 */
.knowledge-content .ql-code-block-container .ql-code-block {
    padding: 0.2rem;
    background: transparent;
    /* 使用容器的背景 */
    color: #e2e8f0;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', 'Courier New', monospace;
    font-size: 0.75rem;
    line-height: 1.4;
    white-space: pre !important;
    /* 文本不换行 */
    /* font-weight: lighter; */
    /* 细体 */
    font-style: italic;
    /* 斜体 */
    overflow-x: visible;
    /* 内容区不产生滚动条 */
    border: none;
    margin: 0;
}

.knowledge-content .ql-code-block {
    padding: 0;
    background: transparent;
    color: #e2e8f0;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', 'Courier New', monospace;
    font-size: 0.75rem;
    line-height: 1.4;
    white-space: pre;
    /* 文本不换行 */
    overflow-x: visible;
    border: none;
    margin: 0;
    position: static;
}

/* Quill编辑器的语法高亮支持 */
.knowledge-content .ql-syntax {
    background: #2d3748;
    color: #e2e8f0;
    padding: 1rem;
    padding-right: 3rem;
    /* 为复制按钮留出空间 */
    border-radius: 6px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', 'Courier New', monospace;
    font-size: 0.875rem;
    line-height: 1.4;
    overflow-x: auto;
    white-space: pre;
    margin: 1rem 0;
    position: relative;
    /* 确保复制按钮能正确定位 */
    /* 添加触摸滚动支持 - 确保iPad横屏模式（桌面端布局）下能正常工作 */
    -webkit-overflow-scrolling: touch;
    touch-action: pan-x pan-y;
}

.knowledge-content .code-line-numbers {
    position: absolute;
    left: 0;
    top: 1.2rem;
    bottom: 1.2rem;
    width: 2.5rem;
    background: rgba(0, 0, 0, 0.2);
    border-right: 1px solid rgba(255, 255, 255, 0.1);
    padding: 0 0.5rem;
    font-size: 0.8rem;
    line-height: 1.6;
    color: #9ca3af;
    user-select: none;
}

.knowledge-content .code-with-numbers {
    padding-left: 3.5rem;
}

/* 文本格式化样式 */
.knowledge-content strong,
.knowledge-content b {
    font-weight: 600;
}

.knowledge-content em,
.knowledge-content i {
    font-style: italic;
}

.knowledge-content u {
    text-decoration: underline;
}

.knowledge-content s,
.knowledge-content del {
    text-decoration: line-through;
}

/* Quill颜色样式 */
.knowledge-content .ql-color-red {
    color: #e53e3e;
}

.knowledge-content .ql-color-orange {
    color: #dd6b20;
}

.knowledge-content .ql-color-yellow {
    color: #d69e2e;
}

.knowledge-content .ql-color-green {
    color: #38a169;
}

.knowledge-content .ql-color-blue {
    color: #3182ce;
}

.knowledge-content .ql-color-purple {
    color: #805ad5;
}

/* Quill背景色样式 */
.knowledge-content .ql-bg-red {
    background-color: rgba(229, 62, 62, 0.2) !important;
    padding: 0.15rem 0.3rem !important;
    border-radius: 4px !important;
    display: inline !important;
}

.knowledge-content .ql-bg-orange {
    background-color: rgba(221, 107, 32, 0.2) !important;
    padding: 0.15rem 0.3rem !important;
    border-radius: 4px !important;
    display: inline !important;
}

.knowledge-content .ql-bg-yellow {
    background-color: rgba(214, 158, 46, 0.2) !important;
    padding: 0.15rem 0.3rem !important;
    border-radius: 4px !important;
    display: inline !important;
}

.knowledge-content .ql-bg-green {
    background-color: rgba(56, 161, 105, 0.2) !important;
    padding: 0.15rem 0.3rem !important;
    border-radius: 4px !important;
    display: inline !important;
}

.knowledge-content .ql-bg-blue {
    background-color: rgba(49, 130, 206, 0.2) !important;
    padding: 0.15rem 0.3rem !important;
    border-radius: 4px !important;
    display: inline !important;
}

.knowledge-content .ql-bg-purple {
    background-color: rgba(128, 90, 213, 0.2) !important;
    padding: 0.15rem 0.3rem !important;
    border-radius: 4px !important;
    display: inline !important;
}

/* 表格样式 */
.knowledge-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 1rem 0;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.knowledge-content th,
.knowledge-content td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.knowledge-content th {
    background-color: var(--bg-secondary);
    font-weight: 600;
}

.knowledge-content tr:last-child td {
    border-bottom: none;
}

.knowledge-content tr:hover {
    background-color: var(--bg-hover);
}

/* 分割线样式 */
.knowledge-content hr {
    margin: 2rem 0;
    border: none;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--border-color), transparent);
}

/* 搜索高亮样式 */
.knowledge-content .search-highlight {
    background-color: #fef3c7;
    color: #92400e;
    padding: 0.1rem 0.2rem;
    border-radius: 3px;
    font-weight: 500;
}

/* 字号样式 - 提高优先级 */
.knowledge-content .ql-size-small,
.knowledge-content span.ql-size-small,
.knowledge-content p.ql-size-small {
    font-size: 0.75em !important;
}

.knowledge-content .ql-size-large,
.knowledge-content span.ql-size-large,
.knowledge-content p.ql-size-large {
    font-size: 1.5em !important;
}

.knowledge-content .ql-size-huge,
.knowledge-content span.ql-size-huge,
.knowledge-content p.ql-size-huge {
    font-size: 2.5em !important;
}

/* 对齐方式样式 - 提高优先级 */
.knowledge-content .ql-align-center,
.knowledge-content p.ql-align-center {
    text-align: center !important;
}

.knowledge-content .ql-align-right,
.knowledge-content p.ql-align-right {
    text-align: right !important;
}

.knowledge-content .ql-align-justify,
.knowledge-content p.ql-align-justify {
    text-align: justify !important;
}

/* 缩进样式 */
.knowledge-content .ql-indent-1 {
    padding-left: 3em;
}

.knowledge-content .ql-indent-2 {
    padding-left: 6em;
}

.knowledge-content .ql-indent-3 {
    padding-left: 9em;
}

.knowledge-content .ql-indent-4 {
    padding-left: 12em;
}

.knowledge-content .ql-indent-5 {
    padding-left: 15em;
}

.knowledge-content .ql-indent-6 {
    padding-left: 18em;
}

.knowledge-content .ql-indent-7 {
    padding-left: 21em;
}

.knowledge-content .ql-indent-8 {
    padding-left: 24em;
}

/* 字体样式 */
.knowledge-content .ql-font-serif {
    font-family: Georgia, Times, serif;
}

.knowledge-content .ql-font-monospace {
    font-family: Monaco, Courier, monospace;
}

/* 方向样式 */
.knowledge-content .ql-direction-rtl {
    direction: rtl;
    text-align: inherit;
}

/* 响应式样式 */
@media (max-width: 1023px) {
    .knowledge-content {
        font-size: 14px;
    }

    /* 移动端基础列表样式 */
    /* 移动端列表样式 - 调整缩进距离 */

    /* 一级有序列表移动端样式 */
    .knowledge-content li[data-list="ordered"]:not(.ql-indent-1):not(.ql-indent-2):not(.ql-indent-3):not(.ql-indent-4):not(.ql-indent-5) {
        margin-left: 1.5em !important;
    }

    .knowledge-content li[data-list="ordered"]:not(.ql-indent-1):not(.ql-indent-2):not(.ql-indent-3):not(.ql-indent-4):not(.ql-indent-5)::before {
        margin-left: -1.5em;
        width: 1.5em;
    }

    /* 二级有序列表 */
    .knowledge-content li[data-list="ordered"].ql-indent-1 {
        margin-left: 3em !important;
    }

    .knowledge-content li[data-list="ordered"].ql-indent-1::before {
        margin-left: -1.5em;
        width: 1.5em;
    }

    /* 三级有序列表 */
    .knowledge-content li[data-list="ordered"].ql-indent-2 {
        margin-left: 4.5em !important;
    }

    .knowledge-content li[data-list="ordered"].ql-indent-2::before {
        margin-left: -1.5em;
        width: 1.5em;
    }

    /* 四级有序列表 */
    .knowledge-content li[data-list="ordered"].ql-indent-3 {
        margin-left: 6em !important;
    }

    .knowledge-content li[data-list="ordered"].ql-indent-3::before {
        margin-left: -1.5em;
        width: 1.5em;
    }

    /* 五级有序列表 */
    .knowledge-content li[data-list="ordered"].ql-indent-4 {
        margin-left: 7.5em !important;
    }

    .knowledge-content li[data-list="ordered"].ql-indent-4::before {
        margin-left: -1.5em;
        width: 1.5em;
    }

    /* 六级有序列表 */
    .knowledge-content li[data-list="ordered"].ql-indent-5 {
        margin-left: 9em !important;
    }

    .knowledge-content li[data-list="ordered"].ql-indent-5::before {
        margin-left: -1.5em;
        width: 1.5em;
    }

    /* 移动端无序列表样式调整 - 与有序列表保持一致对齐 */
    .knowledge-content li[data-list="bullet"] {
        margin-left: 1.5em !important;
    }

    .knowledge-content li[data-list="bullet"]::before {
        margin-left: -1.5em;
        width: 1.5em;
    }

    .knowledge-content li[data-list="bullet"].ql-indent-1 {
        margin-left: 3em !important;
    }

    .knowledge-content li[data-list="bullet"].ql-indent-1::before {
        margin-left: -1.5em;
        width: 1.5em;
    }

    .knowledge-content li[data-list="bullet"].ql-indent-2 {
        margin-left: 1.5em !important;
    }

    .knowledge-content li[data-list="bullet"].ql-indent-2::before {
        margin-left: -1.5em;
        width: 1.5em;
    }

    .knowledge-content li[data-list="bullet"].ql-indent-3 {
        margin-left: 6em !important;
    }

    .knowledge-content li[data-list="bullet"].ql-indent-3::before {
        margin-left: -1.5em;
        width: 1.5em;
    }

    .knowledge-content h1 {
        font-size: 2em !important;
    }

    .knowledge-content h2 {
        font-size: 1.6em !important;
    }

    .knowledge-content h3 {
        font-size: 1.25em !important;
    }

    .knowledge-content h4 {
        font-size: 1em !important;
    }

    .knowledge-content h5 {
        font-size: 0.8em !important;
    }

    .knowledge-content h6 {
        font-size: 0.65em !important;
    }

    .knowledge-content blockquote {
        padding: 0.75rem;
        margin: 1rem 0;
        font-size: 0.875rem;
    }

    .knowledge-content pre,
    .knowledge-content .ql-code-block {
        padding: 0.75rem;
    }

    .knowledge-content table {
        font-size: 0.875rem;
    }

    .knowledge-content th,
    .knowledge-content td {
        padding: 0.5rem;
    }

    .knowledge-content .ql-indent-1 {
        padding-left: 1.5em;
    }

    .knowledge-content .ql-indent-2 {
        padding-left: 3em;
    }

    .knowledge-content .ql-indent-3 {
        padding-left: 4.5em;
    }

    .knowledge-content .ql-indent-4 {
        padding-left: 6em;
    }

    .knowledge-content .ql-indent-5 {
        padding-left: 7.5em;
    }

    .knowledge-content .ql-indent-6 {
        padding-left: 9em;
    }

    .knowledge-content .ql-indent-7 {
        padding-left: 10.5em;
    }

    .knowledge-content .ql-indent-8 {
        padding-left: 12em;
    }
}

/* 夜间模式样式 */
@media (prefers-color-scheme: dark) {
    .knowledge-content img {
        opacity: 0.8;
    }

    .knowledge-content img:hover {
        opacity: 1;
    }

    .knowledge-content .search-highlight {
        background-color: #451a03;
        color: #fbbf24;
    }

    .knowledge-content pre {
        background: linear-gradient(135deg, #1a202c 0%, #2d3748 100%);
    }

    .knowledge-content .ql-code-block {
        /* background: linear-gradient(135deg, #1a202c 0%, #2d3748 100%); */
    }

    .knowledge-content .ql-syntax {
        background: linear-gradient(135deg, #1a202c 0%, #2d3748 100%);
    }

    /* 暗色主题下的highlight.js样式 */
    .knowledge-content .hljs {
        /* background: #1a202c !important; */
    }

    .knowledge-content .code-copy-btn {
        background: rgba(255, 255, 255, 0.15);
        border-color: rgba(255, 255, 255, 0.25);
    }

    .knowledge-content .code-copy-btn:hover {
        background: rgba(255, 255, 255, 0.25);
        border-color: rgba(255, 255, 255, 0.35);
    }

    .knowledge-content .ql-bg-red {
        background-color: rgba(239, 68, 68, 0.25) !important;
        color: #fca5a5 !important;
        padding: 0.15rem 0.3rem !important;
        border-radius: 4px !important;
        display: inline !important;
    }

    .knowledge-content .ql-bg-orange {
        background-color: rgba(249, 115, 22, 0.25) !important;
        color: #fdba74 !important;
        padding: 0.15rem 0.3rem !important;
        border-radius: 4px !important;
        display: inline !important;
    }

    .knowledge-content .ql-bg-yellow {
        background-color: rgba(245, 158, 11, 0.25) !important;
        color: #fde047 !important;
        padding: 0.15rem 0.3rem !important;
        border-radius: 4px !important;
        display: inline !important;
    }

    .knowledge-content .ql-bg-green {
        background-color: rgba(34, 197, 94, 0.25) !important;
        color: #86efac !important;
        padding: 0.15rem 0.3rem !important;
        border-radius: 4px !important;
        display: inline !important;
    }

    .knowledge-content .ql-bg-blue {
        background-color: rgba(59, 130, 246, 0.25) !important;
        color: #93c5fd !important;
        padding: 0.15rem 0.3rem !important;
        border-radius: 4px !important;
        display: inline !important;
    }

    .knowledge-content .ql-bg-purple {
        background-color: rgba(147, 51, 234, 0.25) !important;
        color: #c4b5fd !important;
        padding: 0.15rem 0.3rem !important;
        border-radius: 4px !important;
        display: inline !important;
    }

    .knowledge-content blockquote {
        background: rgba(75, 85, 99, 0.05);
        border-left-color: c4c9d0;
        /* var(--primary-color); */
        color: var(--text-secondary);
        font-size: 0.875rem;
    }
}

/* 暗色主题样式 */
[data-theme="dark"] .knowledge-content img,
.theme-dark .knowledge-content img {
    opacity: 0.8;
}

[data-theme="dark"] .knowledge-content img:hover,
.theme-dark .knowledge-content img:hover {
    opacity: 1;
}

[data-theme="dark"] .knowledge-content .search-highlight,
.theme-dark .knowledge-content .search-highlight {
    background-color: #451a03;
    color: #fbbf24;
}

[data-theme="dark"] .knowledge-content pre,
.theme-dark .knowledge-content pre {
    background: linear-gradient(135deg, #1a202c 0%, #2d3748 100%);
}

[data-theme="dark"] .knowledge-content .ql-code-block,
.theme-dark .knowledge-content .ql-code-block {
    /* background: linear-gradient(135deg, #1a202c 0%, #2d3748 100%); */
}

[data-theme="dark"] .knowledge-content .ql-syntax,
.theme-dark .knowledge-content .ql-syntax {
    background: linear-gradient(135deg, #1a202c 0%, #2d3748 100%);
}

/* 暗色主题下的highlight.js样式 */
[data-theme="dark"] .knowledge-content .hljs,
.theme-dark .knowledge-content .hljs {
    /* background: #1a202c !important; */
}

[data-theme="dark"] .knowledge-content .code-copy-btn,
.theme-dark .knowledge-content .code-copy-btn {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.25);
}

[data-theme="dark"] .knowledge-content .code-copy-btn:hover,
.theme-dark .knowledge-content .code-copy-btn:hover {
    background: rgba(255, 255, 255, 0.25);
    border-color: rgba(255, 255, 255, 0.35);
}

[data-theme="dark"] .knowledge-content .ql-bg-red,
.theme-dark .knowledge-content .ql-bg-red {
    background-color: rgba(239, 68, 68, 0.25) !important;
    color: #fca5a5 !important;
    padding: 0.15rem 0.3rem !important;
    border-radius: 4px !important;
    display: inline !important;
}

[data-theme="dark"] .knowledge-content .ql-bg-orange,
.theme-dark .knowledge-content .ql-bg-orange {
    background-color: rgba(249, 115, 22, 0.25) !important;
    color: #fdba74 !important;
    padding: 0.15rem 0.3rem !important;
    border-radius: 4px !important;
    display: inline !important;
}

[data-theme="dark"] .knowledge-content .ql-bg-yellow,
.theme-dark .knowledge-content .ql-bg-yellow {
    background-color: rgba(245, 158, 11, 0.25) !important;
    color: #fde047 !important;
    padding: 0.15rem 0.3rem !important;
    border-radius: 4px !important;
    display: inline !important;
}

[data-theme="dark"] .knowledge-content .ql-bg-green,
.theme-dark .knowledge-content .ql-bg-green {
    background-color: rgba(34, 197, 94, 0.25) !important;
    color: #86efac !important;
    padding: 0.15rem 0.3rem !important;
    border-radius: 4px !important;
    display: inline !important;
}

[data-theme="dark"] .knowledge-content .ql-bg-blue,
.theme-dark .knowledge-content .ql-bg-blue {
    background-color: rgba(59, 130, 246, 0.25) !important;
    color: #93c5fd !important;
    padding: 0.15rem 0.3rem !important;
    border-radius: 4px !important;
    display: inline !important;
}

[data-theme="dark"] .knowledge-content .ql-bg-purple,
.theme-dark .knowledge-content .ql-bg-purple {
    background-color: rgba(147, 51, 234, 0.25) !important;
    color: #c4b5fd !important;
    padding: 0.15rem 0.3rem !important;
    border-radius: 4px !important;
    display: inline !important;
}

[data-theme="dark"] .knowledge-content blockquote,
.theme-dark .knowledge-content blockquote {
    background: rgba(75, 85, 99, 0.2);
    border-left-color: #c4c9d0;
    /* var(--primary-color); */
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* 打印样式 */
@media print {
    .knowledge-content {
        color: #000;
        font-size: 12pt;
        line-height: 1.4;
    }

    .knowledge-content h1,
    .knowledge-content h2,
    .knowledge-content h3,
    .knowledge-content h4,
    .knowledge-content h5,
    .knowledge-content h6 {
        page-break-after: avoid;
        color: #000;
    }

    .knowledge-content blockquote {
        background: #f5f5f5;
        border-left-color: #333;
        color: #333;
        font-size: 9pt;
        page-break-inside: avoid;
    }

    .knowledge-content .blockquote-group {
        background: #f5f5f5;
        border-left-color: #333;
        page-break-inside: avoid;
    }

    .knowledge-content .blockquote-group blockquote {
        font-size: 9pt;
    }

    .knowledge-content .search-highlight {
        background: none !important;
        color: #000 !important;
        border: 1px solid #000;
    }
}

/* 代码块样式 */
.knowledge-content pre {
    background: transparent;
    /* 背景由外层容器提供 */
    margin: 0;
    padding: 0;
    border-radius: 0;
    white-space: pre;
    /* 添加触摸滚动支持 - 确保iPad横屏模式（桌面端布局）下能正常工作 */
    -webkit-overflow-scrolling: touch;
    touch-action: pan-x pan-y;
}

/* Highlight.js 增强样式 */
.knowledge-content pre code,
.knowledge-content .hljs {
    display: block;
    overflow-x: visible;
    /* 内容区不产生滚动条 */
    padding: 0;
    background: transparent;
    color: #e2e8f0;
    border-radius: 0;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', 'Courier New', monospace;
    font-size: 0.875rem;
    line-height: 1.4;
    margin: 0;
    /* 添加触摸滚动支持 - 确保iPad横屏模式（桌面端布局）下能正常工作 */
    -webkit-overflow-scrolling: touch;
    touch-action: pan-x pan-y;
}

.knowledge-content .ql-code-block .hljs-keyword,
.knowledge-content .ql-syntax .hljs-keyword,
.knowledge-content .ql-code-block-container .hljs-keyword {
    color: #a78bfa;
    font-weight: 600;
}

.knowledge-content .ql-code-block .hljs-string,
.knowledge-content .ql-syntax .hljs-string,
.knowledge-content .ql-code-block-container .hljs-string {
    color: #34d399;
}

.knowledge-content .ql-code-block .hljs-number,
.knowledge-content .ql-syntax .hljs-number,
.knowledge-content .ql-code-block-container .hljs-number {
    color: #fbbf24;
}

.knowledge-content .ql-code-block .hljs-comment,
.knowledge-content .ql-syntax .hljs-comment,
.knowledge-content .ql-code-block-container .hljs-comment {
    color: #6b7280;
    font-style: italic;
}

.knowledge-content .ql-code-block .hljs-function,
.knowledge-content .ql-syntax .hljs-function,
.knowledge-content .ql-code-block-container .hljs-function {
    color: #60a5fa;
}

.knowledge-content .ql-code-block .hljs-variable,
.knowledge-content .ql-syntax .hljs-variable,
.knowledge-content .ql-code-block-container .hljs-variable {
    color: #f87171;
}

.knowledge-content .ql-code-block .hljs-tag,
.knowledge-content .ql-syntax .hljs-tag,
.knowledge-content .ql-code-block-container .hljs-tag {
    color: #fb7185;
}

.knowledge-content .ql-code-block .hljs-attr,
.knowledge-content .ql-syntax .hljs-attr,
.knowledge-content .ql-code-block-container .hljs-attr {
    color: #fcd34d;
}