/* --- 全局样式 --- */
* {
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    margin: 0 auto;
    line-height: 1.6;
    color: #333;
}

.article-main {
    padding: 40px 50px;
    max-width: 900px;
    margin: auto;
    border-radius: 1px;
}

.article-main p {
    white-space: pre-wrap;
}

/* --- 右侧悬浮刻度条（fixed 定位，不占文档流） --- */
.toc-progress {
    position: fixed;
    right: 24px;
    top: 50%;
    transform: translateY(-50%);
    width: 24px;
    max-height: 60vh;
    backdrop-filter: blur(4px);
    border-radius: 2px;
    padding: 12px 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: width 0.25s ease, background 0.25s ease, box-shadow 0.25s ease;
    overflow: visible;
    z-index: 1000;
    cursor: pointer;
    border: 1px solid transparent;
}

.toc-progress:hover,
.toc-progress.expanded {
    width: auto;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
    border-color: #e9ecef;
    cursor: default;
    text-align: left;
}

/* 刻度轨道（窄条模式可见） */
.toc-track {
    position: relative;
    width: 3px;
    height: 100%;
    border-radius: 2px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
    transition: opacity 0.2s;
}

.toc-progress.expanded .toc-track {
    opacity: 0;
    pointer-events: none;
    width: 0;
    margin: 0;
    padding: 0;
    height: 0;
    overflow: hidden;
}

/* 刻度点（窄条模式可见） */
.toc-dot {
    flex-shrink: 0;
    background: #adb5bd;
    border-radius: 2px;
    transition: background 0.2s, transform 0.2s;
    margin: 4px 0;
    cursor: pointer;
}

.toc-dot.active {
    background: #4a6cf7;
    transform: scale(1.3);
}

.toc-dot:hover {
    background: #4a6cf7;
    transform: scale(1.3);
}

/* 大纲列表（展开模式可见） */
.toc-popup {
    display: none;
    width: 100%;
    max-height: 60vh;
    overflow-y: auto;
    padding: 0 12px 0 16px;
    font-size: 14px;
    line-height: 1.6;
    flex-shrink: 1;
}

.toc-progress.expanded .toc-popup {
    display: block;
}

/* 悬浮框滚动条（与全局一致） */
.toc-popup::-webkit-scrollbar {
    width: 6px;
}

.toc-popup::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.toc-popup::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.toc-popup::-webkit-scrollbar-thumb:hover {
    background: #a1a1a1;
}

.toc-popup {
    scrollbar-width: thin;
    scrollbar-color: #c1c1c1 #f1f1f1;
}

/* 大纲列表样式 */
.toc-popup ul {
    list-style: none;
    padding-left: 0;
    margin: 4px 0;
}

.toc-popup ul ul {
    padding-left: 1.2em;
}

.toc-popup li {
    cursor: pointer;
    border-radius: 4px;
    padding: 3px 0 3px 4px;
    transition: background 0.15s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.toc-popup li:hover {
    background: #f1f3f5;
}

.toc-popup li.active {
    background: #e7edff;
    color: #4a6cf7;
    font-weight: 500;
}

.toc-popup li a {
    display: block;
    color: inherit;
    text-decoration: none;
}

/* --- 文章内样式（原样保留） --- */
.article-header {
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 1px solid #eee;
}

.article-title {
    font-size: 28px;
    font-weight: 600;
    color: #1a1a1a;
    margin: 0 0 15px 0;
    line-height: 1.4;
    text-align: left;
}

.article-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    font-size: 14px;
    color: #666;
}

.meta-left {
    display: flex;
    gap: 20px;
    align-items: center;
}

.meta-item .icon {
    font-size: 16px;
}

.meta-right {
    display: flex;
    gap: 10px;
    align-items: center;
}

.like-btn, .share-btn, .copy-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 5px 12px;
    border-radius: 20px;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.like-btn:hover {
    background: #fff0f0;
}

.share-btn:hover {
    background: #e8f4fd;
    color: #1890ff;
}

.copy-btn:hover {
    background: #fff7e6;
    color: #fa8c16;
}

.like-btn.liked .like-icon {
    animation: likePop 0.3s ease;
}

@keyframes likePop {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.3);
    }
    100% {
        transform: scale(1);
    }
}

.article-content {
    margin-top: 20px;
    text-align: left;
}

.article-content h1, .article-content h2, .article-content h3 {
    margin-top: 1.8em;
    margin-bottom: 0.6em;
    text-align: left;
}

.article-content img {
    max-width: 100%;
    height: auto;
}

.article-content code {
    background: #f4f4f4;
    padding: 2px 6px;
    border-radius: 3px;
}

.article-content pre {
    background: #f4f4f4;
    padding: 15px;
    border-radius: 5px;
    overflow-x: auto;
}

.article-content blockquote {
    border-left: 4px solid #ddd;
    padding-left: 15px;
    color: #666;
}

.article-content a {
    color: #007bff;
    text-decoration: none;
}

.article-content a:hover {
    text-decoration: underline;
}

.article-content table {
    border-collapse: collapse;
    width: 100%;
    margin: 15px 0;
}

.article-content th, .article-content td {
    border: 1px solid #ddd;
    padding: 8px 12px;
    text-align: left;
}

.article-content th {
    background: #f8f8f8;
}

/* 全局滚动条 */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #a1a1a1;
}

::-webkit-scrollbar-thumb:active {
    background: #818181;
}

body {
    scrollbar-width: thin;
    scrollbar-color: #c1c1c1 #f1f1f1;
}

