/* ============================================
   文章通用美化增强包
   说明: 为所有文章页面提供统一的美化效果
         低特异性，不破坏文章原有样式
   ============================================ */

/* 超链接美化 */
a {
    color: #6366f1;
    text-decoration: none;
    transition: color 0.25s ease, transform 0.25s ease;
}

a:hover {
    color: #4f46e5;
    text-decoration: underline;
    text-decoration-color: #8b5cf6;
    text-underline-offset: 3px;
}

/* 返回文章列表按钮 */
.back-link {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9rem;
    transition: all 0.25s ease;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    background: var(--bg-primary);
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.back-link::before {
    content: '\f060';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    font-size: 0.8em;
}

.back-link:hover {
    background: var(--primary);
    color: var(--text-inverse);
    border-color: var(--primary);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
    text-decoration: none;
}

.back-link:focus {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

@media (max-width: 768px) {
    .back-link {
        padding: 0.4rem 0.8rem;
        font-size: 0.85rem;
    }
}

/* 全局字体优化 */
body {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    animation: pageFadeIn 0.4s ease-out;
}

@keyframes pageFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* ============================================
   文章正文排版美化
   ============================================ */

/* 文章主内容区容器 - 限制最大阅读宽度 */
.main-content {
    max-width: 820px;
    margin: 0 auto;
    padding: 2.5rem 2rem 3rem;
}

/* 文章标题 h1 */
.main-content > h1 {
    font-size: 2rem;
    font-weight: 800;
    color: var(--text-primary);
    text-align: center;
    margin-bottom: 0.5rem;
    padding-bottom: 1.2rem;
    border-bottom: 2px solid transparent;
    border-image: linear-gradient(90deg, transparent, var(--primary), var(--secondary), transparent) 1;
    line-height: 1.4;
    letter-spacing: -0.02em;
}

/* h1 后紧跟的描述段落 */
.main-content > h1 + p {
    text-align: center;
    color: var(--text-secondary);
    font-size: 1.05rem;
    line-height: 1.8;
    margin-bottom: 2rem;
    max-width: 650px;
    margin-left: auto;
    margin-right: auto;
}

/* h2 二级标题 */
.main-content > h2 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
    margin: 2.5rem 0 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
    position: relative;
    padding-left: 1rem;
    line-height: 1.4;
}

.main-content > h2::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0.1em;
    bottom: 0.6em;
    width: 4px;
    border-radius: 2px;
    background: linear-gradient(180deg, var(--primary), var(--secondary));
}

/* h3 三级标题 */
.main-content > h3 {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 2rem 0 0.75rem;
    padding-left: 0.8rem;
    border-left: 3px solid var(--accent);
    line-height: 1.5;
}

/* h4 四级标题 */
.main-content > h4 {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 1.5rem 0 0.5rem;
}

/* 段落排版 */
.main-content > p {
    margin: 1.2rem 0;
    line-height: 1.85;
    font-size: 0.95rem;
    color: var(--text-primary);
}

/* 列表 */
.main-content > ul,
.main-content > ol {
    margin: 1rem 0 1.5rem 0;
    padding-left: 1.8rem;
}

.main-content > ul {
    list-style: none;
    padding-left: 0;
}

.main-content > ul > li {
    position: relative;
    padding-left: 1.5rem;
    margin: 0.6rem 0;
    line-height: 1.8;
    font-size: 0.95rem;
    color: var(--text-primary);
}

.main-content > ul > li::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0.7em;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
}

.main-content > ol > li {
    margin: 0.6rem 0;
    line-height: 1.8;
    font-size: 0.95rem;
    color: var(--text-primary);
}

.main-content > ol > li::marker {
    color: var(--primary);
    font-weight: 600;
}

li::marker {
    color: var(--primary);
}

/* 分隔线 */
.main-content > hr,
.main-content > hr.section-divider {
    border: none;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--border-color), transparent);
    margin: 2.5rem 0;
}

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

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, #6366f1, #8b5cf6);
    border-radius: 99px;
    border: 2px solid transparent;
    background-clip: padding-box;
}

::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, #4f46e5, #7c3aed);
    background-clip: padding-box;
}

