/* 史记命名实体样式表 v5.7 (全面优化版) */
/* 最后更新: 2026-04-14 */
/* 如果你在浏览器开发者工具中看到这行注释，说明CSS已加载 */
/*
 * v5.7 改进（2026-04-14）：
 * 1. 神话样式：改为双下划线（double），区分于典籍的波浪线（wavy）
 * 2. 动词样式：移除padding和border-radius，避免动词前后产生空隙，保持文字紧凑
 *
 * v5.6 改进（2026-04-14）：
 * 1. 性能优化：平滑滚动、尊重用户运动偏好
 * 2. 可访问性：高对比度模式支持、键盘导航焦点样式
 * 3. 响应式设计：移动端行高和字号优化（768px/480px断点）
 * 4. 视觉改进：对话样式微调、悬停效果优化
 * 5. 打印支持：移除背景色，保留实体颜色
 *
 * v5.4 改进（基于v5.3.3）：
 * 1. 典籍：添加波浪线 (wavy 2px) + 偏移3px
 * 2. 神话：添加波浪线 (wavy 2px) + 偏移3px
 * 3. 朝代：下划线加粗到2px
 * 4. 思想：下划线加粗到2px + 改进颜色透明度
 * 5. 保持v5.3的text-decoration风格和整体配色
 */

/* ======================================== 性能优化 ======================================== */

/* 平滑滚动 - 为Purple Numbers锚点跳转提供更好的体验 */
html {
    scroll-behavior: smooth;
}

/* 尊重用户的运动偏好设置 */
@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }

    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ======================================== 基础样式 ======================================== */
body {
    font-family: "Noto Serif SC", "Source Han Serif SC", serif;
    line-height: 2;
    max-width: 900px;
    margin: 0 auto;
    padding: 20px;
    background-color: #fdfdf8;
    color: #2c2c2c;
}

/* 段落间距 */
p {
    margin: 2em 0;
}

/* 人名样式 */
.person {
    color: #8B4513;
    text-decoration: underline;
    text-decoration-color: #8B451380;
    text-underline-offset: 3px;  /* 增加下划线与文字的距离 */
    font-weight: 500;
    cursor: default;
}

/* 地名样式 */
.place {
    color: #B8860B;
    text-decoration: underline double;  /* 双线区分地名和人名 */
    text-decoration-color: #B8860B80;
    text-underline-offset: 3px;  /* 增加下划线与文字的距离 */
    cursor: default;
}

/* 官职样式 */
.official {
    color: #8B0000;
    font-weight: 500;
    cursor: default;
}

/* 时间/纪年样式 */
.time {
    color: #008B8B;
    font-style: italic;
    cursor: default;
}

/* 朝代/氏族/国号样式 */
.dynasty {
    color: #9370DB;
    text-decoration: underline solid #9370DB80;  /* v5.3.3: 改用text-decoration避免与背景重叠 */
    text-decoration-thickness: 2px;  /* v5.4: 加粗下划线 */
    text-underline-offset: 3px;  /* 增加下划线与文字的距离 */
    cursor: default;
}

/* 封国样式 */
.feudal-state {
    color: #B266B2;
    text-decoration: underline solid #B266B280;  /* v5.3: 改用text-decoration避免与背景重叠 */
    text-underline-offset: 3px;  /* 增加下划线与文字的距离 */
    cursor: default;
}

/* 制度/典章样式 */
.institution {
    color: #4682B4;
    font-weight: 500;
    cursor: default;
}

/* 族群/部落样式 */
.tribe {
    color: #2F4F4F;
    font-weight: 500;
    cursor: default;
}

/* 器物样式 */
.artifact {
    color: #CD853F;
    font-weight: 500;
    cursor: default;
}

/* 天文/历法样式 */
.astronomy {
    color: #483D8B;
    font-style: italic;
    cursor: default;
}

/* 传说生物/神话样式 */
.mythical {
    color: #8B008B;
    text-decoration: underline double #8B008B80;  /* v5.7: 改为双下划线，区分于典籍的波浪线 */
    text-decoration-thickness: 1px;  /* v5.7: 双线无需加粗 */
    text-underline-offset: 3px;  /* v5.4: 下移 */
    font-weight: 500;
    cursor: default;
}

/* 生物样式 */
.biology {
    color: #228B22;
    font-weight: 500;
    cursor: default;
}

/* 典籍样式 */
.book {
    color: #4B0082;
    text-decoration: underline wavy #4B008280;  /* v5.4: 添加波浪线 */
    text-decoration-thickness: 2px;  /* v5.4: 加粗波浪线 */
    text-underline-offset: 3px;  /* v5.4: 下移 */
    font-style: italic;
    cursor: default;
}

/* 礼仪样式 */
.ritual {
    color: #8B6914;
    font-weight: 500;
    cursor: default;
}

/* 刑法样式 */
.legal {
    color: #8B0000;
    background-color: rgba(139, 0, 0, 0.06);
    cursor: default;
}

