/* ========== Variables ========== */
:root {
    --bg: #ffffff;
    --bg-secondary: #f6f7f8;
    --bg-card: #ffffff;
    --text: #1d1d1f;
    --text-secondary: #6e6e73;
    --text-tertiary: #9ca3af;
    --border: #e5e5e7;
    --primary: #0071e3;
    --primary-hover: #0058b9;
    --link: #0066cc;
    --link-hover: #004999;
    --code-bg: #f5f5f7;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 16px rgba(0,0,0,0.08);
    --shadow-lg: 0 8px 30px rgba(0,0,0,0.10);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --max-width: 860px;
    --header-height: 52px;
    --transition: 0.2s ease;
}

[data-theme="dark"] {
    --bg: #1c1c1e;
    --bg-secondary: #2c2c2e;
    --bg-card: #2c2c2e;
    --text: #f5f5f7;
    --text-secondary: #aeaeb2;
    --text-tertiary: #636366;
    --border: #3a3a3c;
    --primary: #0a84ff;
    --primary-hover: #409cff;
    --link: #0a84ff;
    --link-hover: #409cff;
    --code-bg: #2c2c2e;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 16px rgba(0,0,0,0.4);
    --shadow-lg: 0 8px 30px rgba(0,0,0,0.5);
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg: #1c1c1e;
        --bg-secondary: #2c2c2e;
        --bg-card: #2c2c2e;
        --text: #f5f5f7;
        --text-secondary: #aeaeb2;
        --text-tertiary: #636366;
        --border: #3a3a3c;
        --primary: #0a84ff;
        --primary-hover: #409cff;
        --link: #0a84ff;
        --link-hover: #409cff;
        --code-bg: #2c2c2e;
        --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
        --shadow-md: 0 4px 16px rgba(0,0,0,0.4);
        --shadow-lg: 0 8px 30px rgba(0,0,0,0.5);
    }
}

/* ========== Reset ========== */
*, *::before, *::after { margin: 0; padding: 0;  }
html { font-size: 16px; scroll-behavior: smooth; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro SC", "PingFang SC", "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.75;
    font-size: 15px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    transition: background 0.3s, color 0.3s;
}
a { color: var(--link); text-decoration: none; transition: color 0.15s; }
a:hover { color: var(--link-hover); }
img { max-width: 100%; height: auto; display: block; }
ul, ol { list-style: none; }
input, textarea, button { font-family: inherit; font-size: inherit; }

/* ========== Container ========== */
.container { max-width: var(--max-width); margin: 0 auto; padding: 0 20px; }

/* ========== Header ========== */
.site-header {
    position: sticky; top: 0; z-index: 1000;
    background: rgba(255,255,255,0.8);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-bottom: 1px solid var(--border);
    height: var(--header-height);
    display: flex; align-items: center;
}
[data-theme="dark"] .site-header { background: rgba(28,28,30,0.8); }
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .site-header { background: rgba(28,28,30,0.8); }
}
.site-header .container { display: flex; align-items: center; justify-content: space-between; }
.site-logo { font-size: 1.15rem; font-weight: 700; letter-spacing: -0.02em; }
.site-logo a { color: var(--text); }
.site-logo a:hover { color: var(--primary); }
.site-nav { display: flex; align-items: center; gap: 2px; }
.site-nav a {
    padding: 7px 14px; color: var(--text-secondary); font-size: 0.875rem; font-weight: 500;
    border-radius: var(--radius-sm); transition: all 0.15s;
}
.site-nav a:hover { color: var(--primary); background: var(--bg-secondary); }
.site-nav a.active { color: var(--primary); }

.header-actions { display: flex; align-items: center; gap: 8px; }
.header-btn {
    width: 36px; height: 36px; display: flex; align-items: center; justify-content: center;
    border: none; background: var(--bg-secondary); color: var(--text-secondary);
    border-radius: var(--radius-sm); cursor: pointer; transition: all 0.15s;
}
.header-btn:hover { color: var(--primary); }

/* Mobile menu */
.mobile-toggle { display: none; }

/* ========== Hero ========== */
.hero {
    padding: 60px 0 40px;
    text-align: center;
}
.hero h1 {
    font-size: 2.2rem; font-weight: 700; letter-spacing: -0.03em; margin-bottom: 12px;
}
.hero p {
    font-size: 1.05rem; color: var(--text-secondary); max-width: 600px; margin: 0 auto;
}

