/* 主题全局样式 */
:root {
    --width: 720px;
    --font-scale: 1.1rem;
    --background-color: #fff;
    --heading-color: #000;
    --text-color: #000;
    --link-color: #000;
    --code-background-color: #f5f5f5;
    --code-color: #000;
    --gray-color: #666;
    --light-gray-color: #999;
    --hover-start-color: #00b7eb;
    --hover-end-color: #1e90ff;
    --font-main: "Noto Serif SC", serif;
    --font-mono: "Noto Serif SC", serif;
}

[data-theme="dark"] {
    --background-color: #1c1c1c;
    --heading-color: #fff;
    --text-color: #fff;
    --link-color: #fff;
    --code-background-color: #2d2d2d;
    --code-color: #fff;
    --gray-color: #aaa;
    --light-gray-color: #888;
    --hover-start-color: #d946ef;
    --hover-end-color: #6366f1;
}

/* 字体切换样式 */
body.font-serif {
    --font-main: "Noto Serif SC", serif;
    --font-mono: "Noto Serif SC", serif;
}

body.font-sans {
    --font-main: "Noto Sans SC", sans-serif;
    --font-mono: "Noto Sans SC", sans-serif;
}

body {
    font-size: var(--font-scale);
    margin: auto;
    max-width: var(--width);
    background-color: var(--background-color);
    color: var(--text-color);
    font-family: var(--font-main);
    line-height: 1.8;
    font-weight: 400;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

html {
    scroll-behavior: smooth;
    height: 100%;
}

h1, h2, h3, h4, h5, h6 {
    color: var(--heading-color);
    font-family: var(--font-main);
    line-height: 1.4;
}

h1 { font-size: 2.4em; }
h2 { font-size: 1.8em; }
h3 { font-size: 1.4em; }
h4 { font-size: 1.2em; }

.article-title {
    font-size: 2em;
    margin: 0;
    color: var(--heading-color);
    white-space: normal;
    overflow: visible;
}

a {
    color: var(--link-color);
    text-decoration: none;
    transition: color 0.3s ease, text-shadow 0.3s ease;
}

a:hover, a:active {
    color: var(--hover-end-color);
    background: linear-gradient(to bottom, var(--hover-start-color), var(--hover-end-color));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

strong, b {
    color: var(--heading-color);
    font-weight: 700;
}

pre, code {
    font-family: var(--font-mono);
    font-size: 0.9em;
    background-color: var(--code-background-color);
    color: var(--code-color);
    border-radius: 0.3rem;
}

code { padding: 2px 4px; }
pre { padding: 8px 12px; overflow: auto; max-height: 400px; }
pre code { padding: 0; }

blockquote {
    border-left: 4px solid var(--heading-color);
    padding: 8px 12px;
    margin: 12px 0;
    color: var(--text-color);
    background-color: var(--code-background-color);
    border-radius: 0.3rem;
}

hr {
    border: 0;
    border-top: 1px solid var(--gray-color);
}

article hr {
    border-top: 1px dashed var(--gray-color);
}

img {
    max-width: 100%;
    height: auto;
    border-radius: 0.3rem;
}

article img {
    max-width: 80%;
    display: block;
    margin: 16px auto;
}

header, footer {
    padding: 12px 0;
}

main {
    margin-top: 20px;
    flex: 1;
}

.index main {
    margin-top: 10px;
}

.post article, .page article {
    letter-spacing: 0.03em;
    line-height: 2;
    font-weight: 500;
    text-align: justify;
}

.title {
    display: inline-block;
    text-align: center;
    margin: 0 auto;
}

.title h1 {
    font-size: 2.4em;
    margin: 0;
}

.subtitle {
    font-size: 0.95em;
    color: var(--gray-color);
    margin: 4px 0 0;
    line-height: 1.5;
    font-family: var(--font-main);
    font-weight: 400;
}

.home {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.site-nav {
    margin: 12px 0;
    font-size: 0.9em;
    display: flex;
    align-items: center;
    gap: 8px;
    justify-content: center;
}

.site-nav a, .site-nav .search-toggle {
    color: var(--gray-color);
    text-decoration: none;
    font-weight: 400;
    padding: 4px 8px;
    border-radius: 4px;
    background: var(--code-background-color);
    transition: background-color 0.2s, transform 0.1s;
    line-height: 1.5;
    display: inline-flex;
    align-items: center;
}

.site-nav a:hover, .site-nav .search-toggle:hover {
    background: var(--gray-color);
    color: var(--background-color);
    transform: translateY(-1px);
}

.site-nav a:active, .site-nav .search-toggle:active {
    transform: translateY(1px);
}

.site-nav a.current {
    background: var(--heading-color);
    color: var(--background-color);
}

.site-nav .search-toggle {
    cursor: pointer;
}

.search-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.4s ease;
}

.search-modal.active {
    display: flex;
    opacity: 1;
}

.search-modal form {
    width: 100%;
    max-width: 600px;
    padding: 0 16px;
    box-sizing: border-box;
}

.search-modal .search-modal-input {
    width: 100%;
    padding: 12px 0;
    border: none;
    border-bottom: 1px solid var(--gray-color);
    background: transparent;
    color: #fff;
    font-size: 1.3em;
    font-weight: 400;
    outline: none;
    transition: border-bottom 0.3s ease;
}

.search-modal.active .search-modal-input {
    transform: translateY(0);
    opacity: 1;
}

.search-modal .search-modal-input::placeholder {
    color: var(--light-gray-color);
    opacity: 0.6;
}

.search-modal .search-modal-input:focus {
    border-bottom: 2px solid var(--heading-color);
}

.post-item {
    margin-bottom: 16px;
    position: relative;
}

.post-item a {
    font-size: 1.1em;
    color: var(--link-color);
    display: block;
    font-weight: 700;
}

.post-item a:hover {
    text-shadow: 0 0 3px rgba(0, 0, 0, 0.3);
}

.post-item time {
    font-size: 0.85em;
    color: var(--light-gray-color);
    margin-bottom: 4px;
    opacity: 0.5;
}

.post-item.sticky {
    background: var(--code-background-color);
    padding: 8px;
    border-radius: 4px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.post-item .sticky-label {
    font-size: 0.8em;
    color: var(--background-color);
    background: var(--heading-color);
    padding: 2px 6px;
    border-radius: 4px;
    position: absolute;
    right: 8px;
    top: 8px;
}

.post-meta {
    font-size: 0.85em;
    color: var(--gray-color);
    margin: 8px 0 16px;
    display: flex;
    align-items: center;
}

.post .post-meta time, .post .post-meta a, .post .post-meta .separator,
.page .post-meta time, .post .post-meta a, .page .post-meta .separator {
    font-size: 0.95em;
    color: var(--gray-color);
}

.post-meta time { margin-right: 6px; }
.post-meta .separator { margin: 0 6px; font-size: 0.9em; }

.copyright-notice {
    max-width: var(--width);
    margin: 16px auto;
    padding: 12px;
    background-color: var(--code-background-color);
    border-radius: 4px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    font-size: 0.8em;
    color: var(--gray-color);
    line-height: 1.3;
    text-align: left;
    opacity: 0.8;
}

.copyright-notice p {
    margin: 2px 0;
}

.copyright-notice a {
    color: var(--link-color);
    text-decoration: none;
}

.copyright-notice a:hover {
    color: var(--hover-end-color);
}

.btn-back-home, .btn-nav {
    color: var(--gray-color);
    text-decoration: none;
    font-size: 0.9em;
    padding: 6px 12px;
    border-radius: 6px;
    background: var(--code-background-color);
    transition: background-color 0.2s, transform 0.1s, box-shadow 0.2s;
    line-height: 1.5;
    display: inline-flex;
    align-items: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    font-weight: 500;
}

.btn-back-home:hover, .btn-nav:hover {
    background: var(--gray-color);
    color: var(--background-color);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.btn-back-home:active, .btn-nav:active {
    transform: translateY(0);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.btn-nav.disabled {
    background: #e0e0e0;
    color: #999;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
    opacity: 0.6;
}

.btn-nav.disabled:hover {
    background: #e0e0e0;
    color: #999;
    transform: none;
    box-shadow: none;
}

.post-nav {
    display: flex;
    justify-content: space-between;
    margin: 16px 0;
    gap: 12px;
}

.post-nav .btn-nav {
    text-align: center;
}

.recommend-random {
    margin-top: 24px;
}

.recommended-posts {
    max-width: 100%;
}

.recommended-posts h4 {
    margin: 0 0 8px;
    font-size: 1em;
    color: var(--heading-color);
    font-weight: 700;
}

.recommended-posts ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.recommended-posts li {
    margin: 4px 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

.recommended-posts a {
    color: var(--link-color);
    text-decoration: none;
    display: block;
    font-weight: 400;
    font-size: 0.95em;
}

.tags {
    margin-top: 16px;
    color: var(--gray-color);
    font-size: 0.85em;
}

.tags a {
    color: var(--gray-color);
    margin: 0 4px;
    text-decoration: none;
}

.post-pagination {
    margin: 40px 0 24px;
    text-align: center;
}

.post-pagination ol {
    list-style: none;
    display: inline-flex;
    padding: 0;
}

.post-pagination .page-numbers, .post-pagination ol a {
    width: 32px;
    height: 32px;
    line-height: 32px;
    margin-right: 6px;
    display: inline-block;
    text-align: center;
    border-radius: 4px;
    background: var(--code-background-color);
    color: var(--text-color);
}

.post-pagination .pagination a:hover, .post-pagination .pagination .current, .post-pagination ol a:hover, .post-pagination ol .current a {
    background: var(--gray-color);
    color: var(--background-color);
    text-decoration: none;
}

.blog-posts {
    list-style: none;
    padding: 0;
    margin: 16px 0;
}

.blog-posts li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px;
    margin: 8px 0;
    border-radius: 4px;
    background: var(--code-background-color);
}

.blog-posts li:hover {
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.blog-posts li a {
    font-size: 1em;
    color: var(--link-color);
    font-weight: 400;
    text-decoration: none;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.blog-posts .post-time time {
    font-size: 0.85em;
    color: var(--light-gray-color);
}

.blog-posts .no-results {
    padding: 12px;
    text-align: center;
    color: var(--gray-color);
    font-style: italic;
}

article table {
    width: auto;
    max-width: 80%;
    margin: 16px auto;
    border-collapse: collapse;
    display: table;
}

th, td {
    padding: 8px;
    text-align: left;
    border: 1px solid var(--gray-color);
    display: table-cell;
    vertical-align: middle;
}

@media (max-width: 600px) {
    article table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
        max-width: 80%;
        margin: 16px auto;
    }
    th, td {
        padding: 6px;
        font-size: 0.9em;
    }
}

#comments { padding-top: 16px; }
.comment-list, .comment-list ol { list-style: none; margin: 0; padding: 0; }
.comment-list li {
    margin-top: 12px;
    padding: 12px;
    background-color: var(--code-background-color);
    border-radius: 4px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    font-size: 0.8em;
    color: var(--gray-color);
    line-height: 1.3;
    opacity: 0.8;
}

.comment-list li:hover { box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15); }

.comment-list ol li { background-color: color-mix(in srgb, var(--code-background-color) 90%, black 10%); }
.comment-list ol ol li { background-color: color-mix(in srgb, var(--code-background-color) 80%, black 20%); }
.comment-list ol ol ol li { background-color: color-mix(in srgb, var(--code-background-color) 70%, black 30%); }
.comment-list ol ol ol ol li { background-color: color-mix(in srgb, var(--code-background-color) 60%, black 40%); }

.comment-list li .comment-reply { text-align: right; font-size: 0.85em; color: var(--gray-color); }
.comment-meta a { color: var(--gray-color); font-size: 0.85em; }
.comment-author { display: flex; align-items: center; margin-bottom: 8px; }
.comment-author .avatar { width: 28px; height: 28px; border-radius: 50%; margin-right: 8px; object-fit: cover; }
.comment-author cite { font-weight: 500; color: var(--text-color); }
.comment-list .respond { margin-top: 16px; padding-top: 16px; }
.respond .cancel-comment-reply { float: right; margin-top: 12px; font-size: 0.85em; color: var(--gray-color); }
#comment-form label { display: block; margin-bottom: 8px; font-weight: 400; color: var(--text-color); }
#comment-form .required:after { content: " *"; color: #e63946; }
.comment-content { line-height: 1.3; color: var(--gray-color); font-size: 0.8em; }
.comment-content h2 { font-size: 1.2em; margin-top: 1.2em; margin-bottom: 0.6em; }
.comment-content img { max-width: 100%; border-radius: 4px; }
.comment-content a img { background-color: var(--background-color); position: relative; bottom: -4px; }
.comment-content hr { margin: 1.5em auto; width: 80px; border: 0; border-top: 1px solid var(--gray-color); }

input[type="text"], input[type="email"], input[type="url"], textarea {
    padding: 8px;
    border: 1px solid var(--gray-color);
    width: 100%;
    border-radius: 4px;
    box-sizing: border-box;
    font-size: 0.9em;
    background-color: var(--background-color);
    transition: border-color 0.2s ease;
    font-family: var(--font-main);
}

input[type="text"]:focus, input[type="email"]:focus, input[type="url"]:focus, textarea:focus {
    border-color: var(--heading-color);
    outline: none;
}

textarea { resize: vertical; }

button[type="submit"] {
    padding: 8px 16px;
    background-color: var(--heading-color);
    color: var(--background-color);
    border: none;
    border-radius: 4px;
    font-size: 0.9em;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

button[type="submit"]:hover { background-color: var(--gray-color); }
button[type="submit"]:focus { outline: none; }

/* 侧边按钮组 */
.sidebar-buttons {
    position: fixed;
    bottom: 30px;
    right: 30px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
}

.sidebar-buttons.show {
    opacity: 1;
    visibility: visible;
}

.sidebar-btn {
    width: 40px;
    height: 40px;
    background-color: var(--code-background-color);
    color: var(--gray-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    cursor: pointer;
    transition: background-color 0.2s, transform 0.3s, box-shadow 0.3s;
    position: relative;
}

.sidebar-btn:hover {
    background-color: var(--gray-color);
    color: var(--background-color);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.sidebar-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.sidebar-btn i {
    font-size: 18px;
}

/* 滑动动画 */
.sidebar-btn.slide {
    animation: slideToggle 0.3s ease;
}

@keyframes slideToggle {
    0% { transform: translateX(0); }
    50% { transform: translateX(-10px); }
    100% { transform: translateX(0); }
}

/* 工具提示 */
.sidebar-btn::after {
    content: attr(title);
    position: absolute;
    right: 50px;
    top: 50%;
    transform: translateY(-50%);
    background: var(--code-background-color);
    color: var(--text-color);
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.8em;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s, visibility 0.2s;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.sidebar-btn:hover::after {
    opacity: 1;
    visibility: visible;
}

/* 页脚样式 */
footer {
    margin: 50px 0 20px;
    padding-top: 20px;
    border-top: 1px solid var(--gray-color);
    border-top-color: rgba(var(--gray-color), 0.3);
    color: var(--gray-color);
    font-size: 0.85em;
}

.footer-content {
    margin-bottom: 20px;
}

.footer-top {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr;
    gap: 20px;
    align-items: stretch;
}

.footer-admin {
    grid-column: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.footer-spacer {
    grid-column: 2;
}

.footer-sitemap {
    grid-column: 3;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.footer-friend-links {
    grid-column: 4;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.footer-admin h4, .footer-sitemap h4, .footer-friend-links h4 {
    font-size: 1em;
    color: var(--heading-color);
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
    line-height: 1.5;
}

.admin-profile {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}

.admin-avatar {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    object-fit: cover;
}

.admin-info {
    display: flex;
    flex-direction: column;
}

.admin-name {
    font-size: 1em;
    color: var(--text-color);
    font-weight: 500;
}

.admin-bio {
    font-size: 0.9em;
    line-height: 1.5;
    margin: 4px 0 0;
}

.admin-social {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

.admin-social-btn {
    color: var(--gray-color);
    font-size: 1em;
    padding: 4px;
    border-radius: 50%;
    background: var(--code-background-color);
    transition: background-color 0.2s, transform 0.1s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
}

.admin-social-btn:hover {
    background: var(--gray-color);
    color: var(--background-color);
    transform: translateY(-1px);
}

.admin-social-btn:active {
    transform: translateY(1px);
}

.footer-sitemap ul, .footer-friend-links ul {
    list-style: none;
    padding: 0;
    margin: 0;
    flex-grow: 1;
}

.footer-sitemap li, .footer-friend-links li {
    margin-bottom: 4px;
}

.footer-sitemap a, .footer-friend-links a {
    color: var(--gray-color);
    text-decoration: none;
    display: block;
}

.footer-sitemap a:hover, .footer-friend-links a:hover {
    color: var(--hover-end-color);
}

.footer-friend-links a[title]:hover::after {
    content: attr(title);
    position: absolute;
    background: var(--code-background-color);
    color: var(--text-color);
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.8em;
    white-space: nowrap;
    z-index: 1000;
    margin-top: 4px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.footer-copyright {
    text-align: left;
    margin-top: 20px;
}

.footer-copyright p {
    margin: 4px 0;
}

.footer-copyright a {
    color: var(--gray-color);
    text-decoration: none;
}

.footer-copyright a:hover {
    color: var(--hover-end-color);
}

@media (max-width: 768px) {
    body { padding: 0 12px; }
    .title { text-align: center; }
    .site-nav { justify-content: center; flex-wrap: wrap; }
    .recommend-random { flex-direction: column; gap: 12px; }
    .recommended-posts { max-width: 100%; }
    .sidebar-buttons { bottom: 20px; right: 20px; }
    .sidebar-btn { width: 36px; height: 36px; }
    .sidebar-btn i { font-size: 16px; }
    .footer-top {
        display: flex;
        flex-direction: column;
        gap: 16px;
    }
    .footer-admin {
        margin-bottom: 16px;
    }
    .footer-spacer {
        display: none;
    }
    .footer-links-mobile {
        display: flex;
        flex-direction: row;
        justify-content: space-between;
        gap: 16px;
    }
    .footer-sitemap, .footer-friend-links {
        flex: 1;
    }
    .admin-avatar {
        width: 48px;
        height: 48px;
    }
    .admin-name {
        font-size: 0.9em;
    }
    .admin-bio {
        font-size: 0.85em;
    }
    .admin-social-btn {
        width: 28px;
        height: 28px;
        font-size: 0.9em;
        padding: 4px;
    }
}

@media (min-width: 769px) {
    body { padding: 0; }
}