.highlighter-rouge {
    font-size: 0.875rem;
}

/* Blog content styling */
.blog-content {
    line-height: 1.7;
}

.blog-content h1,
.blog-content h2,
.blog-content h3,
.blog-content h4,
.blog-content h5,
.blog-content h6 {
    margin-top: 2rem;
    margin-bottom: 1rem;
    font-weight: 500;
}

.blog-content h1 {
    font-size: 2rem;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 0.5rem;
}

.blog-content h2 {
    font-size: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.25rem;
}

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

.blog-content p {
    margin-bottom: 1rem;
}

.blog-content ul,
.blog-content ol {
    margin-bottom: 1rem;
    padding-left: 2rem;
}

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

.blog-content blockquote {
    border-left: 3px solid var(--border-color);
    padding-left: 1rem;
    margin: 1.5rem 0;
    font-style: italic;
    color: var(--muted-color);
}

.blog-content img {
    max-width: 100%;
    height: auto;
    border-radius: 0.375rem;
    margin: 1rem 0;
}

/* Multi-column image layouts */
.blog-content .row img {
    margin: 0.5rem 0;
    transition: transform 0.2s ease-in-out;
}

.blog-content .row img:hover {
    transform: scale(1.02);
}

/* Image gallery styles */
.blog-content .img-fluid {
    width: 100%;
    height: auto;
    object-fit: cover;
}

.blog-content .shadow-sm {
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075) !important;
}

/* Responsive image containers */
.blog-content .col-md-6 img,
.blog-content .col-md-4 img,
.blog-content .col-lg-3 img {
    width: 100%;
    height: 200px;
    object-fit: cover;
    border-radius: 0.375rem;
}

/* Mixed content layouts */
.blog-content .col-md-8 {
    padding-right: 1rem;
}

.blog-content .col-md-4 {
    padding-left: 1rem;
}

@media (max-width: 768px) {
    .blog-content .col-md-8,
    .blog-content .col-md-4 {
        padding: 0;
        margin-bottom: 1rem;
    }
    
    .blog-content .col-md-6 img,
    .blog-content .col-md-4 img {
        height: 150px;
    }
}

.blog-content table {
    width: 100%;
    margin-bottom: 1rem;
    border-collapse: collapse;
}

.blog-content table th,
.blog-content table td {
    padding: 0.75rem;
    border: 1px solid #dee2e6;
}

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

/* Math formula styling */
.katex-display {
    margin: 1.5rem 0;
    text-align: center;
    overflow-x: auto;
    overflow-y: hidden;
}

.katex {
    font-size: 1.1em;
}

/* Ensure math formulas are properly displayed */
.katex-display .katex {
    display: inline-block;
    white-space: nowrap;
}

/* Fix for math formula containers */
.katex-display {
    display: block;
    width: 100%;
}

/* Ensure proper spacing around math formulas */
.blog-content .katex-display {
    margin: 2rem 0;
    padding: 1rem 0;
}

/* Inline math styling */
.katex-inline {
    display: inline;
    margin: 0 0.2em;
}

h1, h2, h3, h4, h5, h6,
.h1, .h2, .h3, .h4, .h5, .h6 {
    font-weight: 600;
}

/* Blog layout — content preserves original width, TOC uses remaining space */
.blog-layout-wrapper {
    display: flex;
    justify-content: center;
    padding: 0 15px;
    gap: 1.5rem;
}

.blog-main {
    flex: 0 1 950px;
    min-width: 0;
}

.blog-toc-sidebar {
    flex: 0 0 auto;
    width: clamp(160px, 18vw, 360px);
    display: none;
}

@media (min-width: 992px) {
    .blog-toc-sidebar {
        display: block;
    }
}

/* Blog Table of Contents */
.blog-toc-nav {
    position: sticky;
    top: 6rem;
    max-height: calc(100vh - 8rem);
    overflow-y: auto;
    padding-left: 0.75rem;
    border-left: 2px solid var(--border-color);
}

.blog-toc-title {
    font-size: 0.875rem;
    font-weight: 600;
    font-family: var(--font-mono);
    text-transform: none;
    letter-spacing: 0.03em;
    color: var(--muted-color);
    margin-bottom: 0.75rem;
}

/* shell 提示符：$ 用强调色，命令用正文灰 */
.blog-toc-title .toc-prompt {
    color: var(--accent-color);
    font-weight: 700;
}

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

.blog-toc-list li {
    margin-bottom: 0.25rem;
}

.blog-toc-list a {
    display: block;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    line-height: 1.4;
    color: var(--muted-color);
    text-decoration: none;
    padding: 0.15rem 0;
    transition: color 0.2s ease;
}

.blog-toc-list a:hover {
    color: var(--heading-color);
    text-decoration: none;
}

.blog-toc-list a.toc-active {
    color: var(--heading-color);
    font-weight: 600;
}

/* tree 形态目录：h2 = 目录（tree -F 的 / 后缀），h3/h4 = 文件。
   层级由框线前缀承担，原缩进让位（清零）；
   框线色走 --tick-color，两主题各自取色；
   "组内最后一项用 └──" 由 li:has(+ li …) 判定，生成 JS 与 scrollspy 不动。
   h4 规则按常见层级近似（│ 竖线列在父级非末项时成立）。 */
.blog-toc-list .toc-h3 { padding-left: 0; }
.blog-toc-list .toc-h4 { padding-left: 0; }

.blog-toc-list a::before {
    color: var(--tick-color);
    white-space: pre;
}

.blog-toc-list li:not(:last-child) a.toc-h2::before { content: "├── "; }
.blog-toc-list li:last-child a.toc-h2::before { content: "└── "; }
.blog-toc-list a.toc-h2::after { content: "/"; }

.blog-toc-list a.toc-h3::before { content: "│   ├── "; }
.blog-toc-list li:has(+ li .toc-h2) a.toc-h3::before { content: "│   └── "; }
.blog-toc-list li:not(:has(~ li .toc-h2)) a.toc-h3::before { content: "    ├── "; }
.blog-toc-list li:not(:has(~ li .toc-h2)):last-child a.toc-h3::before { content: "    └── "; }

.blog-toc-list a.toc-h4::before { content: "│   │   ├── "; }
.blog-toc-list li:has(+ li .toc-h3) a.toc-h4::before,
.blog-toc-list li:has(+ li .toc-h2) a.toc-h4::before { content: "│   │   └── "; }
.blog-toc-list li:last-child a.toc-h4::before { content: "        └── "; }

/* Hide TOC scrollbar */
.blog-toc-nav::-webkit-scrollbar {
    width: 0;
}

.blog-toc-nav {
    scrollbar-width: none;
}

/* 上一篇 / 下一篇 导航 */
.post-nav {
    margin-top: 1.5rem;
}

.post-nav-link {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    height: 100%;
    padding: 0.8rem 1rem;
    background: var(--panel-color);
    border: 1px solid var(--border-color);
    border-radius: 0.45rem;
    transition: border-color 0.2s ease;
}

.post-nav-link:hover {
    border-color: var(--accent-color);
    text-decoration: none !important;
}

.post-nav-label {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    color: var(--muted-color);
    letter-spacing: 0.02em;
}

.post-nav-title {
    color: var(--text-color);
    font-weight: 600;
    font-size: 0.95rem;
    line-height: 1.4;
}

.post-nav-link:hover .post-nav-title {
    color: var(--accent-color);
}

.post-nav-link.post-nav-next {
    align-items: flex-end;
    text-align: right;
}