/* 思想样式 */
.concept {
    color: #2F4F4F;
    text-decoration: underline dotted #2F4F4F80;  /* v5.4: 改进颜色透明度 */
    text-decoration-thickness: 2px;  /* v5.4: 加粗点线 */
    text-underline-offset: 3px;  /* 增加下划线与文字的距离 */
    cursor: default;
}

/* 数量样式 */
.quantity {
    color: #2E8B57;
    font-weight: 500;
    cursor: default;
}

/* 实体链接样式 - v5.3.2: 移除链接默认下划线，避免与实体自身的text-decoration重叠 */
a.entity-link {
    text-decoration: none;  /* 移除链接默认下划线 */
    color: inherit;         /* 继承实体颜色 */
    transition: opacity 0.2s ease;  /* v5.6: 添加过渡效果 */
}

a.entity-link:hover {
    opacity: 0.7;           /* v5.6: 悬停时略微透明，提供视觉反馈 */
}

/* ======================================== 动词标注样式 v5.7 ======================================== */
/* v5.7: 移除padding和border-radius，避免动词前后产生空隙 */
/* v5.1: 改用半透明背景，深色文字 + 加粗，提升可读性 */

/* 军事动词 ⟦◈动词⟧ */
.verb-military {
    color: #b02a37;
    background-color: #fdecec;
    border-bottom: 1.5px solid #dc3545;
    padding: 0;
    font-weight: 500;
    cursor: default;
}

/* 刑罚动词 ⟦◉动词⟧ */
.verb-penalty {
    color: #0a58ca;
    background-color: #eaf2fd;
    border-bottom: 1.5px solid #3d8bfd;
    padding: 0;
    font-weight: 500;
    cursor: default;
}

/* 政治动词 ⟦○动词⟧ */
.verb-political {
    color: #7a5a00;
    background-color: #fff6d6;
    border-bottom: 1.5px solid #d9a406;
    padding: 0;
    font-weight: 500;
    cursor: default;
}

/* 经济动词 ⟦◇动词⟧ */
.verb-economic {
    color: #146c2e;
    background-color: #e6f4ea;
    border-bottom: 1.5px solid #28a745;
    padding: 0;
    font-weight: 500;
    cursor: default;
}

/* 修辞标注 〘※成语〙 — 朱批圈点：红色点状下划线 */
.idiom {
    text-decoration-line: underline;
    text-decoration-style: dotted;
    text-decoration-color: #C0272D;
    text-decoration-thickness: 2px;
    text-underline-offset: 5px;
    cursor: help;
}

.idiom:hover {
    text-decoration-color: #E03030;
    text-decoration-thickness: 2.5px;
}

body.syntax-highlight-off .idiom {
    text-decoration: none;
}

/* 身份标注 〖#身份〗 */
.identity {
    color: #4169E1;  /* 皇室蓝 */
    font-weight: 500;
    cursor: default;
}

/* 事件标注（事件名、事件链接等） */
.event {
    color: #8B4513;  /* 褐色 */
    font-weight: 500;
    cursor: default;
}

/* 引号内容样式（对话） */
/* 视觉设计：克制优雅的对话标记
 * - 淡褐色背景：极淡的底色，不干扰阅读
 * - 底部虚线：褐色虚线，提供清晰但不突兀的视觉边界
 * - 适度内边距：保持文字呼吸感
 */
.quoted {
    background-color: rgba(139, 69, 19, 0.05);  /* v5.6: 稍微加深背景 */
    border-bottom: 1px dashed rgba(139, 69, 19, 0.4);  /* v5.6: 加深虚线 */
    padding: 0 3px;  /* v5.6: 增加内边距 */
}

/* ======================================== 拼音注释样式（Ruby标注） ======================================== */

/* Ruby 标注基础样式 */
ruby {
    ruby-position: over;
    ruby-align: center;
    margin: 0 0.03em;  /* ruby元素之间的左右间距，适度减小 */
}

/* 拼音文本（rt元素）样式 */
rt.pinyin-rt {
    font-family: system-ui, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    font-size: 0.5em;
    font-weight: 400;
    color: #7a6e62;
    letter-spacing: 0.03em;  /* 拼音字母间距适度减小 */
    line-height: 1.2;
    padding: 0 0.08em;  /* 拼音左右padding适度减小 */
}

/* 标题中的拼音 */
h1 rt.pinyin-rt,
h2 rt.pinyin-rt,
h3 rt.pinyin-rt {
    font-size: 0.55em;
    color: #6a5a4a;
    padding: 0 0.1em;  /* 标题中的拼音间距也适度减小 */
}

/* 专名和多音字的拼音（不再强调显示） */
rt.pinyin-rt.pinyin-emphasis {
    /* 移除红色和加粗，与普通拼音保持一致 */
}

