:root {
  --c-warning: #e7c000;
  --c-warning-bg: #fffbe6;
  --c-warning-text: #6b5900;
  --c-warning-title: #b29400;
  --c-tip: #42b983;
  --c-tip-bg: #e6f9f0;
  --c-tip-text: #22543d;
  --c-tip-title: #2c8f60;
  --c-danger: #ff4d4f;
  --c-danger-bg: #fff1f0;
  --c-danger-text: #a8071a;
  --c-danger-title: #d4380d;
  --font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
}

.book-body {
    overflow-y: scroll;
}

.book-body .book-header {
    position: fixed;
    width: 100%;
}

.book.with-summary .book-body .book-header {
    position: fixed;
    width: calc(100% - 300px);
}

.book-body .body-inner {
    /* position: absolute; */
    margin-top: 50px;
    min-height: calc(100% - 50px);
}

@media (max-width: 1240px) {
    .book-body .body-inner {
        position: absolute;
        margin-top: 50px;
        min-height: calc(100% - 50px)
    }
}

.book-body .body-inner .page-wrapper {
    min-height: calc(100% - 46px);
}

.book-body .body-inner .page-wrapper .page-inner {
    padding-bottom: 20px;
}

@media (max-width: 1240px) {
    .book-body .body-inner .navigation {
        max-width: calc(50% - 3px);
        width: calc(50% - 3px);
    }

    .book.with-summary .book-body .book-header {
        overflow-x: hidden;
        overflow-y: hidden;
    }
}

.book .book-body .book-header {
    background: #ffffff;
}

.book.color-theme-1 .book-body .book-header {
    background: #f3eacb;
}

.book.color-theme-2 .book-body .book-header {
    background: #1c1f2b;
}

.book.color-theme-2 {
  --c-tip-title: #42b983; /* 或其它适合深色背景的绿色 */
  --c-warning-title:var(--c-warning);
  --c-danger-title: #d4380d;
}

.page-inner {
    max-width: 800px;
}

.back-to-top {
    right: calc((100% - 300px - min(100% - 300px, 800px)) / 2 + 25px);
}

/* scrollbar */
::-webkit-scrollbar {
    width: 5px;
    height: 5px;
}

::-webkit-scrollbar-track-piece {
    /* background-color: rgba(125, 125, 125, 0.2); */
    -webkit-border-radius: 6px;
}

::-webkit-scrollbar-thumb:vertical {
    height: 5px;
    background-color: rgba(7, 17, 27, .2);
    -webkit-border-radius: 6px;
}

::-webkit-scrollbar-thumb:horizontal {
    width: 5px;
    background-color: rgba(125, 125, 125, 0.2);
    -webkit-border-radius: 6px;
}

/* Style for search page on mobile screens */

#book-search-input-link {
    padding: 6px;
    background: 0 0;
    background: inherit;
    transition: top .5s ease;
    border-bottom: 1px solid rgba(0,0,0,.07);
    border-top: 1px solid rgba(0,0,0,.07);
    margin-bottom: 10px;
    margin-top: -1px;
}

#book-search-input-link a {
    width: 100%;
    background: 0 0;
    border: 1px solid transparent;
    box-shadow: none;
    outline: 0;
    line-height: 38px;
    padding: 7px 7px;
    color: #757575;
}

#book-search-input {
    display: block;
}
#book-search-input-link {
    display: none;
}

@media (max-width: 1240px) {
    #book-search-input {
        display: none;
    }
    #book-search-input-link {
        display: block;
    }
}

#book-search-input-inside {
    padding: 6px;
    background: 0 0;
    transition: top .5s ease;
    background: #fff;
    border-bottom: 1px solid rgba(0,0,0,.07);
    border-top: 1px solid rgba(0,0,0,.07);
    margin-bottom: 10px;
    margin-top: -1px;
}

#book-search-input-inside input {
    width: 100%;
    background: 0 0;
    border: 1px solid transparent;
    box-shadow: none;
    outline: 0;
    line-height: 22px;
    padding: 7px 7px;
    color: inherit;
}

/* Custom font settings */

