/* ===== CSS 变量 ===== */
:root {
    --theme: #91a3b9;
    --theme-dark: #6b7f94;
    --theme-light: #c5d4e8;
    --theme-glow: rgba(145, 163, 185, 0.25);
    
    --bg: #0a0e17;
    --card: rgba(255, 255, 255, 0.05);
    --card-border: rgba(255, 255, 255, 0.08);
    --text: #e8ecf0;
    --text-secondary: #a8b2c8;
    --text-light: #6b7f94;
    --border: rgba(255, 255, 255, 0.06);
    --shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    --radius: 16px;
    
    --font: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", sans-serif;
    --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ===== 亮色模式 ===== */
[data-theme="light"] {
    --bg: #f0f2f5;
    --card: rgba(255, 255, 255, 0.85);
    --card-border: rgba(0, 0, 0, 0.06);
    --text: #1a2332;
    --text-secondary: #5d6d7e;
    --text-light: #95a5a6;
    --border: rgba(0, 0, 0, 0.06);
    --shadow: 0 8px 32px rgba(0, 0, 0, 0.08);
}

/* ===== 基础 ===== */
* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    line-height: 1.8;
    padding-top: 64px;
    min-height: 100vh;
    overflow-x: hidden;
    transition: background var(--transition), color var(--transition);
}

a {
    color: var(--theme);
    text-decoration: none;
    transition: color var(--transition);
}
a:hover { color: var(--text); }

/* ===== 星空画布（底层） ===== */
#star-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
}

/* ===== 鼠标拖尾画布（最上层） ===== */
#mouse-trail-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
}

/* ===== 滚动条 ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: rgba(255,255,255,0.03); border-radius: 3px; }
::-webkit-scrollbar-thumb { background: var(--theme); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--theme-dark); }

/* ===== 顶部导航 ===== */
#header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    background: rgba(10, 14, 23, 0.8);
    backdrop-filter: blur(16px) saturate(180%);
    -webkit-backdrop-filter: blur(16px) saturate(180%);
    border-bottom: 1px solid var(--border);
    padding: 0 5%;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: background var(--transition), border-color var(--transition);
}
[data-theme="light"] #header {
    background: rgba(255, 255, 255, 0.85);
}

#blogTitle { display: flex; align-items: baseline; gap: 14px; }
#blogTitle h1 a {
    font-size: 22px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: 0.5px;
}
#blogTitle h2 {
    font-size: 14px;
    font-weight: 400;
    color: var(--text-secondary);
}

#navigator { display: flex; align-items: center; gap: 4px; }
#navList { display: flex; list-style: none; gap: 2px; }
#navList li a {
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 14px;
    color: var(--text-secondary);
    transition: all var(--transition);
}
#navList li a:hover {
    background: var(--theme);
    color: #fff;
}

/* ===== 暗色切换按钮 ===== */
.theme-toggle {
    cursor: pointer;
    padding: 6px 12px;
    border-radius: 20px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-secondary);
    font-size: 16px;
    transition: all var(--transition);
    margin-left: 8px;
}
.theme-toggle:hover {
    border-color: var(--theme);
    background: var(--theme-glow);
}

.blogStats {
    font-size: 12px;
    color: var(--text-light);
    margin-left: 16px;
}

/* ===== 主体 ===== */
#main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px 40px;
    display: flex;
    gap: 30px;
    align-items: flex-start;
    position: relative;
    z-index: 1;
}

#mainContent { flex: 1; min-width: 0; }

.forFlow {
    background: var(--card);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: var(--radius);
    border: 1px solid var(--card-border);
    box-shadow: var(--shadow);
    overflow: hidden;
    transition: background var(--transition), box-shadow var(--transition), border-color var(--transition);
}

/* ===== 文章列表 ===== */
.day {
    padding: 32px 36px;
    border-bottom: 1px solid var(--border);
    transition: all var(--transition);
}
.day:last-child { border-bottom: none; }
.day:hover {
    background: rgba(255, 255, 255, 0.03);
    transform: translateY(-2px);
}
[data-theme="light"] .day:hover {
    background: rgba(0, 0, 0, 0.02);
}

.dayTitle {
    font-size: 13px;
    color: var(--text-light);
    margin-bottom: 6px;
}
.dayTitle a { color: var(--text-light); }

.postTitle {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 8px;
}
.postTitle a { color: var(--text); }
.postTitle a:hover { color: var(--theme); }

