/* --- 1. 颜色变量定义 --- */
:root {
    --bg-color: #f5f5f5;
    --main-text: #333;
    --title-color: #51570e;
    --accent-color: #ff9500;
    --card-bg: rgba(255, 255, 255, 0.4);
    --header-bg: rgba(241, 226, 167, 0.7);
    --border-color: rgba(255, 255, 255, 0.3);
    --input-bg: rgba(255, 252, 240, 0.95);
    --sidebar-text: #745105;
    --shadow-color: rgba(0, 0, 0, 0.05);
    --mark-bg: rgba(251, 146, 0, 0.15);
    --sub-bg: rgba(0, 0, 0, 0.05);
}

/* --- 2. 深色模式颜色调优 --- */
html.dark-mode {
    --bg-color: #000000;
    --main-text: #e0e0e0;
    --title-color: #d4d99b;
    --accent-color: #ffaa33;
    --card-bg: rgba(35, 35, 35, 0.7);
    --header-bg: rgba(45, 42, 32, 0.85);
    --border-color: rgba(255, 255, 255, 0.1);
    --input-bg: rgba(45, 45, 45, 0.95);
    --sidebar-text: #e2c08d;
    --shadow-color: rgba(0, 0, 0, 0.4);
    --mark-bg: rgba(255, 170, 51, 0.3);
    --sub-bg: rgba(255, 255, 255, 0.05);
}

/* 背景颜色 */
body {
    background-color: var(--bg-color);
    background-image: url("/image/background.avif");
    background-repeat: repeat;
    color: var(--main-text);
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* 深色模式背景压暗滤镜 */
html.dark-mode::before {
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    z-index: -2;
    pointer-events: none;
}

/* 标题颜色 */
h1 {
    color: var(--title-color);
    text-align: left;
    font-size: 2em;
}

/* 标题链接的基础样式 */
.logo-link {
    text-decoration: none;
    color: var(--title-color);
    transition: all 0.3s ease;
    display: inline-block;
    white-space: nowrap;
}

/* 鼠标悬停在标题上的效果 */
.logo-link:hover {
    color: var(--accent-color);
    transform: scale(1.02);
}

/* --- 修改后的顶部栏样式 --- */
header {
    position: sticky;
    top: 0;
    z-index: 11000;
    width: 100%;
    display: flex;
    justify-content: space-around;
    align-items: center;
    background: transparent;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    border-bottom: none;
    box-shadow: none;
    border-radius: 0;
    overflow: visible !important;
    padding: 10px 0;
}

header::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--header-bg);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border-radius: 20px;
    border-bottom: 1px solid var(--border-color);
    box-shadow: 0 2px 10px var(--shadow-color);
    z-index: -1;
}

/* --- 搜索栏容器 --- */
header form {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--card-bg);
    backdrop-filter: none;
    padding: 4px 8px;
    border-radius: 25px;
    border: 1px solid var(--border-color);
    transition: all 0.3s ease;
    overflow: visible !important;
}

header form>div {
    overflow: visible;
}

header form:hover {
    border-color: var(--accent-color);
    background: var(--card-bg);
    box-shadow: 0 0 10px var(--shadow-color);
}