.book.font-family-0 {
    font-family: Georgia, serif;
}
.book.font-family-1 {
    font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
}
.book.font-family-2 {
    font-family: "Times New Roman", Times, serif;
}

/* Render wide tables */

.table-wrapper {
    overflow-x: scroll;
}

/* Tips, warnings, and dangers */

.markdown-section blockquote.block-tip {
    border-color: var(--c-tip);
    background-color: var(--c-tip-bg);
    color: var(--c-tip-text);
    font-family: var(--font-family);
    padding: 10px;
}

.markdown-section blockquote.block-tip h1,
.markdown-section blockquote.block-tip h2,
.markdown-section blockquote.block-tip h3,
.markdown-section blockquote.block-tip h4,
.markdown-section blockquote.block-tip h5,
.markdown-section blockquote.block-tip h6 {
    color: var(--c-tip-title);
    margin: 0px;
    margin-bottom: 5px;
}

.markdown-section blockquote.block-tip p {
    margin-bottom: 0px;
}

.markdown-section blockquote.block-warning {
    border-color: var(--c-warning);
    background-color: var(--c-warning-bg);
    color: var(--c-warning-text);
    font-family: var(--font-family);
    padding: 10px;
}

.markdown-section blockquote.block-warning h1,
.markdown-section blockquote.block-warning h2,
.markdown-section blockquote.block-warning h3,
.markdown-section blockquote.block-warning h4,
.markdown-section blockquote.block-warning h5,
.markdown-section blockquote.block-warning h6 {
    color: var(--c-warning-title);
    margin: 0px;
    margin-bottom: 5px;
}

.markdown-section blockquote.block-warning p {
    margin-bottom: 0px;
}

.markdown-section blockquote.block-danger {
    border-color: var(--c-danger);
    background-color: var(--c-danger-bg);
    color: var(--c-danger-text);
    font-family: var(--font-family);
    padding: 10px;
}

.markdown-section blockquote.block-danger h1,
.markdown-section blockquote.block-danger h2,
.markdown-section blockquote.block-danger h3,
.markdown-section blockquote.block-danger h4,
.markdown-section blockquote.block-danger h5,
.markdown-section blockquote.block-danger h6 {
    color: var(--c-danger-title);
    margin: 0px;
    margin-bottom: 5px;
}

.markdown-section blockquote.block-danger p {
    margin-bottom: 0px;
}

pre:has(code.language-mermaid[data-processed="true"]) {
    background-color: #ffffff;
    text-align: center;
}

/* ========== ENHANCED: Category Sidebar (Left) ========== */

.book-summary {
    position: fixed;
    top: 0;
    left: 0;
    width: 300px;
    height: 100vh;
    background: #fafafa;
    border-right: 1px solid #e7e7e7;
    overflow-y: auto;
    z-index: 2;
    font-size: 14px;
    font-family: inherit;
}

.summary-header {
    padding: 15px 20px;
    background: #f0f0f0;
    border-bottom: 1px solid #e7e7e7;
    position: sticky;
    top: 0;
    z-index: 3;
}

.summary-header h3 {
    margin: 0;
    color: #333;
    font-size: 16px;
    font-weight: 600;
}

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

.category-group {
    border-bottom: 1px solid #f0f0f0;
}

.category-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    color: #333;
    text-decoration: none;
    font-weight: 500;
    background: #f8f8f8;
    transition: background-color 0.2s ease;
    cursor: pointer;
    font-family: inherit;
}

.category-header:hover {
    background: #f0f0f0;
    color: #42b983;
}

.category-header i {
    margin-right: 8px;
    color: #42b983;
}

.category-count {
    font-size: 12px;
    color: #666;
    background: #e9ecef;
    padding: 2px 6px;
    border-radius: 10px;
    font-weight: normal;
}

.category-posts {
    list-style: none;
    padding: 0;
    margin: 0;
    display: none;
    background: #fff;
}
/* 加载状态样式 */
.category-posts a.loading {
    opacity: 0.6;
    pointer-events: none;
}

.category-posts a.loading::after {
    content: ' ⏳';
    font-size: 0.8em;
}

