/* ================== 0. 引入外部字体 ================== */
@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;600&display=swap');

/* ================== 1. 主题变量 ================== */
:root {
    --bg-body: #fdfdfd; --bg-grid: #eaeaea; --bg-card: #ffffff;
    --text-main: #333333; --text-meta: #888888; --border-color: #f0f0f0;
    --hover-bg: #f0fdf4; --link-color: #555555; --link-hover: #4caf50;
    --code-bg: #f4f5f7; --code-text: #333333; --code-header-bg: #e9ebef;
    --code-header-text: #666666; --code-border: #e0e2e6;
}

/* 深度优化版暗黑模式 (参考 NodeSeek 雅致深灰) */
[data-theme="dark"] {
    --bg-body: #0d0d0d; --bg-grid: #2c2c2c; --bg-card: #1a1a1a;
    --text-main: #f0f0f0; --text-meta: #808080; --border-color: #333333;
    --hover-bg: #2d3730; --link-color: #bbbbbb; --link-hover: #66bb6a;
    --code-bg: #1e1e1e; --code-text: #e3e3e3; --code-header-bg: #2d2d2d;
    --code-header-text: #aaaaaa; --code-border: #444444;
}

/* ================== 2. 基础重置 ================== */
body {
    margin: 0; padding: 0;
    /* 核心修改：英文优先 JetBrains Mono，中文调用苹方，最后给出安全备用 */
    font-family: 'JetBrains Mono', 'PingFang SC', -apple-system, BlinkMacSystemFont, "Microsoft YaHei", sans-serif;
    background-color: var(--bg-body); color: var(--text-main);
    background-image: linear-gradient(var(--bg-grid) 1px, transparent 1px), linear-gradient(90deg, var(--bg-grid) 1px, transparent 1px);
    background-size: 25px 25px; transition: background-color 0.3s, color 0.3s;
}
a { text-decoration: none; color: var(--link-color); transition: color 0.2s;}
a:hover { color: var(--link-hover); }

/* ================== 3. 全局布局 (改为单栏) ================== */
.container {
    display: flex; 
    flex-direction: column; 
    max-width: 850px; 
    margin: 20px auto; gap: 20px; padding: 0 15px;
}
.main-content {
    background: var(--bg-card); border-radius: 8px; 
    box-shadow: 0 1px 5px rgba(0,0,0,0.05); min-width: 0;
}

/* ================== 4. 顶部导航栏 ================== */
.top-nav {
    display: flex; justify-content: space-between; align-items: center;
    background: var(--bg-card); border-radius: 8px; padding: 10px 20px; 
    box-shadow: 0 1px 5px rgba(0,0,0,0.05);
}
.nav-menu {
    display: flex; gap: 5px; overflow-x: auto; white-space: nowrap; 
    -webkit-overflow-scrolling: touch;
}
.nav-menu::-webkit-scrollbar { display: none; }
.nav-menu a {
    display: inline-block; padding: 8px 16px; border-radius: 6px; 
    font-size: 15px; color: var(--text-main);
}
.nav-menu a.active, .nav-menu a:hover { color: var(--link-hover); background: var(--hover-bg); }

.theme-toggle-img {
    width: 24px; height: 24px; cursor: pointer; opacity: 0.7; 
    transition: all 0.3s ease; flex-shrink: 0; margin-left: 15px;
}
.theme-toggle-img:hover { opacity: 1; transform: scale(1.1); }
[data-theme="dark"] .theme-toggle-img { filter: invert(0.85); }

