@charset "utf-8";

/* ==========================================================================
   1. 全局变量定义
   ========================================================================== */
:root {
    /* 日间模式 (默认) */
    --c-primary: #833;
    --c-primary-hover: #a55;
    --c-text-main: #333;
    --c-text-sec: #666;
    --c-bg-body: #eee;
    --c-bg-container: rgba(255, 255, 255, 0.5);
    --c-bg-card: #fff;
    --c-bg-light: #f5f5f5;
    --c-border: #ddd;
    --c-border-dashed: #ccc;
    --c-shadow: rgba(0, 0, 0, 0.1);
    --c-blue: #0066cc;
    --c-input-bg: #fff;
    --bg-image: url(./img/bg.jpg);
    --header-filter: none;
    --icon-invert: 0;
}

body.dark-mode {
    --c-primary: #ff6b6b;
    --c-primary-hover: #ff9999;
    --c-text-main: #e0e0e0;
    --c-text-sec: #aaa;
    --c-bg-body: #1a1a1a;
    --c-bg-container: rgba(30, 30, 30, 0.9);
    --c-bg-card: #2d2d2d;
    --c-bg-light: #333;
    --c-border: #444;
    --c-border-dashed: #555;
    --c-shadow: rgba(0, 0, 0, 0.5);
    --c-blue: #2962ff;
    --c-input-bg: #3d3d3d;
    --bg-image: none;
    --header-filter: brightness(0.7);
    --icon-invert: 1;
}

/* ==========================================================================
   2. 基础重置与通用样式
   ========================================================================== */
* { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: smooth; font-size: 16px; }

body {
    font: 14px/1.6 "Microsoft YaHei", "微软雅黑", Arial, sans-serif;
    color: var(--c-text-main);
    background: var(--c-bg-body) var(--bg-image) center top / cover no-repeat fixed;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* 自定义文本选中颜色 */
::selection { background-color: var(--c-primary); color: #fff; }
::-moz-selection { background-color: var(--c-primary); color: #fff; }

/* 滚动条美化适配 */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--c-bg-body); }
::-webkit-scrollbar-thumb { background: var(--c-border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--c-primary); }

a { color: var(--c-primary); text-decoration: none; transition: all 0.3s ease; }
a:hover { text-decoration: underline; color: var(--c-primary-hover); }
img { border: 0; max-width: 100%; height: auto; }

textarea, input, select, button {
    font-family: inherit; font-size: 14px; border-radius: 4px;
    border: 1px solid var(--c-border); background: var(--c-input-bg);
    color: var(--c-text-main); transition: all 0.3s ease;
}
textarea:focus, input:focus, select:focus {
    outline: none; border-color: var(--c-primary);
    box-shadow: 0 0 0 2px rgba(131, 51, 51, 0.1);
}
textarea { line-height: 1.8; padding: 8px; resize: vertical; overflow: auto; }
input { padding: 6px 8px; }
button { padding: 8px 16px; background: var(--c-primary); color: #fff; border: none; border-radius: 6px; cursor: pointer; }
button:hover { background: var(--c-primary-hover); transform: translateY(-2px); box-shadow: 0 4px 8px var(--c-shadow); }

hr { height: 1px; border: none; background: var(--c-bg-light); margin: 16px 0; }
ul, ol { list-style: none; }
div { word-wrap: break-word; }
.clearfix::after { content: ""; display: block; clear: both; }

/* ==========================================================================
   3. 布局容器
   ========================================================================== */
#outmain {
    width: 950px; margin: 0 auto; position: relative;
    background: var(--c-bg-container); border: 1px solid var(--c-border);
    border-top: none; border-radius: 0 0 8px 8px; box-shadow: 0 2px 10px var(--c-shadow);
    transition: background 0.3s ease, border-color 0.3s ease;
}
#outmain::after { content: ""; display: block; clear: both; }

#header {
    height: 200px; position: relative;
    z-index: 20; /* 提升头部层级 */
    background: #fff url(./img/head.jpg) center / cover no-repeat;
    transition: filter 0.3s ease;
    filter: var(--header-filter);
}
.blog-title { padding: 94px 0 0 50px; font-size: 36px; font-weight: 600; letter-spacing: 2px; text-shadow: 0 2px 4px rgba(0,0,0,0.3); }
.blog-title a, #header .description { color: #fff; text-decoration: none; }
#header .description { padding: 10px 0 0 50px; font-size: 14px; text-shadow: 0 1px 3px rgba(0,0,0,0.3); }

/* ==========================================================================
   4. 功能组件：搜索与导航
   ========================================================================== */