/* 移动端适配 */
@media (max-width: 768px) {
    .article-main {
        padding: 20px;
    }

    .toc-progress {
        right: 12px;
        width: 20px;
        padding: 8px 0;
    }

    .toc-progress:hover,
    .toc-progress.expanded {
        width: 220px;
    }

    .toc-popup {
        font-size: 13px;
    }
}

@media (max-width: 600px) {
    .toc-progress {
        display: none;
    }
}

/* 代码高亮 复制*/
.code-block-wrapper {
    position: relative;
    /* 添加一些内边距，为按钮留出空间 */
    margin: 1em 0;
    background: #f8f8f8;
    border-radius: 6px;

      /* 为语言标签留出顶部空间 */
    padding-top: 2.2em;
    overflow: hidden;
}

/* 语言标签样式 */
.code-lang {
    position: absolute;
    top: 0;
    left: 0;
    opacity: 0.2;
    padding: 4px 12px;
    font-size: 12px;
    font-weight: 600;
    color: black;
    border-radius: 6px 0 6px 0;  /* 左上角圆角，右下角直角 */
    letter-spacing: 1px;
    user-select: none;
}

/* 复制按钮（右上角）调整，避免被语言标签遮挡 */
.copy-code-button {
    position: absolute;
    top: 4px;
    right: 8px;
    opacity: 0.1;
    transition: opacity 0.2s ease;
    padding: 4px 10px;
    font-size: 12px;
    border: 1px solid #ccc;
    border-radius: 4px;
    background: #fff;
    cursor: pointer;
    z-index: 2; /* 确保在语言标签上方（如果重叠） */
}

.copy-block {
    position: relative;
    overflow: hidden;
}

/* 悬浮显示复制按钮 */
.code-block-wrapper:hover .copy-code-button, .code-block-wrapper:hover .code-lang,
.copy-block:hover .copy-code-button {
    opacity: 1;
}

/* Pygments 生成的 .highlight 内部样式微调 */
.code-block-wrapper .highlight {
    margin: 0;           /* 移除默认外边距 */
    overflow: auto;
}
.code-block-wrapper .highlight pre {
    margin: 0;
}

/* ----- 遮罩层 ----- */
.image-viewer-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: none;              /* 默认隐藏 */
    justify-content: center;
    align-items: center;
    z-index: 9999;
    cursor: zoom-out;           /* 点击背景关闭 */
    user-select: none;
}

/* ----- 图片容器（用于居中及限制大小） ----- */
.image-viewer-container {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
    overflow: hidden;           /* 防止缩放后溢出容器 */
    cursor: grab;
    touch-action: none;         /* 禁用浏览器默认手势，方便自定义 */
}

.image-viewer-container:active {
    cursor: grabbing;
}

/* ----- 弹窗中的图片 ----- */
.image-viewer-img {
    display: block;
    max-width: 100%;
    max-height: 100%;
    transform-origin: center center;
    transition: none;           /* 缩放时不要过渡，避免卡顿 */
    will-change: transform;
    pointer-events: none;       /* 避免干扰拖拽事件 */
}

/* ----- 页面所有图片（鼠标指针） ----- */
.article-content img {          /* 请根据你的实际容器类名调整 */
    cursor: pointer;
    transition: box-shadow 0.2s;
}
.article-content img:hover {
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.5);
}

/* 修改全屏查看器的遮罩背景色 */
.iv-fullscreen {
    /* 或者使用你喜欢的任何颜色，比如半透明深色 */
    background-color: rgba(0, 0, 0, 0.7) !important;
}

.iv-fullscreen-close {
    background-color: rgba(0, 0, 0, 0.2) !important; /* 半透明黑色背景 */
    border-radius: 50% !important; /* 可选：让背景变成圆形 */
}

.iv-fullscreen-close:hover {
    background-color: rgba(0, 0, 0, 0.8) !important;
}

/* ================ 上一篇 / 下一篇 导航 ================ */
.article-nav {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    margin-top: 60px;
    padding-top: 30px;
    border-top: 1px solid #eee;
}

.article-nav .nav-item {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    padding: 16px 20px;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    text-decoration: none;
    color: inherit;
    transition: all 0.2s ease;
    cursor: pointer;
    overflow: hidden;
}

.article-nav .nav-item:hover {
    border-color: #4a6cf7;
    background-color: #fafbfc;
    box-shadow: 0 2px 12px rgba(74, 108, 247, 0.08);
    transform: translateY(-1px);
}

.article-nav .nav-prev {
    text-align: left;
    align-items: flex-start;
}

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

.article-nav .nav-label {
    font-size: 12px;
    color: #999;
    margin-bottom: 6px;
    letter-spacing: 1px;
    flex-shrink: 0;
}

.article-nav .nav-title {
    font-size: 15px;
    font-weight: 500;
    color: #333;
    line-height: 1.5;
    /* 标题最多显示两行 */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    word-break: break-word;
    max-width: 100%;
}

.article-nav .nav-item:hover .nav-title {
    color: #4a6cf7;
}

/* 移动端适配：上下篇改为上下堆叠 */
@media (max-width: 600px) {
    .article-nav {
        flex-direction: column;
        gap: 12px;
        margin-top: 40px;
        padding-top: 24px;
    }

    .article-nav .nav-next {
        text-align: left;
        align-items: flex-start;
    }

    .article-nav .nav-item {
        padding: 12px 16px;
    }

    .article-nav .nav-title {
        font-size: 14px;
    }
}