header form label {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

header form input[type="search"] {
    background: transparent;
    border: none;
    outline: none;
    padding: 6px 12px;
    color: var(--main-text);
    font-size: 0.95em;
    width: 180px;
    transition: width 0.4s ease;
}

header form input[type="search"]::placeholder {
    color: var(--main-text);
    opacity: 0.5;
}

header form input[type="search"]:focus {
    width: 240px;
}

header form button {
    background-color: var(--title-color);
    color: #fff;
    border: none;
    padding: 6px 16px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.9em;
    font-weight: bold;
    box-shadow: 0 2px 5px var(--shadow-color);
    transition: all 0.3s ease;
}

header form button:hover {
    background-color: var(--sidebar-text);
    transform: scale(1.05);
    box-shadow: 0 4px 10px var(--shadow-color);
}



/* 搜索下拉框容器 */
.search-dropdown {
    z-index: 10000;
    position: absolute;
    top: calc(100% + 15px);
    left: 0;
    width: 300px;
    background: var(--input-bg);
    backdrop-filter: blur(15px);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: 0 10px 30px var(--shadow-color);
    display: none;
    overflow: hidden;
    transform: translateZ(0);
}

.search-result-item {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: background 0.2s;
}

.search-result-item:last-child {
    border-bottom: none;
}

.search-result-item:hover {
    background: var(--sub-bg);
}

.search-result-item mark {
    background: var(--mark-bg);
    color: var(--accent-color);
    font-weight: bold;
    font-style: normal;
    padding: 0 2px;
    border-radius: 4px;
}

.search-result-item:hover mark {
    background: var(--accent-color);
    color: #fff;
}

.search-result-item a {
    text-decoration: none;
    color: var(--sidebar-text);
    font-size: 0.9em;
    display: block;
}

.search-result-item .result-title {
    font-size: 1em;
    color: var(--sidebar-text);
    margin-bottom: 4px;
}

.result-title {
    display: block;
    font-weight: 600;
    margin-bottom: 2px;
}

.search-result-item .result-preview {
    display: block;
    width: 100%;
    font-size: 0.8em;
    color: var(--main-text);
    opacity: 0.8;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 2px;
}

/* 头部右侧布局 */
.header-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* --- 自定义下拉框容器 --- */
.custom-select {
    position: relative;
    width: 140px;
    user-select: none;
    z-index: 5000;
}

.select-trigger {
    padding: 8px 15px;
    border-radius: 20px;
    border: 1px solid var(--border-color);
    background: var(--card-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    color: var(--sidebar-text);
    font-size: 0.9em;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.3s ease;
    box-shadow: 0 2px 10px var(--shadow-color);
}

.select-trigger:hover {
    background: var(--card-bg);
    border-color: var(--accent-color);
}

.arrow {
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 5px solid var(--sidebar-text);
    transition: transform 0.3s ease;
}

.custom-select.active .arrow {
    transform: rotate(180deg);
}

/* --- 下拉选项列表 --- */
.select-options-card {
    position: absolute;
    top: calc(100% + 10px);
    left: 0;
    right: 0;
    background: var(--input-bg);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border: 1px solid var(--border-color);
    border-radius: 15px;
    box-shadow: 0 10px 30px var(--shadow-color);
    display: none;
    overflow: hidden;
    animation: fadeIn 0.2s ease;
    z-index: 12002;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.custom-select.active .select-options-card {
    display: block;
}

.option {
    padding: 10px 15px;
    color: var(--sidebar-text);
    font-size: 0.9em;
    cursor: pointer;
    transition: background 0.2s;
}

.option:hover {
    background: var(--sub-bg);
}

.option.selected {
    background: var(--sub-bg);
    font-weight: bold;
}

/* 导航栏样式 */
nav ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    gap: 3rem;
}

nav a {
    position: relative;
    text-decoration: none;
    color: var(--main-text);
    font-size: 1.3em;
    font-weight: 500;
    padding: 0.25rem 0;
}

nav a::after {
    content: "";
    position: absolute;
    left: 0;
    bottom: -4px;
    width: 0;
    height: 2px;
    background-color: var(--accent-color);
    transition: width 0.3s ease;
}

nav a:hover::after {
    width: 100%;
}

/* 页面布局 */
.page-layout {
    display: flex;
    justify-content: flex-start;
    padding: 2rem;
    margin-left: 300px;
}

/* --- 左侧侧边栏整体布局 --- */
.sidebar-left {
    position: fixed;
    top: 130px;
    bottom: 0;
    left: 30px;
    width: 260px;
    z-index: 100;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    pointer-events: none;
}

.top-posts-card,
.character {
    pointer-events: auto;
}

.character {
    position: relative;
    width: 100%;
    margin: 0;
    line-height: 0;
}

.character img {
    width: 100%;
    height: auto;
    display: block;
    transition: filter 0.3s ease;
}

html.dark-mode .character img {
    filter: brightness(0.85);
}

/* --- 热门卡片样式 --- */
.top-posts-card {
    background: var(--card-bg);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 1.2rem;
    box-shadow: 0 4px 15px var(--shadow-color);
    transition: transform 0.3s ease;
    margin-top: 0;
}

.top-posts-card:hover {
    transform: translateY(-5px);
}

.top-posts-card h3 {
    margin: 0 0 12px 0;
    font-size: 1.1em;
    color: var(--sidebar-text);
    border-bottom: 2px dashed var(--border-color);
    padding-bottom: 5px;
}

.top-posts-card ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.top-posts-card li {
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.rank-num {
    background: var(--accent-color);
    color: white;
    font-size: 0.7em;
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    flex-shrink: 0;
}

.top-posts-card li:nth-child(1) .rank-num {
    background: #ff4d4d;
}

.top-posts-card li:nth-child(2) .rank-num {
    background: #ff8c00;
}

.top-posts-card li:nth-child(3) .rank-num {
    background: #ffcc00;
}

.top-posts-card a {
    text-decoration: none;
    color: var(--title-color);
    font-size: 0.9em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
    transition: color 0.2s;
}

.top-posts-card a:hover {
    color: var(--accent-color);
}

.top-views-count {
    font-size: 0.75em;
    color: var(--main-text);
    opacity: 0.6;
    margin-left: auto;
}

/* 右侧主内容区域 */
.page-layout main {
    flex: 1;
    padding: 1rem 2rem;
}

/* 文章卡片布局 */
.article-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
    gap: 2rem;
    align-items: start;
}

/* 文章卡片样式 */
.article-card {
    background: var(--card-bg);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 2rem;
    box-shadow: 0 8px 32px 0 var(--shadow-color);
    position: relative;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.article-card:hover {
    cursor: pointer;
    transform: translateY(-5px);
    box-shadow: 0 12px 40px 0 var(--shadow-color);
    background: var(--card-bg);
}

.article-card:hover .article-image img {
    transform: scale(1.1);
}

.article-card h2 a {
    text-decoration: none;
    color: var(--title-color);
    transition: color 0.3s;
}

.main-link::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    z-index: 1;
}

.article-image img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    transition: transform 0.5s ease;
}

.article-tags {
    margin-bottom: 0.8rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.tag {
    position: relative;
    z-index: 10;
    cursor: pointer;
    font-size: 0.85em;
    padding: 2px 10px;
    background: var(--sub-bg);
    color: var(--sidebar-text);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    transition: all 0.3s ease;
}

.tag:hover {
    background: var(--accent-color);
    color: #fff;
}

/* 深色模式按钮 */
.theme-toggle-btn {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.2rem;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    transition: all 0.3s ease;
    padding: 0;
}

.theme-toggle-btn:hover {
    transform: scale(1.1) rotate(15deg);
    border-color: var(--accent-color);
}

/* --- 404 错误页面样式 --- */
.error-404 {
    text-align: center;
    padding: 100px 20px;
}

.error-404 h1 {
    font-size: 8rem;
    color: var(--accent-color);
    margin: 0;
    line-height: 1;
    opacity: 0.5;
}

.error-404 p {
    font-size: 1.5rem;
    color: var(--sidebar-text);
    margin: 20px 0;
}

.error-msg-sub {
    font-size: 1rem;
    color: var(--main-text);
    opacity: 0.7;
    margin-bottom: 30px;
}

.back-home-btn {
    display: inline-block;
    padding: 12px 30px;
    background: var(--title-color);
    color: #fff !important;
    text-decoration: none;
    border-radius: 25px;
    transition: all 0.3s ease;
}

.back-home-btn:hover {
    background: var(--accent-color);
    transform: translateY(-3px);
    box-shadow: 0 5px 15px var(--shadow-color);
}

/* --- 分页组件通用样式 --- */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    margin-top: 3rem;
    padding-bottom: 2rem;
    width: 100%;
}

.p-btn,
.p-num {
    background: var(--card-bg);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border-color);
    color: var(--sidebar-text);
    padding: 10px 18px;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s;
    font-size: 0.9em;
}

.p-num.active {
    background: var(--accent-color);
    color: white;
    border-color: var(--accent-color);
    font-weight: bold;
}

.p-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.p-btn:hover:not(:disabled),
.p-num:hover:not(.active) {
    background: var(--accent-color);
    color: white;
    transform: translateY(-2px);
}