#searchbar { 
    float: right; padding: 0 10px 0 0; margin-top: 13px; 
    position: relative; z-index: 9999; /* 防止遮挡 */
}
.searchform {
    background: var(--c-bg-light); border: 1px solid var(--c-primary);
    border-radius: 20px; padding: 5px 10px; width: 200px; display: flex; align-items: center;
}
.searchform .searchinput { border: none; background: transparent; flex: 1; padding: 0; min-width: 0; }
.searchform .searchsubmit {
    width: 20px; height: 20px; background: url(img/searchsubmit.gif) no-repeat center;
    border: none; cursor: pointer; opacity: 0.7; margin-left: 5px; text-indent: -999px;
    filter: invert(var(--icon-invert));
}
.searchform .searchsubmit:hover { opacity: 1; }

#pagemenu {
    width: 100%;
    position: relative; z-index: 10; /* 低于头部，防止遮挡搜索框 */
    background: transparent url(./img/head1.jpg) no-repeat;
    transition: filter 0.3s ease; filter: var(--header-filter); /* 夜间自动变暗保留图片 */
}
#pagemenu ul { display: flex; padding: 0 30px; gap: 15px; }
#pagemenu ul li { position: relative; z-index: 100; line-height: 30px; }
#pagemenu ul li a {
    display: block; padding: 0 20px; background: var(--c-blue); color: #fff;
    border-radius: 6px 6px 0 0; box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
body.dark-mode #pagemenu ul li a { background: #333; color: #ccc; box-shadow: none; }
#pagemenu ul li a:hover, #pagemenu ul li.current_page_item a { background: var(--c-primary); color: #fff; text-decoration: none; }

/* 下拉菜单 */
#pagemenu ul li { position: relative; }
#pagemenu ul li .sub-menu {
    display: block; visibility: hidden; opacity: 0; position: absolute; top: 100%; left: 0; min-width: 120px; padding: 0; /* padding:0 去除继承的左右30px间距，让悬浮色块撑满左右 */
    background: var(--c-bg-card); border: 1px solid var(--c-border); transform: translateY(10px); transition: all 0.3s ease;
    box-shadow: 0 4px 10px var(--c-shadow); border-radius: 0 0 6px 6px; z-index: 3000;
}
#pagemenu ul li:hover .sub-menu, #pagemenu ul li:focus-within .sub-menu { visibility: visible; opacity: 1; transform: translateY(0); }
.arrow-down { font-size: 10px; margin-left: 4px; display: inline-block; transition: transform 0.3s ease; }
#pagemenu ul li:hover .arrow-down { transform: rotate(180deg); }
#pagemenu ul li .sub-menu li { width: 100%; display: block; margin: 0; border-bottom: 1px solid var(--c-bg-light); }
#pagemenu ul li .sub-menu li:last-child { border-bottom: none; }
#pagemenu ul li .sub-menu li a {
    padding: 10px 15px; background: var(--c-bg-card) !important; color: var(--c-text-main) !important;
    border-radius: 0; box-shadow: none; text-align: left; font-size: 13px; line-height: normal; white-space: nowrap;
}
#pagemenu ul li .sub-menu li a:hover { background: var(--c-primary) !important; color: #fff !important; }

/* ==========================================================================
   5. 内容区域与侧边栏 (升级为 Flex 布局)
   ========================================================================== */
#page { width: 100%; padding: 10px; display: flex; justify-content: space-between; align-items: flex-start; }
#wrap { width: 630px; padding: 0 10px; }
#sidebar { width: 280px; padding: 0 10px; }

.post-main { margin-bottom: 30px; padding-bottom: 20px; border-bottom: 1px dashed var(--c-border-dashed); }
.post-title { font-size: 24px; font-weight: 600; margin: 8px 0 12px; color: var(--c-text-main); }
.post-stick-title { font-size: 22px; color: var(--c-primary); margin: 8px 0; }
.post-date, .post-meta { font-size: 12px; color: var(--c-text-sec); }
.post-meta { text-align: right; }
.post-meta-link { padding: 0 0 0 28px; background: url(img/comment.gif) no-repeat 10px 4px; }
.cat-links { padding: 0 0 0 15px; background: url(img/bullet_go.gif) no-repeat 0 4px; font-size: 12px; }
.post-body { font-size: 15px; line-height: 1.8; margin: 15px 0; color: var(--c-text-main); word-wrap: break-word; overflow: hidden; }
.post-body pre { overflow-x: auto; max-width: 100%; white-space: pre; padding: 10px; background: var(--c-bg-light); border-radius: 4px; box-sizing: border-box; }
.syntaxhighlighter { width: 100% !important; overflow-x: auto !important; box-sizing: border-box; }
.syntaxhighlighter table { width: 100% !important; }
.quote { border-left: 4px solid var(--c-primary); background: var(--c-bg-light); padding: 12px 16px; margin: 15px 0; border-radius: 0 6px 6px 0; color: var(--c-text-sec); }