/* ========== Section ========== */
.section { padding: 30px 0; }
.section-title {
    font-size: 1.25rem; font-weight: 700; margin-bottom: 20px;
    display: flex; align-items: center; gap: 8px;
}
.section-title::before {
    content: ''; width: 4px; height: 20px; background: var(--primary); border-radius: 2px;
}

/* ========== Article List ========== */
.article-list { display: flex; flex-direction: column; gap: 12px; }
.article-card {
    background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-md);
    padding: 20px 24px; transition: all 0.2s; cursor: pointer;
    text-decoration: none;
}
.article-card:hover {
    border-color: var(--primary); box-shadow: var(--shadow-md); transform: translateY(-1px);
}
.article-card .article-date { font-size: 0.78rem; color: var(--text-tertiary); margin-bottom: 6px; }
.article-card h3 { font-size: 1.1rem; font-weight: 600; margin-bottom: 6px; color: var(--text); }
.article-card:hover h3 { color: var(--primary); }
.article-card p { font-size: 0.875rem; color: var(--text-secondary); }
.article-card .article-meta {
    display: flex; align-items: center; gap: 12px; margin-top: 10px;
    font-size: 0.78rem; color: var(--text-tertiary);
}
.article-card .article-meta span { display: flex; align-items: center; gap: 4px; }

/* ========== Article Single ========== */
.article-single { padding: 40px 0; }
.article-single h1 {
    font-size: 1.8rem; font-weight: 700; line-height: 1.3; margin-bottom: 12px;
}
.article-single .article-meta {
    display: flex; align-items: center; gap: 16px; padding-bottom: 20px;
    border-bottom: 1px solid var(--border); margin-bottom: 28px;
    font-size: 0.82rem; color: var(--text-tertiary);
}
.article-content { font-size: 1rem; line-height: 1.9; }
.article-content h1, .article-content h2, .article-content h3 { margin-top: 1.5em; margin-bottom: 0.6em; font-weight: 600; }
.article-content h2 { font-size: 1.4rem; }
.article-content h3 { font-size: 1.2rem; }
.article-content p { margin-bottom: 1.2em; }
.article-content code {
    background: var(--code-bg); padding: 2px 6px; border-radius: 4px;
    font-family: "SF Mono", "JetBrains Mono", Consolas, monospace; font-size: 0.875em;
}
.article-content pre { background: var(--code-bg); padding: 16px; border-radius: var(--radius-sm); overflow-x: auto; margin: 1.2em 0; }
.article-content pre code { background: none; padding: 0; }
.article-content blockquote {
    border-left: 3px solid var(--primary); padding: 8px 16px; margin: 1em 0;
    background: var(--bg-secondary); border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    color: var(--text-secondary);
}
.article-content ul { list-style: disc; padding-left: 1.5em; margin: 1em 0; }
.article-content ul li { margin-bottom: 0.3em; }
.article-content a { color: var(--link); text-decoration: underline; text-underline-offset: 2px; }
.article-content hr { border: none; border-top: 1px solid var(--border); margin: 2em 0; }
.back-link { font-size: 0.875rem; color: var(--text-secondary); margin-bottom: 20px; display: inline-block; }