/* 平滑过渡效果 */
.body-inner {
    transition: opacity 0.2s ease-in-out;
}
.category-group.expanded .category-posts {
    display: block;
}

.category-posts li {
    border-bottom: 1px solid #f5f5f5;
}

.category-posts li:last-child {
    border-bottom: none;
}

.category-posts a {
    display: block;
    padding: 10px 20px 10px 40px;
    color: #666;
    text-decoration: none;
    line-height: 1.4;
    transition: all 0.2s ease;
    border-left: 3px solid transparent;
    font-family: inherit;
}

.category-posts a:hover {
    background: #f8f8f8;
    color: #42b983;
    border-left-color: #42b983;
}

.category-posts li.active a {
    background: #e2f5ec;
    color: #42b983;
    border-left-color: #42b983;
    font-weight: 500;
}

.post-date {
    display: block;
    font-size: 11px;
    color: #999;
    margin-top: 4px;
}

.show-more a {
    font-style: italic;
    color: #42b983 !important;
    font-size: 13px;
}

/* ========== ENHANCED: Table of Contents (Right) ========== */

.toc-container {
    position: fixed;
    right: 10px;
    top: 60px;
    width: 100px;
    max-height: calc(100vh - 120px);
    background: #ffffff;
    border: 1px solid #e7e7e7;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    z-index: 100;
    font-size: 14px;
    overflow: hidden;
}

.toc-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: #42b983;
    color: white;
    font-weight: 500;
}

.toc-header h4 {
    margin: 0;
    font-size: 15px;
}

.toc-header i {
    margin-right: 6px;
}