/* 特殊读音标识（可选：添加下划线或其他标识） */
rt.pinyin-rt.pinyin-special {
    /* 特殊读音词，与普通拼音保持一致，通过title提示区分 */
    cursor: help;  /* 鼠标悬停显示帮助光标 */
}

/* 汉字部分保持原样式 */
ruby .hanzi {
    letter-spacing: 0.02em;  /* 汉字间距也相应减小 */
}

/* 拼音隐藏功能 - 当关闭拼音显示时隐藏所有 rt 元素 */
body.pinyin-off rt.pinyin-rt {
    display: none;
}

/* 调整行高以适应ruby标注 */
body:not(.pinyin-off) p,
body:not(.pinyin-off) li,
body:not(.pinyin-off) blockquote {
    line-height: 2.2;
}

body:not(.pinyin-off) h1,
body:not(.pinyin-off) h2,
body:not(.pinyin-off) h3 {
    line-height: 1.8;
}

/* 章节标题 */
h1 {
    color: #8B0000;
    border-bottom: 3px solid #8B0000;
    padding-bottom: 10px;
}

h2 {
    color: #8B4513;
    border-left: 5px solid #8B4513;
    padding-left: 15px;
    margin-top: 40px;
}

h3 {
    color: #B8860B;
    margin-top: 30px;
}

/* 分隔线 */
hr {
    border: none;
    border-top: 2px solid #ddd;
    margin: 40px 0;
}

/* 引用块（对话） - 缩进两个汉字 */
blockquote {
    border: none;
    margin: 0.5em 0;  /* 稍微增加上下边距，避免与段落贴太紧 */
    padding: 0;
    padding-left: 2em;
    background: none;
}

/* 当段落以"曰："结尾且后接blockquote时，减小段落下边距 */
p:has(+ blockquote) {
    margin-bottom: 0.5em;  /* 减小"曰："后的空白 */
}

/* 长对话缩进 - 段内较长引号内容另起一行，缩进两个汉字 */
.dialogue {
    display: block;
    padding-left: 2em;
}

/* 列表样式 - 古籍风格，去除项目符号，仅缩进 */
ul, ol {
    line-height: 2;
    list-style: none;
    padding-left: 2em;
    margin: 1em 0;
}

ul li, ol li {
    margin: 0;
}

/* 段落编号 (PN - Purple Numbers) - 致敬 Doug Engelbart
 * Purple Numbers 是 Doug Engelbart 在 1960 年代提出的概念，
 * 用于为文档中的每个段落分配唯一的、可引用的编号。
 * 这一创新使得超文本链接和精确引用成为可能，
 * 是现代互联网和知识管理系统的重要基础。
 *
 * 参考 Eugene Eric Kim 的实现 (https://eekim.com/software/purple/purple.html)
 * 使用淡紫色，字体较小，显示在段落开头。
 * 点击 PN 可复制带锚点的完整 URL，便于分享和引用。
 */
.para-num {
    display: inline;
    color: #C8A8FF;  /* 淡紫色 - 参考 Purple 原始实现 */
    font-family: Helvetica, Arial, sans-serif;
    font-size: 0.75em;  /* x-small */
    font-weight: bold;
    font-style: normal;
    margin-right: 0.5em;  /* 开头位置，右边距 */
    text-decoration: none;
    vertical-align: baseline;
    font-variant-numeric: tabular-nums;
    cursor: pointer;  /* 显示为可点击 */
    transition: color 0.2s ease;
    /* 跳转到 #pn-X 时，在视口顶端留出呼吸空间，避免 PN 紧贴顶边难以辨认 */
    scroll-margin-top: 80px;
}

/* 段落编号悬停效果 */
.para-num:hover {
    color: #9370DB;  /* 深一点的紫色 */
    text-decoration: underline;
}

/* v5.6: 段落编号键盘导航焦点样式 */
.para-num:focus {
    outline: 2px solid #9370DB;
    outline-offset: 2px;
}

/* 当段落编号独立成段时（段落只包含编号），显示为块级元素 */
p:has(> .para-num:only-child) {
    margin: 0.5em 0;
}

p > .para-num:only-child {
    display: inline-block;
    margin-bottom: 0.3em;
}

/* 史记年表样式 - 突破 body max-width 限制，占满视口宽度；flex 居中 */
.shiji-table-wrapper {
    overflow-x: auto;
    max-height: 85vh;
    width: 100vw;
    margin-left: calc(-50vw + 50%);
    margin-top: 2em;
    margin-bottom: 2em;
    border-top: 1px solid #d0c8a0;
    border-bottom: 1px solid #d0c8a0;
    box-shadow: 0 1px 4px rgba(90, 74, 42, 0.08);
    display: flex;
    justify-content: center;
    align-items: flex-start;
}

.shiji-table {
    border-collapse: collapse;
    width: max-content;
    max-width: 100%;
    margin: 0 auto;
    font-size: 0.85em;
    line-height: 1.7;
    font-family: "Noto Serif SC", "Source Han Serif SC", serif;
}