* {
    scrollbar-width: thin;
    scrollbar-color: #6366f1 transparent;
}

/* 选中文字美化 */
::selection {
    background: rgba(99, 102, 241, 0.2);
    color: inherit;
}

/* 图片美化 */
img {
    image-rendering: -webkit-optimize-contrast;
    border-radius: 8px;
    max-width: 100%;
    height: auto;
}

/* 代码块增强 */
pre {
    border-radius: 12px !important;
    overflow-x: auto; /* 移动端横向滑动 */
    overflow-y: hidden;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08) !important;
    transition: box-shadow 0.3s ease;
    -webkit-overflow-scrolling: touch; /* iOS 惯性滑动 */
}

pre:hover {
    box-shadow: 0 6px 30px rgba(0, 0, 0, 0.12) !important;
}

/* 代码块内 code 不换行，保证横向滑动生效 */
pre > code {
    white-space: pre;
    display: block;
    min-width: max-content;
}

/* 无 hljs 的纯 pre > code 也需要明确的文字颜色 */
pre > code:not(.hljs) {
    color: #24292e !important;
}

[data-theme="dark"] pre > code:not(.hljs) {
    color: #cdd6f4 !important;
}

/* 保护 hljs 语法高亮颜色不被覆盖 - 亮色模式 */
pre code.hljs {
    color: #24292e !important;
}

