:root {
    --width: 720px;
    --font-scale: 1.1rem;
    --background-color: #fff;
    --heading-color: #222;
    --text-color: #222;
    --link-color: #222;
    --visited-color: #222;
    --code-background-color: #F0F0F0;
    --code-color: #222;
    --blockquote-color: #222;
    --gray-color: #666;
}

/* 深色模式样式 */
[theme-mode="dark"] {
    --background-color: #1c1c1c;
    --heading-color: #e0e0e0;
    --text-color: #e0e0e0;
    --link-color: #e0e0e0;
    --visited-color: #e0e0e0;
    --code-background-color: #2d2d2d;
    --code-color: #e0e0e0;
    --blockquote-color: #e0e0e0;
    --gray-color: #aaa;
}

/* 亮色模式样式（显式定义） */
[theme-mode="light"] {
    --background-color: #fff;
    --heading-color: #222;
    --text-color: #222;
    --link-color: #222;
    --visited-color: #222;
    --code-background-color: #F0F0F0;
    --code-color: #222;
    --blockquote-color: #222;
    --gray-color: #666;
}

/* 护眼模式样式 */
[theme-mode="read"] {
    --background-color: #F2F1EA;
    --heading-color: #474135;
    --text-color: #474135;
    --link-color: #4F6D96;
    --visited-color: #4F6D96;
    --code-background-color: #EBE9E0;
    --code-color: #474135;
    --blockquote-color: #594833;
    --gray-color: #594833;
}


@media (prefers-color-scheme: dark) {
    :root {
        --width: 780px;
        --font-scale: 1.1rem;
        --background-color: #1c1c1c;
        --heading-color: #e0e0e0;
        --text-color: #e0e0e0;
        --link-color: #e0e0e0;
        --visited-color: #e0e0e0;
        --code-background-color: #2d2d2d;
        --code-color: #e0e0e0;
        --blockquote-color: #e0e0e0;
        --gray-color: #aaa;
    }
}

body {
    font-size: var(--font-scale);
    margin: auto;
    max-width: var(--width);
    text-align: left;
    background-color: var(--background-color);
    word-wrap: break-word;
    overflow-wrap: break-word;
    line-height: 1.7;
    font-weight: 400;
    color: var(--text-color);
    font-family: sans-serif;
    word-break: break-all;
    min-height: 100vh; /* 最小高度为视口高度,允许内容超出 */
    display: flex;
    flex-direction: column;
}

html {
    scroll-behavior: smooth;
}

time {
    font-family: consolas, monospace;
    font-style: normal;
}

h1,
h2,
h3,
h4,
h5,
h6 {
    color: var(--heading-color);
    display: inherit;
    margin: 0.5em 0;
}

h1 {
    font-size: 1.8em;
}

h2 {
    font-size: 1.5em;
}

h3 {
    font-size: 1.3em;
}

a {
    color: var(--link-color);
    cursor: pointer;
    text-decoration: none;
    border-bottom: 1px solid transparent;
}

a:hover,
nav .current {
    color: var(--gray-color);
    text-decoration: underline;
}

nav a {
    margin-right: 8px;
}

article a {
    text-decoration: underline;
}

strong,
b {
    color: var(--heading-color);
}

pre {
    padding: 5px 12px;
    overflow: auto;
    max-height: 400px;
}

hr {
    border: 0;
    border-top: 1px solid;
}

article hr {
    border: 0;
    border-top: 1px dashed;
}

img {
    max-width: 100%;
    height: auto;
    border-radius: 0.3rem;
}

video {
    max-width: 100%;
    height: auto;
    border-radius: 0.3rem;
    display: block;
    margin: 20px auto;
}

time,
.intro {
    color: var(--gray-color);
}

pre,
code {
    font-size: 0.85em;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    background-color: var(--code-background-color);
    color: var(--code-color);
    border-radius: 0.3rem;
}

code {
    padding: 2px 5px;
}

pre {
    padding: 10px 12px;
    overflow: auto;
    max-height: 400px;
}

pre code {
    padding: 0;
}