/* ========== Guestbook ========== */
.guestbook { padding: 30px 0 60px; }
.guestbook-form {
    background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg);
    padding: 24px; margin-bottom: 30px;
}
.guestbook-form h3 { font-size: 1rem; font-weight: 600; margin-bottom: 16px; }
.form-row { display: flex; gap: 12px; margin-bottom: 12px; }
.form-row input {
    flex: 1; padding: 10px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm);
    background: var(--bg); color: var(--text); transition: border 0.2s;
}
.form-row input:focus, .guestbook-form textarea:focus { outline: none; border-color: var(--primary); }
.guestbook-form textarea {
    width: 100%; min-height: 100px; padding: 10px 14px; border: 1px solid var(--border);
    border-radius: var(--radius-sm); background: var(--bg); color: var(--text);
    resize: vertical; transition: border 0.2s; margin-bottom: 12px;
}
.form-footer { display: flex; align-items: center; justify-content: space-between; }
.form-footer .char-count { font-size: 0.78rem; color: var(--text-tertiary); }
.btn-primary {
    padding: 8px 24px; background: var(--primary); color: #fff; border: none;
    border-radius: var(--radius-sm); font-size: 0.875rem; font-weight: 600; cursor: pointer;
    transition: background 0.2s;
}
.btn-primary:hover { background: var(--primary-hover); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

/* Message list */
.message-list { display: flex; flex-direction: column; gap: 12px; }
.message-item {
    background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-md);
    padding: 16px 20px; transition: all 0.2s;
}
.message-item:hover { box-shadow: var(--shadow-sm); }
.message-header { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.message-avatar img { width: 36px; height: 36px; border-radius: 50%; }
.message-name { font-weight: 600; font-size: 0.9rem; }
.message-date { font-size: 0.75rem; color: var(--text-tertiary); margin-left: auto; }
.message-text { font-size: 0.9rem; color: var(--text-secondary); line-height: 1.7; }
.message-reply {
    margin-top: 10px; padding: 10px 14px; background: var(--bg-secondary);
    border-radius: var(--radius-sm); font-size: 0.85rem; color: var(--text-secondary);
    border-left: 3px solid var(--primary);
}
.message-reply::before { content: '管理员回复：'; font-weight: 600; }
.guestbook-empty { text-align: center; padding: 40px; color: var(--text-tertiary); font-size: 0.9rem; }

/* Pagination */
.pagination { display: flex; justify-content: center; gap: 6px; margin-top: 30px; }
.pagination a, .pagination span {
    display: flex; align-items: center; justify-content: center;
    min-width: 36px; height: 36px; padding: 0 10px;
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    color: var(--text-secondary); font-size: 0.85rem; transition: all 0.15s;
}
.pagination a:hover { border-color: var(--primary); color: var(--primary); }
.pagination .current { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ========== Footer ========== */
.site-footer {
    background: var(--bg-secondary); border-top: 1px solid var(--border);
    padding: 24px 0; margin-top: 40px;
}
.site-footer .container { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; }
.footer-info { font-size: 0.78rem; color: var(--text-tertiary); }
.footer-info a { color: var(--text-secondary); }

/* ========== Toast ========== */
.toast {
    position: fixed; top: 80px; left: 50%; transform: translateX(-50%) translateY(-20px);
    background: var(--text); color: var(--bg); padding: 12px 24px;
    border-radius: var(--radius-sm); font-size: 0.875rem; font-weight: 500;
    box-shadow: var(--shadow-lg); z-index: 3000; opacity: 0;
    transition: all 0.3s; pointer-events: none;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.success { background: #34c759; color: #fff; }
.toast.error { background: #ff3b30; color: #fff; }

/* ========== Back to top ========== */
.back-to-top {
    position: fixed; bottom: 24px; right: 24px; width: 40px; height: 40px;
    background: var(--primary); color: #fff; border: none; border-radius: 50%;
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    opacity: 0; visibility: hidden; transition: all 0.3s; z-index: 999;
    box-shadow: var(--shadow-md);
}
.back-to-top.visible { opacity: 1; visibility: visible; }
.back-to-top:hover { transform: translateY(-2px); }

/* ========== Responsive ========== */
@media (max-width: 768px) {
    .mobile-toggle {
        display: flex; flex-direction: column; gap: 4px; width: 36px; height: 36px;
        border: none; background: var(--bg-secondary); border-radius: var(--radius-sm);
        cursor: pointer; align-items: center; justify-content: center; padding: 0;
    }
    .mobile-toggle span { display: block; width: 16px; height: 2px; background: var(--text); border-radius: 1px; }
    .site-nav {
        position: fixed; top: var(--header-height); left: 0; right: 0;
        flex-direction: column; background: var(--bg); border-bottom: 1px solid var(--border);
        padding: 10px; gap: 0; transform: translateY(-100%); opacity: 0;
        transition: all 0.25s; z-index: 999;
    }
    .site-nav.active { transform: translateY(0); opacity: 1; }
    .site-nav a { padding: 12px 14px; }
    .hero h1 { font-size: 1.6rem; }
    .hero p { font-size: 0.95rem; }
    .form-row { flex-direction: column; }
    .article-single h1 { font-size: 1.4rem; }
}

@media (max-width: 480px) {
    .container { padding: 0 14px; }
    .guestbook-form { padding: 16px; }
}