.shiji-table th {
    background-color: #5a4a2a;
    color: #f5f0e0;
    font-weight: bold;
    padding: 8px 12px;
    border: 1px solid #4a3c1e;
    text-align: center;
    white-space: nowrap;
    position: sticky;
    top: 0;
    z-index: 10;
    font-family: "Noto Sans SC", "Source Han Sans SC", sans-serif;
    font-size: 0.95em;
    letter-spacing: 0.05em;
}

.shiji-table td {
    padding: 6px 10px;
    border: 1px solid #e0dcc8;
    text-align: left;
    vertical-align: top;
    color: #2c2c2c;
}

.shiji-table tr.even td {
    background-color: #fdfdf8;
}

.shiji-table tr.odd td {
    background-color: #f5f0e0;
}

.shiji-table tbody tr:hover td {
    background-color: #ede8d4;
    transition: background-color 0.15s ease;
}

.shiji-table td:nth-child(2) {
    white-space: nowrap;
    font-weight: 600;
    color: #5a4a2a;
    background-color: rgba(90, 74, 42, 0.06);
    text-align: center;
    border-right: 2px solid #d0c8a0;
}

/* 表格行号列（Purple Number for table rows） */
.row-pn-col {
    width: 2em;
    min-width: 2em;
    text-align: right;
    padding-right: 6px !important;
    color: #C8A8FF;
    font-size: 0.75em;
    font-family: Helvetica, Arial, sans-serif;
    white-space: nowrap;
    border-right: 1px solid #e0d8c0;
    user-select: none;
    -webkit-user-select: none;
}

.row-pn-col .para-num {
    font-size: 1em;  /* 继承列字号，不再额外缩小 */
}

/* 语义标注块（::: fenced div） */
.note-box {
    background-color: #fffef0;
    border: 1px solid #e6e0c0;
    border-radius: 5px;
    padding: 15px 20px;
    margin: 20px 0;
}

.note-box h4 {
    color: #8B7500;
    margin-top: 0;
}

/* 太史公曰 */
.note-太史公曰 {
    border-left: 3px solid #8B7500;
}

/* 赞（韵文） */
.note-赞 {
    border-left: 3px solid #a0522d;
    background-color: #fefcf5;
    font-style: italic;
}
.note-赞 p {
    line-height: 2.0;
    white-space: pre-line;
}

/* 诗歌 */
.note-诗歌 {
    border-left: 3px solid #6b8e23;
    background-color: #fcfef5;
    font-style: italic;
}
.note-诗歌 p {
    line-height: 2.0;
    white-space: pre-line;
}

/* ======================================== 配置面板样式 ======================================== */

/* 浮动配置按钮 - 定位在导航栏右侧，无边框纯图标 */
#settings-toggle {
    position: fixed;
    top: 27px;
    right: calc(50% - 450px + 20px);  /* 相对于 body max-width(900px) 右侧 20px */
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 20px;
    z-index: 1000;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.6;
    padding: 0;
}

/* 浮动报错按钮 - 定位在设置按钮左侧 */
#report-issue-button {
    position: fixed;
    top: 27px;  /* 与设置按钮同一行 */
    right: calc(50% - 450px + 60px);  /* 在设置按钮左侧 40px */
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 20px;
    z-index: 1000;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.6;
    padding: 0;
}

#report-issue-button:hover {
    opacity: 1;
    transform: scale(1.15);
}

#report-issue-button:active {
    transform: scale(0.95);
}

/* 在小屏幕上回退到右侧定位 */
@media (max-width: 960px) {
    #settings-toggle {
        right: 20px;
    }
    #settings-panel {
        right: auto !important;  /* 强制移除右侧定位 */
        left: 50% !important;  /* 水平居中 */
        transform: translateX(-50%);  /* 水平居中偏移 */
        width: auto;  /* 移除固定宽度 */
        max-width: 400px;  /* 最大宽度限制 */
        min-width: 280px;  /* 最小宽度 */
    }
    #report-issue-button {
        right: 60px;  /* 在设置按钮左侧 40px */
    }
}

/* 在更小屏幕上优化显示 */
@media (max-width: 480px) {
    #settings-panel {
        left: 50% !important;
        right: auto !important;
        transform: translateX(-50%) !important;  /* 保持水平居中 */
        width: calc(100% - 20px) !important;  /* 左右各留10px边距 */
        max-width: none !important;  /* 移除最大宽度限制 */
        min-width: auto !important;  /* 移除最小宽度限制 */
        top: 80px !important;  /* 固定从顶部80px开始 */
        max-height: calc(100vh - 100px);  /* 最大高度，底部留20px */
        overflow-y: auto;  /* 内容过多时滚动 */
    }

    #settings-panel.active {
        animation: slideInMobile 0.2s ease-out;
    }

    @keyframes slideInMobile {
        from {
            opacity: 0;
            transform: translateX(-50%) translateY(-10px);
        }
        to {
            opacity: 1;
            transform: translateX(-50%) translateY(0);
        }
    }
}