.c_b_p_desc {
    font-size: 15px;
    color: var(--text-secondary);
    line-height: 1.8;
}

.c_b_p_desc_readmore {
    display: inline-block;
    margin-top: 12px;
    padding: 5px 24px;
    border: 1.5px solid var(--theme);
    border-radius: 24px;
    font-size: 13px;
    font-weight: 500;
    color: var(--theme);
    transition: all var(--transition);
}
.c_b_p_desc_readmore:hover {
    background: var(--theme);
    color: #fff;
    transform: translateX(4px);
}

.postDesc {
    font-size: 13px;
    color: var(--text-light);
    margin-top: 14px;
    display: flex;
    flex-wrap: wrap;
    gap: 12px 24px;
}

/* ===== 文章详情页 ===== */
#post_detail,
#topics .post,
.cnblogs-post-body,
.blogpost-body {
    padding: 40px 44px !important;
}
#post_detail .postTitle,
#topics .post .postTitle {
    padding: 0 0 16px 0 !important;
    margin: 0 0 16px 0 !important;
    border-bottom: 1px solid var(--border);
}
#post_detail .postBody { padding: 0 !important; }
#post_detail .postDesc {
    padding: 16px 0 0 0 !important;
    margin: 0 !important;
    border-top: 1px solid var(--border);
}

#cnblogs_post_body,
.cnblogs-markdown { padding: 0 !important; }
#cnblogs_post_body p { margin: 0 0 18px 0; line-height: 1.9; }

#cnblogs_post_body h1,
#cnblogs_post_body h2,
#cnblogs_post_body h3,
#cnblogs_post_body h4 {
    margin: 32px 0 16px 0;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}
#cnblogs_post_body h1 { font-size: 28px; }
#cnblogs_post_body h2 { font-size: 24px; }
#cnblogs_post_body h3 { font-size: 20px; }
#cnblogs_post_body h4 { font-size: 17px; }

#cnblogs_post_body blockquote {
    margin: 20px 0;
    padding: 16px 24px;
    background: rgba(255,255,255,0.03);
    border-left: 4px solid var(--theme);
    border-radius: 0 8px 8px 0;
    color: var(--text-secondary);
}
[data-theme="light"] #cnblogs_post_body blockquote {
    background: rgba(0, 0, 0, 0.02);
}

#cnblogs_post_body ul,
#cnblogs_post_body ol {
    margin: 16px 0 20px 28px;
}
#cnblogs_post_body li { margin-bottom: 6px; }

#cnblogs_post_body img {
    max-width: 100%;
    border-radius: 8px;
    margin: 16px auto;
    display: block;
}

.cnblogs_code {
    margin: 16px 0 !important;
    padding: 18px 20px !important;
    background: rgba(0, 0, 0, 0.35) !important;
    border-radius: 8px !important;
    border: 1px solid var(--border) !important;
    overflow-x: auto;
}
.cnblogs_code pre {
    background: transparent !important;
    padding: 0 !important;
    border: none !important;
}
[data-theme="light"] .cnblogs_code {
    background: rgba(0, 0, 0, 0.05) !important;
}

/* ===== 侧边栏 ===== */
#sideBar { width: 300px; flex-shrink: 0; }
#sideBarMain { display: flex; flex-direction: column; gap: 18px; }

.sidebar-block,
#sidebar_news,
#blog-calendar {
    background: var(--card);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: var(--radius);
    padding: 20px 24px;
    border: 1px solid var(--card-border);
    box-shadow: var(--shadow);
    transition: background var(--transition), box-shadow var(--transition), border-color var(--transition);
}

.sidebar-block h3,
.catListTitle {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
}

.sidebar-block ul { list-style: none; }
.sidebar-block ul li {
    padding: 4px 0;
    font-size: 14px;
}
.sidebar-block ul li a { color: var(--text-secondary); }
.sidebar-block ul li a:hover { color: var(--theme); }

/* ===== 个人信息 ===== */
#sidebar_news { text-align: center; }

.profile-avatar {
    width: 84px;
    height: 84px;
    border-radius: 50%;
    border: 3px solid var(--theme-light);
    margin: 0 auto 12px;
    display: block;
    object-fit: cover;
    transition: border-color var(--transition);
}