.toc-toggle-btn {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.toc-toggle-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.toc-content {
    height: calc(400px - 50px);
    max-height: 300px;
    overflow-y: auto;
    padding: 10px 0;
    /* 自定义滚动条样式 */
    scrollbar-width: thin;
    scrollbar-color: rgba(0,0,0,0.3) transparent;
}

.toc-content.collapsed {
    display: none !important;
}

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

.toc-list li {
    margin: 0;
}

.toc-list a {
    display: block;
    padding: 8px 16px;
    color: #555;
    text-decoration: none;
    border-left: 3px solid transparent;
    transition: all 0.2s ease;
    line-height: 1.3;
}

.toc-list a:hover {
    background: #f8f9fa;
    color: #42b983;
    border-left-color: #42b983;
}

.toc-list a.active {
    background: #e2f5ec;
    color: #42b983;
    border-left-color: #42b983;
    font-weight: 500;
}

/* TOC heading levels */
.toc-list .toc-h1 { font-weight: 600; }
.toc-list .toc-h2 { padding-left: 24px; }
.toc-list .toc-h3 { padding-left: 32px; font-size: 13px; }
.toc-list .toc-h4 { padding-left: 40px; font-size: 13px; }
.toc-list .toc-h5 { padding-left: 48px; font-size: 12px; }
.toc-list .toc-h6 { padding-left: 56px; font-size: 12px; }

/* ========== MOBILE TOGGLES ========== */

.toc-mobile-toggle,
.category-mobile-toggle {
    display: none;
    position: fixed;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: none;
    background: #42b983;
    color: white;
    font-size: 16px;
    cursor: pointer;
    z-index: 1001;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
}

.toc-mobile-toggle:hover,
.category-mobile-toggle:hover {
    background: #359469;
    transform: scale(1.1);
}

.toc-mobile-toggle {
    bottom: 80px;
    right: 20px;
}

.category-mobile-toggle {
    bottom: 140px;
    right: 20px;
}

/* ========== RESPONSIVE DESIGN ========== */

/* Large screens - optimal layout */
@media (min-width: 1400px) {
    .toc-container {
        width: 240px;
        right: 20px;
    }
}

/* Medium screens - adjust TOC */
@media (max-width: 1240px) {
    .book.with-summary .book-body .book-header {
        width: calc(100% - 300px);
    }
    
    .toc-container {
        width: 260px;
        right: 15px;
    }
}

/* Tablet and mobile */
@media (max-width: 768px) {
    /* Show mobile toggle buttons */
    .toc-mobile-toggle,
    .category-mobile-toggle {
        display: block;
    }
    
    /* Hide TOC by default on mobile */
    .toc-container {
        display: none;
        position: fixed;
        top: 60px;
        right: 10px;
        left: 10px;
        width: auto;
        max-height: calc(100vh - 100px);
        z-index: 1002;
    }
    
    .toc-container.mobile-show {
        display: block;
    }
    
    /* Hide category sidebar by default on mobile */
    .book-summary {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        z-index: 1000;
    }
    
    .book-summary.mobile-show {
        transform: translateX(0);
    }
    
    /* Adjust main content for mobile */
    .book.with-summary .book-body {
        margin-left: 0;
    }
    
    .book.with-summary .book-body .book-header {
        width: 100%;
    }
}

/* Very small screens */
@media (max-width: 480px) {
    .book-summary {
        width: 280px;
    }
    
    .toc-mobile-toggle,
    .category-mobile-toggle {
        width: 45px;
        height: 45px;
        font-size: 14px;
    }
    
    .toc-mobile-toggle {
        bottom: 70px;
        right: 15px;
    }
    
    .category-mobile-toggle {
        bottom: 125px;
        right: 15px;
    }
}

/* ========== DARK THEME SUPPORT ========== */

.book.color-theme-2 .book-summary {
    background: #2c3e50;
    border-right-color: #34495e;
}

.book.color-theme-2 .summary-header {
    background: #34495e;
    border-bottom-color: #2c3e50;
}

.book.color-theme-2 .summary-header h3 {
    color: #ecf0f1;
}

.book.color-theme-2 .category-header {
    background: #34495e;
    color: #ecf0f1;
}

.book.color-theme-2 .category-header:hover {
    background: #2c3e50;
    color: #42b983;
}

.book.color-theme-2 .category-posts {
    background: #2c3e50;
}

.book.color-theme-2 .category-posts a {
    color: #bdc3c7;
}

.book.color-theme-2 .category-posts a:hover,
.book.color-theme-2 .category-posts li.active a {
    background: #34495e;
    color: #42b983;
}

.book.color-theme-2 .toc-container {
    background: #2c3e50;
    border-color: #34495e;
}

.book.color-theme-2 .toc-list a {
    color: #bdc3c7;
}

.book.color-theme-2 .toc-list a:hover,
.book.color-theme-2 .toc-list a.active {
    background: #34495e;
    color: #42b983;
}

/* ========== HEADING SCROLL MARGIN ========== */
h1, h2, h3, h4, h5, h6 {
    scroll-margin-top: 80px;
    /* For Firefox */
}

h1 {
    scroll-margin-top: 100px;
}

@supports (-webkit-touch-callout: none) {
    h1, h2, h3, h4, h5, h6 {
        scroll-margin-top: 60px;
    }
    
    h1 {
        scroll-margin-top: 80px;
    }
}

/* Warning, Danger, Tips blocks */
.markdown-section blockquote.block-warning,
.markdown-section blockquote.block-danger,
.markdown-section blockquote.block-tip {
    font-family: inherit;
}

/* Block titles */
.markdown-section blockquote.block-warning h1,
.markdown-section blockquote.block-warning h2,
.markdown-section blockquote.block-warning h3,
.markdown-section blockquote.block-warning h4,
.markdown-section blockquote.block-warning h5,
.markdown-section blockquote.block-warning h6,
.markdown-section blockquote.block-danger h1,
.markdown-section blockquote.block-danger h2,
.markdown-section blockquote.block-danger h3,
.markdown-section blockquote.block-danger h4,
.markdown-section blockquote.block-danger h5,
.markdown-section blockquote.block-danger h6,
.markdown-section blockquote.block-tip h1,
.markdown-section blockquote.block-tip h2,
.markdown-section blockquote.block-tip h3,
.markdown-section blockquote.block-tip h4,
.markdown-section blockquote.block-tip h5,
.markdown-section blockquote.block-tip h6 {
    font-family: inherit;
}

/* Block content */
.markdown-section blockquote.block-warning p,
.markdown-section blockquote.block-danger p,
.markdown-section blockquote.block-tip p {
    font-family: inherit;
}