#settings-toggle:hover {
    opacity: 1;
    transform: scale(1.15);
}

#settings-toggle:active {
    transform: scale(0.95);
}

/* 配置面板 */
#settings-panel {
    position: fixed;
    top: 70px;
    right: calc(50% - 450px + 20px);  /* 与按钮对齐 */
    width: 280px;
    background: #ffffff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
    padding: 20px;
    z-index: 999;
    display: none;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
}

#settings-panel.active {
    display: block;
    animation: slideIn 0.2s ease-out;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 配置面板关闭按钮 */
#settings-panel-close {
    position: absolute;
    top: 15px;
    right: 15px;
    width: 28px;
    height: 28px;
    border: none;
    background: #f5f5f5;
    color: #666;
    border-radius: 4px;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
    padding: 0;
    z-index: 1;
}

#settings-panel-close:hover {
    background: #e0e0e0;
    color: #333;
}

#settings-panel-close:active {
    transform: scale(0.9);
}

#settings-panel h3 {
    margin: 0 0 15px 0;
    padding-right: 35px;  /* 为关闭按钮留出空间 */
    font-size: 16px;
    font-weight: 600;
    color: #2c2c2c;
    border-bottom: 1px solid #e0e0e0;
    padding-bottom: 10px;
    border-left: none;
    padding-left: 0;
}

.setting-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.setting-item {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    user-select: none;
}

.setting-item input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.setting-item span {
    font-size: 14px;
    color: #2c2c2c;
}

.setting-item.setting-slider {
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
    cursor: default;
}

.setting-slider-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 14px;
    color: #2c2c2c;
}

.setting-slider-value {
    font-size: 13px;
    color: #666;
    font-variant-numeric: tabular-nums;
}

.setting-item.setting-slider input[type="range"] {
    width: 100%;
    cursor: pointer;
}

/* 关闭语法高亮时的样式 - 覆盖所有实体类型 */
body.syntax-highlight-off .person,
body.syntax-highlight-off .place,
body.syntax-highlight-off .official,
body.syntax-highlight-off .time,
body.syntax-highlight-off .dynasty,
body.syntax-highlight-off .feudal-state,
body.syntax-highlight-off .institution,
body.syntax-highlight-off .tribe,
body.syntax-highlight-off .artifact,
body.syntax-highlight-off .astronomy,
body.syntax-highlight-off .book,
body.syntax-highlight-off .mythical,
body.syntax-highlight-off .concept,
body.syntax-highlight-off .biology,
body.syntax-highlight-off .action,
body.syntax-highlight-off .identity,
body.syntax-highlight-off .ritual,
body.syntax-highlight-off .legal,
body.syntax-highlight-off .quantity,
body.syntax-highlight-off .verb-military,
body.syntax-highlight-off .verb-penalty,
body.syntax-highlight-off .verb-political,
body.syntax-highlight-off .verb-economic {
    color: inherit !important;
    background-color: transparent !important;
    text-decoration: none !important;
    font-weight: inherit !important;
    font-style: inherit !important;
    border-bottom: none !important;
    padding: 0 !important;
    border-radius: 0 !important;
}

/* 段落合并模式 - 关闭智能分段时的样式 */
/* 当关闭智能分段时，将共享顶级编号的段落合并显示 */

/* 1. 子段落（p和li）改为行内显示，与前面内容连续 */
body.merge-paragraphs p.sub-paragraph,
body.merge-paragraphs li.sub-paragraph {
    display: inline !important;
    margin: 0 !important;
    padding: 0 !important;
    list-style: none !important;  /* 移除列表项标记 */
}

/* 2. 隐藏子段落的编号链接 */
body.merge-paragraphs .sub-paragraph .para-num {
    display: none !important;
}

/* 3. 顶级段落保持块级显示，有段落间距 */
body.merge-paragraphs p.top-paragraph {
    display: block !important;
    margin: 2em 0 !important;
}

/* 4. 顶级段落的编号保持可见 */
body.merge-paragraphs .top-paragraph .para-num {
    display: inline !important;
}

/* 5. 包含子段落的ul列表也改为行内显示，以便内容连续 */
body.merge-paragraphs ul.has-sub-paragraph {
    display: inline !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
}

/* 6. 消除顶级段落后的ul之间的空白 */
body.merge-paragraphs p.top-paragraph + ul.has-sub-paragraph {
    margin-left: 0 !important;
}

/* 7. 消除ul后的子段落p之间的空白 */
body.merge-paragraphs ul.has-sub-paragraph + p.sub-paragraph {
    margin-left: 0 !important;
}

/* 8. 顶级段落内的br标签也应该被隐藏或转为空格 */
body.merge-paragraphs p.top-paragraph br,
body.merge-paragraphs p.sub-paragraph br,
body.merge-paragraphs li.sub-paragraph br {
    display: none !important;
}

