/* crimson · 阅读增强（目录 TOC / 阅读进度条） */

/* 阅读进度条：顶部细红线 */
.cr-rbar {
    position: fixed;
    top: 0;
    left: 0;
    height: 3px;
    width: 0;
    background: #b91c1c;
    z-index: 9999;
    pointer-events: none;
    transition: width .08s linear;
}

/* 目录盒 */
.cr-toc {
    margin: 0 0 22px;
    padding: 12px 16px 12px 22px;
    border: 1px solid #eee;
    border-left: 3px solid #b91c1c;
    border-radius: 4px;
    background: #fafafa;
    font-size: 14px;
}

.cr-toc-title {
    font-weight: 700;
    margin: 0 0 8px;
    color: #b91c1c;
    cursor: pointer;
    user-select: none;
}

.cr-toc ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

.cr-toc li {
    margin: 3px 0;
    line-height: 1.6;
}

.cr-toc li.cr-toc-h3 {
    padding-left: 16px;
}

.cr-toc a {
    color: #444;
    text-decoration: none;
    border-bottom: 1px dotted transparent;
}

.cr-toc a:hover,
.cr-toc a.cr-toc-on {
    color: #b91c1c;
    border-bottom-color: #b91c1c;
}

@media (min-width: 1024px) {
    /* 文章区较宽时收纳为可折叠小盒，避免占满首屏 */
    .cr-toc {
        padding: 10px 14px 10px 20px;
    }
}

/* 阅读工具栏（A-/A+ 字号、行距、明暗主题） */
.cr-tools {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    margin: 0 0 12px;
    font-size: 13px;
}

.cr-tools button {
    border: 1px solid #e3e5e8;
    background: #fff;
    color: #444;
    border-radius: 4px;
    padding: 3px 10px;
    cursor: pointer;
    line-height: 1.5;
}

.cr-tools button:hover {
    border-color: #b91c1c;
    color: #b91c1c;
}

.cr-tools .cr-fs-val {
    display: inline-block;
    min-width: 46px;
    text-align: center;
    color: #666;
    font-variant-numeric: tabular-nums;
}

body.night .cr-tools .cr-fs-val {
    color: #aaa;
}

/* 暗色主题下的阅读组件 */
body.night .cr-tools button {
    background: #1e1e1e;
    border-color: #333;
    color: #c9c9c9;
}

body.night .cr-toc {
    background: #171717;
    border-color: #333;
    border-left-color: #e04b4b;
}

body.night .cr-toc a {
    color: #bbb;
}

body.night .cr-toc a:hover,
body.night .cr-toc a.cr-toc-on {
    color: #ff8f8f;
}

/* 行距/主题按钮固定最小宽度，避免文字切换时抖动 */
.cr-tools .cr-lh-btn { min-width: 78px; }
.cr-tools .cr-theme-btn { min-width: 92px; }

/* 移动端：工具栏收纳（隐藏字号百分比、取消最小宽度、按钮可换行） */
@media screen and (max-width: 640px) {
    .cr-tools {
        gap: 5px;
        font-size: 12px;
    }
    .cr-tools .cr-fs-val {
        display: none;
    }
    .cr-tools button {
        padding: 4px 8px;
    }
    .cr-tools .cr-lh-btn,
    .cr-tools .cr-theme-btn {
        min-width: 0;
    }
}

/* 正文段落统一样式：替代旧文章内联 style（仅作用于启用首行缩进的正文）
   注意：模板把 indent 类加在 .article-body 自身（<div class="article-body indent">），
   故选择器必须是 .article-body.indent，写成后代选择器 .article-body .indent 永远不命中。 */
.article-body.indent p {
    margin: 5px 0;
    text-indent: 2em;
    text-align: left;
}

/* 行距切换通过 --cr-lh 级联到正文段落（默认 1.9 与主题一致） */
.article-body p {
	line-height: var(--cr-lh, 1.9);
}

/* 阅读进度记忆：右下角「继续阅读」提示条（不自动滚动，点击才跳转，可关闭） */
.cr-resume {
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 9998;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border: 1px solid #eee;
    border-left: 3px solid #b91c1c;
    border-radius: 4px;
    background: #fff;
    box-shadow: 0 2px 10px rgba(0, 0, 0, .08);
    line-height: 1.4;
}

.cr-resume-btn {
    border: 0;
    background: transparent;
    padding: 0;
    color: #b91c1c;
    font-size: 13px;
    cursor: pointer;
}

.cr-resume-btn:hover {
    text-decoration: underline;
}

.cr-resume-x {
    border: 0;
    background: transparent;
    padding: 0 2px;
    color: #999;
    font-size: 15px;
    line-height: 1;
    cursor: pointer;
}

.cr-resume-x:hover {
    color: #b91c1c;
}

body.night .cr-resume {
    background: #1e1e1e;
    border-color: #333;
    border-left-color: #e04b4b;
    box-shadow: 0 2px 10px rgba(0, 0, 0, .4);
}

body.night .cr-resume-btn {
    color: #ff8f8f;
}

body.night .cr-resume-x {
    color: #888;
}

@media screen and (max-width: 640px) {
    .cr-resume {
        right: 10px;
        bottom: 10px;
        gap: 8px;
        padding: 7px 10px;
    }
    .cr-resume-btn {
        font-size: 12px;
    }
}

/* v1.0.77 新增：移动端底部阅读工具栏（仅文章页注入，窄屏显示，桌面恒隐藏） */
.cr-mbar {
    display: none;
}

@media screen and (max-width: 768px) {
    .cr-mbar {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 950;
        display: flex;
        align-items: stretch;
        background: var(--cr-surface);
        border-top: 1px solid var(--cr-border);
        padding: 4px 4px calc(4px + env(safe-area-inset-bottom, 0px));
        box-shadow: 0 -2px 12px rgba(0, 0, 0, .06);
    }
    .cr-mbar-btn {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 3px;
        min-height: 46px;
        border: 0;
        background: transparent;
        color: var(--cr-text);
        font-size: 11px;
        line-height: 1.2;
        cursor: pointer;
        border-radius: 8px;
        padding: 4px 0;
    }
    .cr-mbar-btn:active {
        background: rgba(0, 0, 0, .06);
        color: var(--cr-primary);
    }
    .cr-mbar-btn[disabled] {
        opacity: .35;
        pointer-events: none;
    }
    .cr-mbar-ico {
        font-size: 17px;
        line-height: 1;
    }
    body.night .cr-mbar-btn:active {
        background: rgba(255, 255, 255, .08);
    }
    /* 与返回顶部按钮、续读条错开底部空间 */
    body.cr-has-mbar #back-to-top {
        bottom: 76px;
    }
    body.cr-has-mbar .cr-resume {
        bottom: 70px;
    }
    /* 页脚让位，避免底栏遮挡版权行 */
    body.cr-has-mbar .site-footer {
        padding-bottom: 80px;
    }
}