/* 代码块优化 */
pre[class*="language-"] {
    padding: 12px 15px;
    margin: 1em 0;
    overflow: auto;
    max-height: 400px;
    line-height: 1.4;
}

pre[class*="language-"] code {
    background: none;
    padding: 0;
    font-size: 0.9em;
}

blockquote {
    border-left: 5px solid var(--heading-color);
    padding: 10px 15px;
    margin: 10px 0;
    font-weight: bold;
    color: var(--blockquote-color);
    background-color: var(--code-background-color);
    border-radius: 0.3rem;
}

blockquote footer {
    text-align: right;
    font-size: 0.9em;
    color: #777;
}

header,
footer {
    padding: 10px 0;
}

.title h1,
.title h2 {
    font-size: 2em;
    margin: 0;
}

.title:hover {
    text-decoration: none;
}

main {
    margin-top: 30px;
    flex: 1;
    box-sizing: border-box;
}

nav a {
    font-size: 1.2em;
}

ul.posts {
    list-style-type: none;
    padding: unset;
}

ul.posts li {
    display: flex;
    margin: 3px 0;
}

ul.posts li span {
    flex: 0 0 115px;
}

ul.posts li a:visited {
    color: var(--visited-color);
}

.tags {
    margin-top: 30px;
    color: var(--gray-color);
}

.tags a {
    color: #888;
    margin: 0 5px 0 2px;
}

.post-item {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
}

.post-item a {
    flex: 1;
}

.post-item time {
    margin-left: 10px;
    white-space: nowrap;
}

footer,
footer a {
    letter-spacing: 0;
    line-height: 2;
    color: var(--gray-color);
    text-decoration: none;
    font-size: 13px;
}

.home {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

@media (max-width:768px) {
    body {
        padding: 0px 20px;
    }

    /* 移动端代码块优化 */
    pre,
    code {
        font-size: 0.75em;
    }

    pre {
        padding: 8px 10px;
        max-height: 300px;
    }

    pre[class*="language-"] {
        padding: 8px 10px;
        margin: 0.8em 0;
        max-height: 300px;
        line-height: 1.3;
    }

    pre[class*="language-"] code {
        font-size: 0.85em;
    }

    /* 移动端标题优化 */
    h1 {
        font-size: 1.5em;
    }

    h2 {
        font-size: 1.3em;
    }

    h3 {
        font-size: 1.1em;
    }

    .title h1,
    .title h2 {
        font-size: 1.6em;
    }

    main {
        margin-top: 20px;
    }
}

@media (min-width:769px) {
    body {
        padding: 0;
    }
}

/* PJAX 加载进度条 */
#pjax-progress {
    position: fixed;
    top: 0;
    left: 0;
    height: 2px;
    background: var(--link-color);
    z-index: 9999;
    opacity: 0;
    transition: opacity 0.2s;
    width: 0%;
}

#pjax-progress.active {
    opacity: 1;
    animation: pjax-loading 2s ease-in-out infinite;
}

@keyframes pjax-loading {
    0% { width: 0%; }
    50% { width: 70%; }
    100% { width: 95%; }
}

.post-pagination ol {
    list-style: none;
    display: inline-flex;
    padding: 0;
}

.post-pagination .page-numbers,
.post-pagination ol a {
    width: 35px;
    height: 35px;
    line-height: 35px;
    margin-right: 8px;
    display: inline-block;
    text-align: center;
    border-radius: 4px;
}

.post-pagination .pagination a:hover,
.post-pagination .pagination .current,
.post-pagination ol a:hover,
.post-pagination ol .current a {
    background: #333;
    color: #fff;
    text-decoration: none;
}

.post-pagination .page-numbers,
.post-pagination ol a {
    background: #f8f8f8;
    color: #555;
}

.post-pagination {
    margin: 80px 0 50px;
}

table {
    width: 100%;
    border-collapse: collapse;
    margin: 20px 0;
}

th,
td {
    padding: 12px;
    text-align: left;
    border: 1px solid #ddd;
}

th {
    position: sticky;
    top: 0;
    z-index: 10;
}