/* 9. 段落内的所有子元素都应该是行内显示 */
body.merge-paragraphs p.top-paragraph > *,
body.merge-paragraphs p.sub-paragraph > *,
body.merge-paragraphs li.sub-paragraph > * {
    display: inline !important;
}

/* 10. 移除对话和引用的特殊样式（缩进、换行等） */
body.merge-paragraphs .quoted,
body.merge-paragraphs .dialogue {
    display: inline !important;
    margin: 0 !important;
    padding: 0 !important;
    text-indent: 0 !important;
    padding-left: 0 !important;
}

/* ======================================== 响应式设计（移动端优化） ======================================== */

/* 平板设备优化 */
@media (max-width: 960px) {
    body {
        line-height: 1.9;
    }

    /* 拼音行高相应调整 */
    body:not(.pinyin-off) p,
    body:not(.pinyin-off) li,
    body:not(.pinyin-off) blockquote {
        line-height: 2.1;
    }
}

/* 移动端优化 */
@media (max-width: 768px) {
    body {
        line-height: 1.8;
        font-size: 16px;  /* 移动端基础字号 */
        padding: 15px;
    }

    /* 拼音行高也相应调整 */
    body:not(.pinyin-off) p,
    body:not(.pinyin-off) li,
    body:not(.pinyin-off) blockquote {
        line-height: 2.0;
    }

    /* 标题字号调整 */
    h1 {
        font-size: 1.6em;
    }

    h2 {
        font-size: 1.4em;
        margin-top: 30px;
    }

    h3 {
        font-size: 1.2em;
        margin-top: 20px;
    }

    /* 史记年表优化 */
    .shiji-table {
        font-size: 0.75em;
    }

    .shiji-table th,
    .shiji-table td {
        padding: 4px 6px;
    }

    /* 段落间距调整 */
    p {
        margin: 1.5em 0;
    }
}

/* 小屏幕手机优化 */
@media (max-width: 480px) {
    body {
        font-size: 15px;
        padding: 10px;
    }

    .shiji-table {
        font-size: 0.7em;
    }

    .shiji-table th,
    .shiji-table td {
        padding: 3px 4px;
    }
}

/* ======================================== 可访问性改进 ======================================== */

/* 高对比度模式支持 */
@media (prefers-contrast: high) {
    /* 实体颜色加深，提高对比度 */
    .person {
        color: #6B3410;  /* 更深的褐色 */
    }

    .place {
        color: #947000;  /* 更深的金色 */
    }

    .official {
        color: #660000;  /* 更深的暗红 */
    }

    .time {
        color: #006666;  /* 更深的青色 */
    }

    .dynasty {
        color: #7B5CB8;  /* 更深的紫色 */
    }

    .feudal-state {
        color: #8E4B8E;  /* 更深的紫红 */
    }

    .institution {
        color: #36648B;  /* 更深的钢蓝 */
    }

    .tribe {
        color: #1F3F3F;  /* 更深的暗灰绿 */
    }

    .artifact {
        color: #A0662F;  /* 更深的土黄 */
    }

    .astronomy {
        color: #342A6B;  /* 更深的深蓝紫 */
    }

    .mythical {
        color: #6B006B;  /* 更深的洋红 */
    }

    .biology {
        color: #186818;  /* 更深的森林绿 */
    }

    .book {
        color: #380062;  /* 更深的靛蓝 */
    }

    .ritual {
        color: #6B5010;  /* 更深的橄榄色 */
    }

    .legal {
        color: #660000;  /* 更深的暗红 */
        background-color: rgba(139, 0, 0, 0.10);  /* 加深背景 */
    }

    .concept {
        color: #1F3F3F;  /* 更深的暗灰绿 */
    }

    .quantity {
        color: #1F6B3F;  /* 更深的海绿 */
    }

    .identity {
        color: #2F4FB8;  /* 更深的皇室蓝 */
    }

    .event {
        color: #6B3410;  /* 更深的褐色 */
    }

    /* 动词：高对比模式下加深底色与边线 */
    .verb-military {
        color: #8a1f29;
        background-color: #fbdcdc;
        border-bottom-color: #b02a37;
    }

    .verb-penalty {
        color: #084298;
        background-color: #dbe7fb;
        border-bottom-color: #0a58ca;
    }

    .verb-political {
        color: #5f4700;
        background-color: #ffecb0;
        border-bottom-color: #b8860b;
    }

    .verb-economic {
        color: #0f5423;
        background-color: #d4ecda;
        border-bottom-color: #1e7e34;
    }

    /* 对话对比度增强 */
    .quoted {
        background-color: rgba(139, 69, 19, 0.08);
        border-bottom: 1px dashed rgba(139, 69, 19, 0.6);
    }
}

/* ======================================== 打印样式 ======================================== */