.profile-name {
    font-size: 20px;
    font-weight: 700;
    color: var(--text);
}
.profile-bio {
    font-size: 14px;
    color: var(--text-secondary);
    margin: 4px 0 14px;
}

.profile-stats {
    display: flex;
    justify-content: center;
    gap: 28px;
    font-size: 14px;
    color: var(--text-secondary);
}
.profile-stats span { display: flex; flex-direction: column; }
.profile-stats .num {
    font-weight: 600;
    font-size: 18px;
    color: var(--text);
}

.hitokoto-box {
    margin-top: 16px;
    padding: 14px 16px;
    background: rgba(255,255,255,0.04);
    border-radius: 12px;
    font-size: 14px;
    color: var(--text-secondary);
    text-align: center;
    font-style: italic;
    border-left: 3px solid var(--theme);
    transition: background var(--transition);
}
[data-theme="light"] .hitokoto-box {
    background: rgba(0, 0, 0, 0.03);
}

/* ===== 日历 ===== */
#blogCalendar {
    width: 100%;
    font-size: 14px;
    border-collapse: separate;
    border-spacing: 2px;
}
#blogCalendar td {
    padding: 6px 0;
    text-align: center;
    border-radius: 6px;
}
#blogCalendar .CalTodayDay {
    background: var(--theme);
    color: #fff;
    font-weight: 600;
    border-radius: 50%;
}
#blogCalendar .CalOtherMonthDay { color: var(--text-light); }
#blogCalendar .CalDayHeader {
    font-weight: 400;
    font-size: 12px;
    color: var(--text-light);
}

/* ===== 标签 ===== */
#sidebar_toptags ul li {
    display: inline-block;
    margin: 3px 4px 3px 0;
}
#sidebar_toptags ul li a {
    display: inline-block;
    padding: 3px 16px;
    background: rgba(255,255,255,0.06);
    border-radius: 14px;
    font-size: 12px;
    color: var(--text-secondary);
    transition: all var(--transition);
}
#sidebar_toptags ul li a:hover {
    background: var(--theme);
    color: #fff;
    transform: translateY(-1px);
}
[data-theme="light"] #sidebar_toptags ul li a {
    background: rgba(0, 0, 0, 0.05);
}

/* ===== 评论 ===== */
.feedbackItem {
    padding: 16px 0;
    border-bottom: 1px solid var(--border);
}
.feedbackCon {
    background: rgba(255,255,255,0.04);
    padding: 12px 16px;
    border-radius: 10px;
    margin-top: 6px;
}
[data-theme="light"] .feedbackCon {
    background: rgba(0, 0, 0, 0.02);
}

/* ===== 底部 ===== */
#footer {
    text-align: center;
    padding: 28px 20px 20px;
    font-size: 13px;
    color: var(--text-light);
    border-top: 1px solid var(--border);
    max-width: 1200px;
    margin: 0 auto;
    transition: color var(--transition), border-color var(--transition);
}

/* ===== 回到顶部 ===== */
#back-top {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--card);
    backdrop-filter: blur(12px);
    border: 1px solid var(--card-border);
    box-shadow: var(--shadow);
    color: var(--text-secondary);
    font-size: 20px;
    cursor: pointer;
    transition: all var(--transition);
    opacity: 0;
    transform: translateY(20px);
    pointer-events: none;
    z-index: 999;
    display: flex;
    align-items: center;
    justify-content: center;
}
#back-top.visible {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}
#back-top:hover {
    background: var(--theme);
    color: #fff;
    border-color: var(--theme);
    transform: translateY(-3px);
}

/* ===== 响应式 ===== */
@media (max-width: 820px) {
    #main { flex-direction: column; padding: 0 12px 30px; }
    #sideBar { width: 100%; }
    #header { padding: 0 12px; }
    .blogStats { display: none; }
    .day { padding: 20px 18px; }
    .postTitle { font-size: 19px; }
    #post_detail,
    #topics .post,
    .cnblogs-post-body,
    .blogpost-body {
        padding: 24px 18px !important;
    }
    .theme-toggle { font-size: 14px; padding: 4px 10px; }
}

@media (max-width: 480px) {
    #post_detail,
    #topics .post,
    .cnblogs-post-body,
    .blogpost-body {
        padding: 16px 12px !important;
    }
    #cnblogs_post_body h1 { font-size: 22px; }
    #cnblogs_post_body h2 { font-size: 19px; }
    #cnblogs_post_body h3 { font-size: 17px; }
}