pre code.hljs .hljs-keyword,
pre code.hljs .hljs-selector-tag,
pre code.hljs .hljs-built_in { color: #d73a49 !important; }
pre code.hljs .hljs-string,
pre code.hljs .hljs-attr,
pre code.hljs .hljs-symbol,
pre code.hljs .hljs-bullet { color: #032f62 !important; }
pre code.hljs .hljs-title,
pre code.hljs .hljs-section { color: #6f42c1 !important; font-weight: bold !important; }
pre code.hljs .hljs-comment,
pre code.hljs .hljs-doctag { color: #6a737d !important; font-style: italic !important; }
pre code.hljs .hljs-number,
pre code.hljs .hljs-literal,
pre code.hljs .hljs-type,
pre code.hljs .hljs-params,
pre code.hljs .hljs-link { color: #005cc5 !important; }
pre code.hljs .hljs-meta { color: #22863a !important; }
pre code.hljs .hljs-deletion { color: #b31d28 !important; background-color: #ffeef0 !important; }
pre code.hljs .hljs-addition { color: #22863a !important; background-color: #f0fff4 !important; }

/* 暗色模式代码块背景（包括无 hljs 的纯 pre）*/
[data-theme="dark"] pre,
[data-theme="dark"] pre code.hljs,
[data-theme="dark"] .hljs {
    background-color: #1e1e2e !important;
    border-color: #313244 !important;
}

/* 暗色模式 hljs 颜色 */
[data-theme="dark"] pre code.hljs {
    color: #cdd6f4 !important;
}

[data-theme="dark"] pre code.hljs .hljs-keyword,
[data-theme="dark"] pre code.hljs .hljs-selector-tag,
[data-theme="dark"] pre code.hljs .hljs-built_in { color: #f38ba8 !important; }
[data-theme="dark"] pre code.hljs .hljs-string,
[data-theme="dark"] pre code.hljs .hljs-attr,
[data-theme="dark"] pre code.hljs .hljs-symbol,
[data-theme="dark"] pre code.hljs .hljs-bullet { color: #a6e3a1 !important; }
[data-theme="dark"] pre code.hljs .hljs-title,
[data-theme="dark"] pre code.hljs .hljs-section { color: #cba6f7 !important; }
[data-theme="dark"] pre code.hljs .hljs-comment,
[data-theme="dark"] pre code.hljs .hljs-doctag { color: #6c7086 !important; }
[data-theme="dark"] pre code.hljs .hljs-number,
[data-theme="dark"] pre code.hljs .hljs-literal,
[data-theme="dark"] pre code.hljs .hljs-type,
[data-theme="dark"] pre code.hljs .hljs-params { color: #fab387 !important; }
[data-theme="dark"] pre code.hljs .hljs-link { color: #89b4fa !important; }
[data-theme="dark"] pre code.hljs .hljs-meta { color: #94e2d5 !important; }

code {
    font-family: 'JetBrains Mono', 'Fira Code', 'Consolas', 'Monaco', monospace !important;
}

/* 行内代码（排除 pre 内的代码块，保留 hljs 高亮） */
.main-content > p > code:not(.hljs),
.main-content > li > code:not(.hljs),
.main-content > td > code:not(.hljs),
.main-content > th > code:not(.hljs) {
    font-size: 0.88em;
    background: rgba(99, 102, 241, 0.08);
    color: var(--primary);
    padding: 0.15rem 0.45rem;
    border-radius: 4px;
    font-weight: 500;
}

[data-theme="dark"] .main-content > p > code:not(.hljs),
[data-theme="dark"] .main-content > li > code:not(.hljs) {
    background: rgba(99, 102, 241, 0.15);
}

/* 复制按钮美化 */
.copy-button {
    border-radius: 6px !important;
    transition: all 0.25s ease !important;
    opacity: 0.7;
}

.copy-button:hover {
    opacity: 1;
    transform: scale(1.05);
}

/* 表格美化 */
table {
    border-collapse: separate;
    border-spacing: 0;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
    width: 100%;
    margin: 1.5rem 0;
    font-size: 0.9rem;
}

th {
    background: linear-gradient(135deg, #6366f1, #8b5cf6) !important;
    color: #fff !important;
    padding: 0.75rem 1rem !important;
    font-weight: 600;
    text-align: left;
}

td {
    padding: 0.65rem 1rem !important;
    border-bottom: 1px solid var(--border-color) !important;
    transition: background 0.2s ease;
}

tr:last-child td {
    border-bottom: none !important;
}

tr:hover td {
    background: rgba(99, 102, 241, 0.04);
}

[data-theme="dark"] th {
    background: linear-gradient(135deg, #4338ca, #6d28d9) !important;
}

[data-theme="dark"] td {
    border-bottom-color: rgba(255, 255, 255, 0.06) !important;
}

/* 引用块美化 */
blockquote {
    border-left: 4px solid #6366f1 !important;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.05), rgba(139, 92, 246, 0.03)) !important;
    border-radius: 0 8px 8px 0 !important;
    padding: 1em 1.5em !important;
    margin: 1.5rem 0 !important;
}

[data-theme="dark"] blockquote {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.1), rgba(139, 92, 246, 0.06)) !important;
    border-left-color: var(--primary-light, #818cf8) !important;
}

/* ============================================
   提示框统一美化（note/highlight/tip/warning）
   ============================================ */
.main-content > .note,
.main-content > .highlight,
.main-content > .tip,
.main-content > .warning,
.main-content > .info,
.main-content > .danger {
    padding: 1rem 1.25rem;
    margin: 1.5rem 0;
    border-radius: var(--radius-lg);
    border-left: 4px solid;
    transition: transform 0.2s ease;
}

.main-content > .note:hover,
.main-content > .highlight:hover,
.main-content > .tip:hover,
.main-content > .warning:hover {
    transform: translateX(4px);
}

/* note 提示框 */
.main-content > .note {
    background: rgba(59, 130, 246, 0.06);
    border-left-color: #3b82f6;
}

.main-content > .note .note-title {
    font-weight: 600;
    color: #2563eb;
    margin-bottom: 0.4rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

/* highlight 高亮框 */
.main-content > .highlight {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.06), rgba(245, 158, 11, 0.03));
    border-left-color: #f59e0b;
}

/* warning 警告框 */
.main-content > .warning {
    background: rgba(239, 68, 68, 0.06);
    border-left-color: #ef4444;
}

/* tip 提示框 */
.main-content > .tip {
    background: rgba(34, 197, 94, 0.06);
    border-left-color: #22c55e;
}

/* info 信息框 */
.main-content > .info {
    background: rgba(6, 182, 212, 0.06);
    border-left-color: #06b6d4;
}

/* danger 危险框 */
.main-content > .danger {
    background: rgba(239, 68, 68, 0.08);
    border-left-color: #dc2626;
}

/* 暗色模式提示框适配 */
[data-theme="dark"] .main-content > .note {
    background: rgba(59, 130, 246, 0.1);
    border-left-color: #60a5fa;
}

[data-theme="dark"] .main-content > .note .note-title {
    color: #60a5fa;
}

[data-theme="dark"] .main-content > .highlight {
    background: rgba(245, 158, 11, 0.1);
}

[data-theme="dark"] .main-content > .warning {
    background: rgba(239, 68, 68, 0.1);
}

[data-theme="dark"] .main-content > .tip {
    background: rgba(34, 197, 94, 0.1);
}

[data-theme="dark"] .main-content > .info {
    background: rgba(6, 182, 212, 0.1);
}

[data-theme="dark"] .main-content > .danger {
    background: rgba(239, 68, 68, 0.12);
}

/* 行内高亮 span.highlight */
.main-content span.highlight {
    background: rgba(245, 158, 11, 0.15);
    padding: 0.1rem 0.35rem;
    border-radius: 4px;
    font-weight: 500;
    color: var(--text-primary);
}

[data-theme="dark"] .main-content span.highlight {
    background: rgba(245, 158, 11, 0.25);
}

/* 卡片美化 */
.main-content > .card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    margin: 1.5rem 0;
    box-shadow: var(--shadow-sm);
    transition: all 0.25s ease;
}

.main-content > .card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
    border-color: var(--primary-light);
}

/* 数学公式 */
.main-content > p.math-equation {
    text-align: center;
    font-size: 1.1rem;
    padding: 1.5rem;
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    margin: 1.5rem auto;
    max-width: fit-content;
}

/* 技术关键词 */
.tech {
    display: inline-block;
    padding: 0.1em 0.4em;
    background: rgba(99, 102, 241, 0.1);
    color: #6366f1;
    border-radius: 4px;
    font-size: 0.85em;
    font-weight: 500;
}

/* ============================================
   返回顶部按钮
   ============================================ */
#back-to-top {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: #fff;
    border: none;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 999;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.4);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-size: 1.1rem;
}

#back-to-top:hover {
    transform: translateY(-4px) scale(1.08);
    box-shadow: 0 8px 30px rgba(99, 102, 241, 0.5);
}

#back-to-top.show {
    display: flex;
}

/* ============================================
   页脚统一美化（文章页通用）
   ============================================ */
footer {
    position: relative;
    background: linear-gradient(180deg, #fafbff 0%, #f0f2ff 100%);
    border-top: none !important;
    padding: 2.5rem 1rem 1.5rem !important;
    margin-top: 3rem;
    overflow: hidden;
    text-align: center;
}

[data-theme="dark"] footer {
    background: linear-gradient(180deg, #0f172a 0%, #1e1b4b 100%);
}

footer .footer-content {
    max-width: 800px;
    margin: 0 auto;
}

/* 顶部流光条 */
.footer-glow {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, #3b82f6, #8b5cf6, #ec4899, #f59e0b, #3b82f6);
    background-size: 200% 100%;
    animation: footerGlow 4s linear infinite;
}

@keyframes footerGlow {
    0% { background-position: 0% 50%; }
    100% { background-position: 200% 50%; }
}

/* 兼容：无 .footer-glow 时用 ::before 伪元素 */
footer:not(:has(.footer-glow))::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, #3b82f6, #8b5cf6, #ec4899, #f59e0b, #3b82f6);
    background-size: 200% 100%;
    animation: footerGlow 4s linear infinite;
}

@keyframes footerGradient {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

/* 品牌区域 */
.footer-brand {
    text-align: center;
    margin-bottom: 1.2rem;
}

.footer-logo {
    font-size: 1.25rem;
    font-weight: 700;
    color: #4361ee;
    margin-bottom: 0.4rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    letter-spacing: -0.02em;
}

[data-theme="dark"] .footer-logo {
    color: var(--primary-light);
}

.footer-desc {
    color: #6b7280;
    font-size: 0.9rem;
    line-height: 1.8;
    max-width: 500px;
    margin: 0 auto;
}

/* 社交图标 */
.footer .social-links {
    display: flex;
    justify-content: center;
    gap: 0.75rem;
    margin: 1rem 0;
    flex-wrap: wrap;
}

.footer .social-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    color: #9ca3af;
    border-radius: 50%;
    font-size: 1rem;
    transition: all 0.3s ease;
    text-decoration: none;
    border: 1px solid #e5e7eb;
    background: #fff;
}

[data-theme="dark"] .footer .social-icon {
    border-color: rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.05);
}

.footer .social-icon[title="GitHub"] {
    color: #8b5cf6;
    border-color: rgba(139, 92, 246, 0.3);
    background: rgba(139, 92, 246, 0.05);
}

.footer .social-icon[title="GitHub"]:hover {
    background: linear-gradient(135deg, #8b5cf6, #a78bfa);
    color: #fff;
    border-color: transparent;
    transform: translateY(-3px) scale(1.08);
    box-shadow: 0 6px 16px rgba(139, 92, 246, 0.3);
}

.footer .social-icon[title="微博"] {
    color: #ef4444;
    border-color: rgba(239, 68, 68, 0.3);
    background: rgba(239, 68, 68, 0.05);
}

.footer .social-icon[title="微博"]:hover {
    background: linear-gradient(135deg, #ef4444, #f87171);
    color: #fff;
    border-color: transparent;
    transform: translateY(-3px) scale(1.08);
    box-shadow: 0 6px 16px rgba(239, 68, 68, 0.3);
}

.footer .social-icon[title="知乎"] {
    color: #3b82f6;
    border-color: rgba(59, 130, 246, 0.3);
    background: rgba(59, 130, 246, 0.05);
}

.footer .social-icon[title="知乎"]:hover {
    background: linear-gradient(135deg, #3b82f6, #60a5fa);
    color: #fff;
    border-color: transparent;
    transform: translateY(-3px) scale(1.08);
    box-shadow: 0 6px 16px rgba(59, 130, 246, 0.3);
}

.footer .social-icon[title="邮箱"] {
    color: #10b981;
    border-color: rgba(16, 185, 129, 0.3);
    background: rgba(16, 185, 129, 0.05);
}

.footer .social-icon[title="邮箱"]:hover {
    background: linear-gradient(135deg, #10b981, #34d399);
    color: #fff;
    border-color: transparent;
    transform: translateY(-3px) scale(1.08);
    box-shadow: 0 6px 16px rgba(16, 185, 129, 0.3);
}

/* 底部信息区 */
.footer-bottom {
    margin-top: 1.5rem;
    padding: 1.2rem;
    background: #fff;
    border-radius: 12px;
    border: 1px solid #e5e7eb;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.03);
    position: relative;
}

[data-theme="dark"] .footer-bottom {
    background: rgba(255, 255, 255, 0.04);
    border-color: rgba(255, 255, 255, 0.08);
}

.footer-bottom::before {
    content: '';
    position: absolute;
    top: -1px;
    left: 15%;
    right: 15%;
    height: 2px;
    background: linear-gradient(90deg, transparent, #6366f1, transparent);
    opacity: 0.4;
}

.footer-meta-row {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1.2rem;
    margin-bottom: 0.5rem;
    flex-wrap: wrap;
    font-size: 0.85rem;
    color: #6b7280;
}

[data-theme="dark"] .footer-meta-row {
    color: var(--text-secondary);
}

.footer-meta-item {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
}

.footer-meta-item i {
    color: #6366f1;
    opacity: 0.7;
}

.footer-copyright {
    text-align: center;
    color: #9ca3af;
    font-size: 0.85rem;
    margin: 0.5rem 0;
    font-weight: 500;
}

[data-theme="dark"] .footer-copyright {
    color: var(--text-muted);
}

.footer-copyright i {
    color: #6366f1;
    margin-right: 4px;
}

/* 备案徽章 */
.footer-badges {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.6rem;
    margin-top: 0.6rem;
    flex-wrap: wrap;
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 12px;
    border-radius: 999px;
    font-size: 0.78rem;
    text-decoration: none;
    transition: all 0.25s ease;
    border: 1px solid #e5e7eb;
    background: #f9fafb;
    color: #9ca3af;
}

[data-theme="dark"] .badge {
    border-color: rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-muted);
}

.badge:hover {
    transform: translateY(-2px);
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.06);
}

.badge i {
    font-size: 0.7rem;
}

.badge img {
    width: 14px;
    height: 14px;
    vertical-align: middle;
}

.badge-icp:hover {
    border-color: #3b82f6;
    color: #3b82f6;
    background: rgba(59, 130, 246, 0.05);
}

.badge-police:hover {
    border-color: #10b981;
    color: #10b981;
    background: rgba(16, 185, 129, 0.05);
}

.badge-nobug:hover {
    border-color: #f59e0b;
    color: #f59e0b;
    background: rgba(245, 158, 11, 0.05);
}

/* 页脚链接增强 */
.footer-link {
    transition: color 0.25s ease, transform 0.25s ease;
    display: inline-block;
}

.footer-link:hover {
    color: #6366f1 !important;
    transform: translateY(-1px);
}

/* 页脚响应式 */
@media (max-width: 768px) {
    footer {
        padding: 2rem 0.8rem 1.2rem !important;
    }

    .footer-logo {
        font-size: 1.1rem;
    }

    .footer-bottom {
        padding: 1rem 0.8rem;
    }

    .footer-meta-row {
        gap: 0.8rem;
        font-size: 0.8rem;
    }

    .footer-badges {
        gap: 0.4rem;
    }

    .badge {
        padding: 3px 10px;
        font-size: 0.75rem;
    }
}

/* ============================================
   响应式适配
   ============================================ */
@media (max-width: 768px) {
    .main-content {
        padding: 1.5rem 1rem 2rem;
    }

    .main-content > h1 {
        font-size: 1.6rem;
        padding-left: 0.5rem;
        padding-right: 0.5rem;
    }

    .main-content > h2 {
        font-size: 1.3rem;
    }

    .main-content > h3 {
        font-size: 1.1rem;
    }

    /* 移动端长文阅读优化：字号、行宽、行距 */
    .main-content > p {
        font-size: 0.95rem; /* 提升到舒适阅读字号 */
        line-height: 1.9;   /* 增大行距减轻视觉疲劳 */
        max-width: 100%;
        word-break: break-word;
    }

    .main-content > h1 + p {
        font-size: 0.95rem;
        line-height: 1.8;
    }

    .main-content > ul > li,
    .main-content > ol > li {
        font-size: 0.93rem;
        line-height: 1.85;
    }

    /* 代码块字号略减，确保横向可读 */
    pre,
    pre > code {
        font-size: 0.82rem;
    }

    table {
        font-size: 0.82rem;
        display: block;
        overflow-x: auto;
    }
}

@media (min-width: 1201px) {
    /* 宽屏时为 TOC 预留左侧空间 - 仅当存在 TOC 时生效 */
    body.has-toc .main-content {
        margin-left: 310px;
        margin-right: 20px;
        max-width: calc(100vw - 330px);
    }
}

/* ============================================
   输入框和焦点
   ============================================ */
input:focus, textarea:focus {
    outline: none;
    border-color: #6366f1 !important;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15) !important;
}

/* Focus-visible 可访问性 */
*:focus-visible {
    outline: 2px solid #6366f1;
    outline-offset: 2px;
    border-radius: 4px;
}

/* 减弱动画偏好 */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ============================================
   代码主题（与页面主题同步）
   通过 body[data-code-theme="light|dark"] 控制
   data-code-theme 由 main.js 的 setTheme 自动同步
   ============================================ */

/* === 浅色代码主题（body[data-code-theme="light"]） === */
body[data-code-theme="light"] pre,
body[data-code-theme="light"] pre code.hljs,
body[data-code-theme="light"] .hljs {
    background-color: #f6f8fa !important;
    border-color: #d0d7de !important;
}

body[data-code-theme="light"] pre > code:not(.hljs) {
    color: #24292e !important;
}

body[data-code-theme="light"] pre code.hljs {
    color: #24292e !important;
}

body[data-code-theme="light"] pre code.hljs .hljs-keyword,
body[data-code-theme="light"] pre code.hljs .hljs-selector-tag,
body[data-code-theme="light"] pre code.hljs .hljs-built_in { color: #d73a49 !important; }

body[data-code-theme="light"] pre code.hljs .hljs-string,
body[data-code-theme="light"] pre code.hljs .hljs-attr,
body[data-code-theme="light"] pre code.hljs .hljs-symbol,
body[data-code-theme="light"] pre code.hljs .hljs-bullet { color: #032f62 !important; }

body[data-code-theme="light"] pre code.hljs .hljs-title,
body[data-code-theme="light"] pre code.hljs .hljs-section { color: #6f42c1 !important; font-weight: bold !important; }

body[data-code-theme="light"] pre code.hljs .hljs-comment,
body[data-code-theme="light"] pre code.hljs .hljs-doctag { color: #6a737d !important; font-style: italic !important; }

body[data-code-theme="light"] pre code.hljs .hljs-number,
body[data-code-theme="light"] pre code.hljs .hljs-literal,
body[data-code-theme="light"] pre code.hljs .hljs-type,
body[data-code-theme="light"] pre code.hljs .hljs-params,
body[data-code-theme="light"] pre code.hljs .hljs-link { color: #005cc5 !important; }

body[data-code-theme="light"] pre code.hljs .hljs-meta { color: #22863a !important; }

/* === 深色代码主题（body[data-code-theme="dark"]） === */
body[data-code-theme="dark"] pre,
body[data-code-theme="dark"] pre code.hljs,
body[data-code-theme="dark"] .hljs {
    background-color: #1e1e2e !important;
    border-color: #313244 !important;
}

body[data-code-theme="dark"] pre > code:not(.hljs) {
    color: #cdd6f4 !important;
}

body[data-code-theme="dark"] pre code.hljs {
    color: #cdd6f4 !important;
}

body[data-code-theme="dark"] pre code.hljs .hljs-keyword,
body[data-code-theme="dark"] pre code.hljs .hljs-selector-tag,
body[data-code-theme="dark"] pre code.hljs .hljs-built_in { color: #f38ba8 !important; }

body[data-code-theme="dark"] pre code.hljs .hljs-string,
body[data-code-theme="dark"] pre code.hljs .hljs-attr,
body[data-code-theme="dark"] pre code.hljs .hljs-symbol,
body[data-code-theme="dark"] pre code.hljs .hljs-bullet { color: #a6e3a1 !important; }

body[data-code-theme="dark"] pre code.hljs .hljs-title,
body[data-code-theme="dark"] pre code.hljs .hljs-section { color: #cba6f7 !important; }

body[data-code-theme="dark"] pre code.hljs .hljs-comment,
body[data-code-theme="dark"] pre code.hljs .hljs-doctag { color: #6c7086 !important; }

body[data-code-theme="dark"] pre code.hljs .hljs-number,
body[data-code-theme="dark"] pre code.hljs .hljs-literal,
body[data-code-theme="dark"] pre code.hljs .hljs-type,
body[data-code-theme="dark"] pre code.hljs .hljs-params { color: #fab387 !important; }

body[data-code-theme="dark"] pre code.hljs .hljs-link { color: #89b4fa !important; }

body[data-code-theme="dark"] pre code.hljs .hljs-meta { color: #94e2d5 !important; }

/* ============================================
   收藏按钮样式
   ============================================ */
.article-bookmark-section {
    margin: 1.5rem 0;
    display: flex;
    justify-content: center;
}

.article-bookmark-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1.4rem;
    border: 1px solid var(--border-color, #e5e7eb);
    border-radius: 999px;
    background: var(--bg-primary, #fff);
    color: var(--text-secondary, #6b7280);
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.25s ease;
    touch-action: manipulation;
}

.article-bookmark-btn:hover {
    border-color: var(--primary, #6366f1);
    color: var(--primary, #6366f1);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.15);
}

.article-bookmark-btn.bookmarked {
    background: linear-gradient(135deg, #f59e0b, #f97316);
    color: #fff;
    border-color: transparent;
}

.article-bookmark-btn.bookmarked i {
    color: #fff;
}

.article-bookmark-btn i {
    font-size: 1rem;
    transition: transform 0.25s ease;
}

.article-bookmark-btn.bookmarked:hover i {
    transform: scale(1.2);
}

/* ============================================
   CodePen 嵌入交互演示区
   ============================================ */
.codepen-embed-section {
    margin: 2rem 0;
    padding: 1.25rem;
    border: 1px solid var(--border-color, #e5e7eb);
    border-radius: var(--radius-lg, 12px);
    background: var(--bg-secondary, #f9fafb);
}

.codepen-embed-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.codepen-embed-title {
    font-weight: 600;
    color: var(--text-primary);
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.95rem;
}

.codepen-embed-title i {
    color: var(--primary, #6366f1);
}

.codepen-embed-toggle {
    font-size: 0.85rem;
    color: var(--primary, #6366f1);
    cursor: pointer;
    border: none;
    background: transparent;
    padding: 0.25rem 0.6rem;
    border-radius: 6px;
    transition: background 0.2s ease;
}

.codepen-embed-toggle:hover {
    background: rgba(99, 102, 241, 0.08);
}

.codepen-embed-frame {
    width: 100%;
    height: 360px;
    border: 1px solid var(--border-color, #e5e7eb);
    border-radius: 8px;
    background: #fff;
}

.codepen-embed-frame[hidden] {
    display: none;
}

/* ============================================
   文章页订阅卡片
   ============================================ */
.article-subscribe-section {
    margin: 2.5rem 0;
}
.subscribe-card {
    background: linear-gradient(135deg, rgba(99,102,241,0.06), rgba(139,92,246,0.06));
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    padding: 1.5rem 2rem;
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: center;
}
.subscribe-card-icon {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 1.2rem;
    flex-shrink: 0;
}
.subscribe-card-content {
    flex: 1;
    min-width: 200px;
}
.subscribe-card-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}
.subscribe-card-desc {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.5;
}
.subscribe-card-form {
    display: flex;
    gap: 0.5rem;
    width: 100%;
    max-width: 320px;
}
.subscribe-card-input {
    flex: 1;
    padding: 0.6rem 0.8rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 0.88rem;
    background: var(--bg-primary);
    color: var(--text-primary);
    outline: none;
    transition: border-color 0.2s;
}
.subscribe-card-input:focus {
    border-color: var(--primary);
}
.subscribe-card-btn {
    padding: 0.6rem 1rem;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: var(--radius-md);
    font-size: 0.88rem;
    cursor: pointer;
    transition: opacity 0.2s;
    white-space: nowrap;
    touch-action: manipulation;
}
.subscribe-card-btn:hover {
    opacity: 0.9;
}
.subscribe-card-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}
.subscribe-card-msg {
    width: 100%;
    font-size: 0.82rem;
    min-height: 1.2rem;
}

/* 系列单独订阅按钮区域 */
.subscribe-series-toggle {
    width: 100%;
    margin-top: 0.5rem;
    padding-top: 0.75rem;
    border-top: 1px dashed var(--border-color);
}
.series-subscribe-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 0.9rem;
    background: transparent;
    color: var(--primary);
    border: 1px solid var(--primary);
    border-radius: var(--radius-md);
    font-size: 0.82rem;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
    touch-action: manipulation;
}
.series-subscribe-btn:hover {
    background: var(--primary);
    color: #fff;
}
.series-subscribe-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}
.series-subscribe-msg {
    margin-top: 0.4rem;
    font-size: 0.8rem;
    min-height: 1.1rem;
}

@media (max-width: 768px) {
    .subscribe-card {
        padding: 1.25rem 1.25rem;
    }
    .subscribe-card-form {
        max-width: 100%;
    }
}

/* 配套视频嵌入 */
.video-embed-section {
    margin: 1.5rem 0;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
}
.video-embed-header {
    padding: 0.75rem 1.25rem;
    background: linear-gradient(135deg, rgba(99,102,241,0.08), rgba(236,72,153,0.08));
    border-bottom: 1px solid var(--border-color);
}
.video-embed-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.video-embed-title i {
    color: var(--primary);
}
.video-embed-frame {
    padding: 1rem;
    position: relative;
    padding-top: 56.25%;
    height: 0;
    overflow: hidden;
}
.video-embed-frame iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: 0;
}
.video-embed-link {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem 1.25rem;
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
}
.video-embed-link:hover {
    text-decoration: underline;
}
@media (max-width: 768px) {
    .video-embed-frame {
        padding-top: 56.25%;
    }
}