@media print {
    /* 隐藏交互元素 */
    #settings-toggle,
    #settings-panel,
    #report-issue-button,
    .chapter-nav,
    nav {
        display: none !important;
    }

    /* 优化页面布局 */
    body {
        background-color: white;
        max-width: 100%;
        margin: 0;
        padding: 1cm;
        font-size: 12pt;
        line-height: 1.6;
    }

    /* 移除半透明背景节省墨水 */
    .verb-military,
    .verb-penalty,
    .verb-political,
    .verb-economic {
        background-color: transparent !important;
    }

    .legal {
        background-color: transparent !important;
    }

    .quoted {
        background-color: transparent !important;
    }

    /* 标题优化 */
    h1, h2, h3 {
        page-break-after: avoid;
    }

    h1 {
        font-size: 18pt;
    }

    h2 {
        font-size: 16pt;
    }

    h3 {
        font-size: 14pt;
    }

    /* 避免段落跨页断开 */
    p {
        page-break-inside: avoid;
        orphans: 3;
        widows: 3;
    }

    /* 表格打印优化 */
    .shiji-table {
        font-size: 9pt;
        page-break-inside: avoid;
    }

    .shiji-table th {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .shiji-table td:nth-child(2) {
        background-color: transparent !important;
    }

    /* Purple Numbers 打印样式 */
    .para-num {
        font-size: 8pt;
    }

    /* 链接打印样式 */
    a.entity-link {
        text-decoration: none;
    }

    a[href]:after {
        content: none;  /* 不显示URL */
    }
}

/* ======================================== 白话翻译样式 ======================================== */

/* 白话翻译容器
 * 设计理念：
 * 1. 字体：使用无衬线字体（思源黑体），与原文宋体形成对比
 * 2. 背景：淡蓝色背景，区别于原文的米黄色背景
 * 3. 边框：左侧蓝色边框，视觉上引导读者区分
 * 4. 字号：略小于原文，避免喧宾夺主
 */
.modern-translation {
    /* 字体：使用无衬线字体（黑体），与原文宋体形成对比 */
    font-family: "Noto Sans SC", "Source Han Sans SC", "Microsoft YaHei", sans-serif;

    /* 背景：淡蓝色调，营造现代感 */
    background-color: #f0f8ff;  /* AliceBlue - 淡雅的蓝色 */

    /* 边框：左侧蓝色粗边框，视觉引导 */
    border-left: 4px solid #4682B4;  /* SteelBlue - 钢青色 */

    /* 间距与布局 */
    padding: 14px 18px;
    margin: 10px 0 20px 0;
    border-radius: 6px;

    /* 文字样式 */
    font-size: 0.92em;  /* 略小于原文 */
    line-height: 1.85;   /* 行高适中，便于阅读 */
    color: #2c3e50;      /* 深蓝灰色，区别于原文的纯黑 */

    /* 阴影：轻微阴影增强层次感 */
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);

    display: none;  /* 默认隐藏 */
}

/* 当启用白话翻译时显示 */
body.show-translation .modern-translation {
    display: block;
}

/* 白话译文标签（伪元素，不修改HTML） */
.modern-translation::before {
    content: "白话译文";
    display: block;
    font-size: 0.72em;
    font-weight: 600;
    color: #4682B4;
    letter-spacing: 0.12em;
    margin-bottom: 8px;
    opacity: 0.85;
}

/* 翻译内容 */
.modern-translation .translation-content {
    /* 继承父容器样式 */
}

/* 白话翻译中的实体标注：调整颜色以适配淡蓝背景 */
.modern-translation .person {
    font-weight: 500;  /* 稍微加粗，增强可读性 */
}

.modern-translation .place {
    font-weight: 500;
}

.modern-translation .dynasty {
    font-weight: 500;
}

/* 智能分段模式下，隐藏子段落的翻译（随原文段落折叠） */
.modern-translation[data-hidden-by-merge="true"] {
    display: none !important;
}

/* 打印时的样式 */
@media print {
    .modern-translation {
        background-color: #f0f8ff;
        border-left: 2px solid #4682B4;
        page-break-inside: avoid;
        box-shadow: none;  /* 打印时移除阴影 */
    }
}

/* 移动端响应式优化 */
@media (max-width: 768px) {
    .modern-translation {
        font-size: 0.9em;
        padding: 12px 14px;
        margin: 8px 0 16px 0;
    }
}

/* =========================================================================
 * 三家注（集解·索隐·正义）行下展示
 * 数据源：docs/notes_cache/NNN-notes.json（由 scripts/build_sanjia_cache.py 生成）
 * 渲染：docs/js/sanjia-notes.js
 * ========================================================================= */