#sidebar div.stitle { font-size: 20px; font-style: italic; color: var(--c-text-main); margin: 10px 0 15px; padding-bottom: 8px; }
#sidebar ul li { background: url(img/arrow.gif) no-repeat 2px 13px; padding: 8px 0 8px 15px; transition: padding-left 0.3s ease; }
#sidebar ul li:hover { padding-left: 20px; }
.art-tag { margin: 15px 0; font-size: 14px; }
.art-tag a { display: inline-block; padding: 4px 10px; margin: 0 8px 8px 0; background: var(--c-bg-light); border-radius: 16px; color: var(--c-text-sec); }
.art-tag a:hover { background: var(--c-primary); color: #fff; text-decoration: none; }

#showcalendar { margin: 20px 0; width: 260px; text-align: center; border: 1px dashed var(--c-border-dashed); border-radius: 6px; overflow: hidden; }
#showcalendar td { padding: 4px; border-color: var(--c-border); }
.week { background: var(--c-bg-light); border-bottom: 2px solid #aaa; font-weight: 600; }
body.dark-mode .week { border-color: #555; }
.cal_day1:hover { background: var(--c-bg-light); }
.curdate { background: #80c9ef; color: #fff; border-radius: 4px; font-weight: bold; }

div.comment { margin: 10px 0 20px 42px; padding: 16px; background: var(--c-bg-card); border-radius: 8px; box-shadow: 0 1px 3px var(--c-shadow); }
div.comment:hover { box-shadow: 0 3px 8px var(--c-shadow); }
div.rowa { background: var(--c-bg-light); } 
div.rowb { background: var(--c-bg-card); }
.comment_data { padding-bottom: 8px; color: #999; font-size: 12px; margin-bottom: 8px; }
.comment_data .author { display: block; font-size: 16px; color: #444; font-weight: 600; margin-bottom: 4px; }
.comment_data a.reply { float: right; padding: 2px 8px; background: #f5f5f5; border-radius: 4px; font-size: 12px; }
.comment_data a.reply:hover { background: #833; color: #fff; text-decoration: none; }
.comment_data .art-title { font-size: 12px; float: right; font-weight: normal; }
img.avatar { float: left; margin-right: 10px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1); }
body.dark-mode img.avatar { border-color: #444; }
.nocomment { padding: 20px; background: var(--c-bg-light); text-align: center; color: var(--c-text-sec); border-radius: 8px; }

.p_bar { margin: 30px 0; text-align: center; }
.p_bar a, .p_curpage { display: inline-block; padding: 8px 12px; margin: 0 2px; border: 1px solid var(--c-border); border-radius: 4px; background: var(--c-bg-card); }
.p_curpage, .p_bar a:hover { background: var(--c-bg-light); border-color: var(--c-primary); color: var(--c-primary); }
#footer { padding: 20px; text-align: center; font-size: 12px; color: var(--c-text-sec); clear: both; }

/* ==========================================================================
   6. 页面特定样式 (归档/链接/标签/附件)
   ========================================================================== */
.car-container { padding: 10px; }
.car-container p { margin: 20px 0; font-weight: bold; color: var(--c-text-main); }
.car-toggle { font-weight: normal; font-size: 16px; line-height: 30px; margin: 8px 0; padding: 8px 0; cursor: pointer; color: var(--c-text-main); }
.car-toggle:hover { color: var(--c-primary); }
.car-yearmonth span { color: var(--c-text-sec); font-size: 12px; margin-left: 5px; }
.car-yearmonth a { font-weight: bold; }
.car-monthlisting { margin: 10px 0 20px 20px; }
.car-monthlisting li { list-style: none; padding-left: 5px; color: var(--c-text-sec); }

/* 友情链接 */
.linkgroup { margin-bottom: 25px; clear: both; }
.linkover { margin: 0 0 20px 0; padding: 10px 0; clear: both; overflow: hidden; }
.linkover li { float: left; width: 140px; line-height: 32px; margin: 5px 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.linkover li.onelink { width: 280px; }
.linkover li a { display: flex; align-items: center; padding: 5px; border-radius: 4px; background: var(--c-bg-light); color: var(--c-text-main); transition: all 0.3s; }
.linkover li a:hover { background: var(--c-primary); color: #fff; text-decoration: none; }
.link-favicon { width: 18px; height: 18px; border-radius: 3px; margin-right: 8px; flex-shrink: 0; background-color: #fff; padding: 1px; object-fit: contain; }
.link-favicon-text { width: 18px; height: 18px; border-radius: 3px; margin-right: 8px; flex-shrink: 0; color: #fff; font-size: 12px; font-weight: bold; align-items: center; justify-content: center; text-transform: uppercase; line-height: 1; overflow: hidden; white-space: nowrap; }

.tags { line-height: 2.5; margin-bottom: 25px; }
.tags a { display: inline-block; padding: 3px 3px; margin: 2px; color: var(--c-text-sec); }
.tags a:hover { background: var(--c-primary); color: #fff; text-decoration: none; }

.attach { padding: 10px; margin: 10px 0; border-radius: 6px; }
.attach a { text-decoration: underline; }
.attach img, img.attach { background: var(--c-bg-card); padding: 5px; border: 1px solid var(--c-border); border-radius: 4px; margin-top: 5px; }

.formbox p { margin: 0; padding: 0 0 12px; }
.title { font-size: 24px; font-weight: 600; margin: 10px 0 15px; padding-bottom: 12px; border-bottom: 1px dashed var(--c-border-dashed); }
.formfield { width: 100%; padding: 8px 12px; background: var(--c-bg-card); border: 1px solid var(--c-border); border-radius: 4px; }

/* ==========================================================================
   7. 悬浮工具栏 (包含返回顶部/日夜模式)
   ========================================================================== */
#action-buttons { position: fixed; bottom: 40px; right: 30px; z-index: 9999; display: flex; flex-direction: column; gap: 15px; }
.action-btn {
    width: 48px; height: 48px; border-radius: 50%; background-color: var(--c-bg-card); color: var(--c-text-sec);
    border: 1px solid var(--c-border); cursor: pointer; display: flex; align-items: center; justify-content: center;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1); transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1); outline: none;
}
.action-btn:hover { background-color: var(--c-primary); color: #fff; border-color: var(--c-primary); transform: translateY(-4px); box-shadow: 0 8px 25px rgba(131, 51, 51, 0.3); }
.action-btn svg.icon { width: 22px; height: 22px; stroke-width: 2px; transition: transform 0.4s ease; }
.action-btn:hover svg.icon { transform: scale(1.1); }
.link-icon { display: inline-flex; align-items: center; justify-content: center; width: 16px; height: 16px; margin-right: 6px; vertical-align: middle; border-radius: 2px; background-color: #f0f0f0; overflow: hidden; }

#backToTop { display: none; }
#backToTop[style*="display: flex"] { display: flex !important; }
#darkModeToggle .icon-sun { display: none; }
body.dark-mode #darkModeToggle .icon-moon { display: none; }
body.dark-mode #darkModeToggle .icon-sun { display: block; animation: rotateIn 0.5s ease; }
@keyframes rotateIn { from { transform: rotate(-90deg) scale(0.5); opacity: 0; } to { transform: rotate(0) scale(1); opacity: 1; } }

/* ==========================================================================
   8. 移动端响应式
   ========================================================================== */
@media screen and (max-width: 960px) {
    body { background-attachment: scroll !important; } /* 解决 iOS 卡顿 */
    #outmain { width: 100%; border: none; border-radius: 0; }
    #page { flex-direction: column; padding: 0; } /* Flex 列排布 */
    #wrap { width: 100%; padding: 10px 15px; }
    #sidebar { display: none !important; }

    #header { height: auto; padding-bottom: 20px; background-size: cover; }
    .blog-title { padding: 40px 15px 10px; font-size: 26px; text-align: center; }
    #header .description { padding: 0 15px; text-align: center; }

    #searchbar { float: none; margin: 15px auto; padding: 0 15px; width: 50%; box-sizing: border-box; }
    .searchform { width: 100%; max-width: 400px; height: 40px; }
    .searchform .searchinput { font-size: 16px; }

    #pagemenu { height: auto; background-size: cover; }
    #pagemenu ul { flex-wrap: wrap; justify-content: center; padding: 5px 0; }
    #pagemenu ul li a { font-size: 13px; padding: 0 8px; }
    #pagemenu ul li .sub-menu { top: 40px; left: 50%; transform: translateX(-50%); width: 140px; z-index: 10000; } /* 移动端下拉菜单宽度，原为 200px，可修改 width 的数值来调整宽高 */
    #pagemenu ul li .sub-menu.show-menu { display: block !important; }

    .linkover li, .linkover li.onelink { width: 100%; float: none; margin: 5px 0; }

    #action-buttons { bottom: 25px; right: 20px; gap: 12px; }
    .action-btn { width: 42px; height: 42px; }
    .action-btn svg.icon { width: 20px; height: 20px; }
    #footer { padding: 20px 10px; line-height: 2.0; height: auto; }
}