@media (max-width:600px) {

    th,
    td {
        display: block;
        width: 100%;
    }

    th {
        position: static;
    }

    tr {
        display: flex;
        flex-direction: column;
        margin-bottom: 10px;
    }
}

/* 主题模式选择器样式 */
.site-header-wrapper {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 30px;
}

.site-header-wrapper .title {
    margin: 0;
    flex: 1;
}

.site-header-wrapper .title h1 {
    margin: 0;
}

#themeMode-selector {
    flex-shrink: 0;
    margin-left: 20px;
}

#themeMode-selector #themeMode {
    padding: 2px 6px;
    border: 1px solid var(--gray-color);
    background-color: var(--background-color);
    color: var(--text-color);
    border-radius: 3px;
    cursor: pointer;
    font-size: 0.75em;
    min-width: 90px;
}

#themeMode-selector #themeMode:focus {
    outline: none;
    border-color: var(--link-color);
}

/* 移动端适配 */
@media (max-width:600px) {
    .site-header-wrapper {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }

    #themeMode-selector {
        margin-left: 0;
        width: 100%;
    }

    #themeMode-selector #themeMode {
        width: 100%;
    }
}

/* 主题模式悬浮按钮组 */
.minitool-group {
    position: fixed;
    right: 20px;
    top: 20px;
    z-index: 999;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.minitool-group .vertical-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    font-size: 20px;
    outline: none;
    color: var(--text-color);
    background-color: var(--code-background-color);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s;
}

.minitool-group .vertical-btn:hover {
    transform: scale(1.1);
}

/* 主题模式按钮图标控制 */
.minitool-group .themeMode-minitool .bi-sun,
.minitool-group .themeMode-minitool .bi-moon-stars,
.minitool-group .themeMode-minitool .bi-book {
    display: none;
}

[theme-mode=""] .minitool-group .themeMode-minitool .bi-sun,
[theme-mode="light"] .minitool-group .themeMode-minitool .bi-sun {
    display: block;
}

[theme-mode="dark"] .minitool-group .themeMode-minitool .bi-moon-stars {
    display: block;
}

[theme-mode="read"] .minitool-group .themeMode-minitool .bi-book {
    display: block;
}

/* 相册样式（优化版） */
.gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 10px;
    margin: 20px 0;
}

.gallery a {
    display: block;
    overflow: hidden;
    border-radius: 8px;
    position: relative;
    background: var(--code-background-color);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.gallery a:hover {
    transform: translateY(-4px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

.gallery img {
    width: 100%;
    height: 200px;
    object-fit: cover;
    display: block;
    transition: transform 0.3s ease, opacity 0.3s ease;
}

.gallery a:hover img {
    transform: scale(1.05);
}

/* 相册加载状态 */
.gallery a::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 30px;
    height: 30px;
    border: 3px solid var(--gray-color);
    border-top-color: transparent;
    border-radius: 50%;
    opacity: 0;
    animation: gallery-loading 1s linear infinite;
    pointer-events: none;
}

.gallery img.loading + a::before {
    opacity: 1;
}

@keyframes gallery-loading {
    to { transform: translate(-50%, -50%) rotate(360deg); }
}

/* 响应式设计 */
@media (max-width: 768px) {
    .gallery {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 8px;
    }

    .gallery img {
        height: 150px;
    }
}

@media (max-width: 480px) {
    .gallery {
        grid-template-columns: repeat(2, 1fr);
        gap: 6px;
    }

    .gallery img {
        height: 120px;
    }
}

/* 图片懒加载样式（增强版） */
img.lazyload {
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
    background-color: var(--background-color);
}

img.lazyloaded {
    opacity: 1;
    background-color: transparent;
}

img.loading {
    opacity: 0.5;
    position: relative;
    background-color: var(--background-color);
}

img.lazyload-error {
    opacity: 0.3;
    filter: grayscale(100%);
    position: relative;
    background-color: var(--code-background-color);
}

/* 图片加载失败提示 */
img.lazyload-error::after {
    content: '✕';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 2em;
    color: var(--gray-color);
    background: var(--background-color);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.8;
}