/* 原文中的锚点编号（默认隐藏，启用三家注时显示） */
.sanjia-anchor-marker {
    display: none;
    color: #c0504d;
    font-size: 0.7em;
    font-weight: bold;
    vertical-align: super;
    cursor: pointer;
    margin: 0 1px;
    padding: 0 2px;
    border-radius: 3px;
    transition: background 0.2s, color 0.2s;
    user-select: none;
}
body.show-sanjia .sanjia-anchor-marker {
    display: inline;
}
.sanjia-anchor-marker:hover {
    background: #fff3cd;
    color: #8B4513;
}
.sanjia-anchor-marker.highlighted {
    background: #ffd700;
    color: #8B4513;
}

/* 注释容器：默认隐藏，启用时显示 */
.sanjia-notes-container {
    display: none;
    background-color: #faf8f0;
    border-left: 4px solid #c0a060;
    padding: 14px 18px;
    margin: 10px 0 20px 0;
    border-radius: 6px;
    font-size: 0.9em;
    line-height: 1.8;
    color: #3d3326;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    font-family: "Noto Serif SC", "Source Han Serif SC", serif;
}
body.show-sanjia .sanjia-notes-container {
    display: block;
}
.sanjia-notes-container::before {
    content: "三家注";
    display: block;
    font-size: 0.75em;
    font-weight: 600;
    color: #8B4513;
    letter-spacing: 0.15em;
    margin-bottom: 10px;
    opacity: 0.85;
}
.sanjia-notes-container.sanjia-notes-chapter::before {
    content: "三家注 · 章首";
}
.sanjia-notes-container.sanjia-notes-orphans::before {
    content: "三家注 · 未定位";
    color: #888;
}

/* 折叠式未定位注：<details> 元素 */
details.sanjia-notes-container {
    margin-top: 30px;
    opacity: 0.85;
}
details.sanjia-notes-container[open] {
    opacity: 1;
}
details.sanjia-notes-container > summary {
    cursor: pointer;
    user-select: none;
    padding: 4px 0;
    font-weight: 600;
    color: #8B4513;
    outline: none;
    list-style: none;
}
details.sanjia-notes-container > summary::-webkit-details-marker {
    display: none;
}
details.sanjia-notes-container > summary::before {
    content: "▸ ";
    display: inline-block;
    font-size: 0.9em;
    margin-right: 4px;
    transition: transform 0.15s;
}
details.sanjia-notes-container[open] > summary::before {
    content: "▾ ";
}
.sanjia-notes-heading {
    font-weight: bold;
    color: #8B4513;
    margin-bottom: 8px;
    font-size: 0.95em;
}

/* 单条注释条目 */
.sanjia-note {
    margin-bottom: 12px;
    padding: 8px 12px;
    background: #fff8e5;
    border-radius: 4px;
    transition: box-shadow 0.2s, background 0.2s;
}
.sanjia-note:last-child {
    margin-bottom: 0;
}
.sanjia-note.highlighted {
    background: #fff3b8;
    box-shadow: 0 0 8px rgba(255, 215, 0, 0.4);
}

/* 注释条目内：编号与锚词 */
.sanjia-note-num {
    display: inline-block;
    color: #c0504d;
    font-weight: bold;
    font-size: 0.9em;
    margin-right: 6px;
    cursor: pointer;
    user-select: none;
}
.sanjia-note-anchor {
    display: inline-block;
    color: #8B4513;
    font-weight: 500;
    padding: 0 4px;
    border-bottom: 1px dotted #c0a060;
    margin-right: 8px;
    font-size: 0.92em;
}

/* 条目内的单条注（集解/索隐/正义） */
.sanjia-note-items {
    margin-top: 4px;
}
.sanjia-note-item {
    margin-bottom: 4px;
    padding-left: 2px;
    line-height: 1.75;
}
.sanjia-note-item:last-child {
    margin-bottom: 0;
}

/* 出处标签：三色区分 */
.sanjia-source {
    display: inline-block;
    padding: 1px 8px;
    border-radius: 3px;
    font-size: 0.78em;
    font-weight: bold;
    margin-right: 8px;
    color: white;
    vertical-align: baseline;
    letter-spacing: 0.05em;
}
.sanjia-source-jijie   { background: #26a269; }  /* 集解：绿 */
.sanjia-source-suoyin  { background: #d72187; }  /* 索隐：粉 */
.sanjia-source-zhengyi { background: #8B5A5A; }  /* 正义：棕 */

.sanjia-text {
    color: #4a3c2a;
}

/* 智能分段（合并模式）：隐藏子段落的三家注容器，避免错位重复 */
body.merge-paragraphs .sanjia-notes-container[data-sub="true"] {
    display: none !important;
}

/* 移动端响应式 */
@media (max-width: 768px) {
    .sanjia-notes-container {
        font-size: 0.85em;
        padding: 12px 14px;
        margin: 8px 0 16px 0;
    }
    .sanjia-source {
        font-size: 0.75em;
        padding: 1px 6px;
    }
}

/* 打印优化 */
@media print {
    .sanjia-notes-container {
        page-break-inside: avoid;
        box-shadow: none;
    }
}