/* ================== 5. 文章列表 ================== */
.post-list-item { display: flex; padding: 18px 20px; border-bottom: 1px solid var(--border-color); align-items: center; gap: 15px; }
.post-list-item:last-child { border-bottom: none; }
.post-avatar img { width: 40px; height: 40px; border-radius: 6px; background: #eee; object-fit: cover; }
.post-info { flex: 1; }
.post-title { margin: 0 0 8px 0; font-size: 16.5px; font-weight: 600; line-height: 1.4; } 

.post-meta { 
    font-size: 12.5px; color: var(--text-meta); display: flex; gap: 15px; flex-wrap: wrap;
    filter: grayscale(100%); opacity: 0.6; transition: opacity 0.3s;
} 
[data-theme="dark"] .post-meta { opacity: 0.35; }

.sticky-badge {
    background: #ff5252; color: #fff; font-size: 12px; padding: 2px 6px;
    border-radius: 4px; margin-right: 6px; vertical-align: middle; font-weight: 500;
}

.post-category {
    font-size: 12.5px; color: var(--text-meta); border: 1px solid var(--border-color); 
    padding: 3px 8px; border-radius: 4px; display: flex; align-items: center; gap: 5px; 
    flex-shrink: 0; 
}

/* ================== 6. 文章详情页 ================== */
.post-content-wrap { padding: 25px; }
.post-header { border-bottom: 1px solid var(--border-color); padding-bottom: 15px; margin-bottom: 15px; }
.post-header h1 { margin: 0 0 10px 0; font-size: 22px; }

/* 修复：长链接强制换行的代码 */
.post-body { 
    line-height: 1.7; 
    font-size: 15px; 
    overflow-wrap: break-word; 
    word-wrap: break-word; 
    word-break: break-word; 
}
.post-body ul, .post-body ol { padding-left: 20px; margin: 15px 0; }
.post-body li { margin-bottom: 10px; line-height: 1.7; }
.post-body img { max-width: 100%; height: auto; display: block; border-radius: 6px; margin: 15px 0; }
[data-theme="dark"] .post-body img { filter: brightness(0.9); }

/* ================== 7. 提示框 (Callout) 样式 ================== */
.alert { padding: 15px 15px 15px 20px; margin: 20px 0; border-radius: 6px; border-left: 4px solid; font-size: 14.5px; line-height: 1.6; }
.alert-recommend { background-color: rgba(76, 175, 80, 0.08); border-color: #4caf50; color: var(--text-main); }
.alert-recommend::before { content: "💡 推荐："; font-weight: bold; color: #4caf50; margin-right: 5px; }
.alert-note { background-color: rgba(33, 150, 243, 0.08); border-color: #2196f3; color: var(--text-main); }
.alert-note::before { content: "ℹ️ 注意："; font-weight: bold; color: #2196f3; margin-right: 5px; }
.alert-warning { background-color: rgba(255, 152, 0, 0.08); border-color: #ff9800; color: var(--text-main); }
.alert-warning::before { content: "⚠️ 警告："; font-weight: bold; color: #ff9800; margin-right: 5px; }

/* ================== 8. 音频与视频播放器样式 (固定与深度修复) ================== */
/* 统一音频播放器样式 */
.post-audio {
    width: 100%;
    margin: 20px 0;
    border-radius: 8px;
    outline: none;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    background-color: transparent !important; /* 核心：背景透明，彻底解决白边刺眼问题 */
}

/* 统一视频播放器容器 */
.dplayer-custom-container {
    width: 100%;
    margin: 20px 0;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0,0,0,0.08);
    background: #000;
    line-height: 0; /* 消除视频底部的细微空隙 */
    height: 450px; /* 核心：固定高度增加，使视频区域更雅致 */
    min-height: 400px;
}

/* 内部视频标签自适应 */
.dplayer-custom-container video {
    width: 100%;
    height: 100%; /* 填满容器 */
    display: block;
    outline: none;
    object-fit: contain; /* 核心：保持原比例缩放并居中显示 */
}

/* 暗黑模式下对播放器的微调 */
[data-theme="dark"] .dplayer-custom-container { 
    box-shadow: 0 2px 10px rgba(0,0,0,0.5); 
}
[data-theme="dark"] .post-audio {
    opacity: 0.9;
    background-color: transparent !important;
    color-scheme: dark; /* 核心：应用暗黑颜色方案，修复 native 控件的白边问题 */
}

/* ================== 9. 代码块与分页 ================== */
.post-body pre { background: var(--code-bg) !important; color: var(--code-text) !important; border-radius: 8px; padding: 0 !important; margin: 15px 0; overflow: hidden; border: 1px solid var(--code-border); }
.code-header { display: flex; justify-content: space-between; align-items: center; background: var(--code-header-bg); padding: 8px 15px; font-size: 12.5px; color: var(--code-header-text); border-bottom: 1px solid var(--code-border); }
.code-copy-btn { background: transparent; border: none; color: var(--code-header-text); cursor: pointer; display: flex; align-items: center; gap: 4px; font-size: 12px; padding: 0; outline: none; }
.code-copy-btn:hover { color: var(--link-hover); }

/* 核心修改：代码块专属字体，保证英文字符完美等宽 */
.post-body pre code { 
    display: block; padding: 15px; overflow-x: auto; 
    font-family: 'JetBrains Mono', Consolas, Monaco, monospace; 
    font-size: 14.5px; line-height: 1.5; 
}

.page-navigator { list-style: none; padding: 0; margin: 20px 0; display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; }
.page-navigator li { display: inline-block; }
.page-navigator li a, .page-navigator li span { display: inline-block; padding: 6px 12px; background: var(--bg-card); border: 1px solid var(--border-color); border-radius: 4px; color: var(--text-main); font-size: 14px; }
.page-navigator li a:hover { background: var(--hover-bg); color: var(--link-hover); border-color: var(--link-hover); }
.page-navigator li.current a { background: #4caf50; color: #fff; border-color: #4caf50; }

/* ================== 10. 单栏底部标签云 ================== */
.bottom-tag-cloud {
    margin-top: 20px; padding: 20px; background: var(--bg-card);
    border-radius: 8px; box-shadow: 0 1px 5px rgba(0,0,0,0.05);
}
.bottom-tag-cloud .tag-cloud-title {
    font-size: 14.5px; font-weight: 600; margin-bottom: 15px; color: var(--text-main);
}
.bottom-tag-cloud .tag-list {
    display: flex; flex-wrap: wrap; gap: 10px; 
}
.bottom-tag-cloud .tag-list a {
    background: var(--bg-body); border: 1px solid var(--border-color);
    padding: 6px 14px; font-size: 13px; border-radius: 20px; 
    color: var(--text-meta); transition: all 0.2s;
}
.bottom-tag-cloud .tag-list a:hover {
    background: var(--hover-bg); color: var(--link-hover); border-color: var(--link-hover);
}

/* ================== 11. 移动端微调 ================== */
@media (max-width: 768px) {
    .container { padding: 10px; margin: 0; gap: 15px;}
    .post-list-item { padding: 15px; align-items: flex-start; }
    .post-avatar img { width: 36px; height: 36px; }
    .post-title { font-size: 15.5px; margin-bottom: 6px; }
    .top-nav { padding: 8px 15px; }
    .post-category { display: none !important; }
}