/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg: #f7f8fa;
    --surface: #ffffff;
    --text: #0a0f1f;
    --text-secondary: #556270;
    --accent: #635bff;
    --accent-hover: #4f3ff5;
    --accent-light: rgba(99,91,255,0.08);
    --border: #e8eaef;
    --success: #00b3b3;
    --radius: 16px;
    --radius-sm: 10px;
    --shadow: 0 2px 8px rgba(0,0,0,0.04), 0 0 1px rgba(0,0,0,0.06);
    --shadow-hover: 0 8px 30px rgba(0,0,0,0.08);
}

html { font-size: 17px; -webkit-font-smoothing: antialiased; }

body {
    font-family: "PingFang SC", "Noto Sans SC", "Microsoft YaHei", sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.75;
    min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; transition: color 200ms ease; }
a:hover { color: var(--accent-hover); }

img { max-width: 100%; height: auto; }

code, pre { font-family: "JetBrains Mono", "Fira Code", "Cascadia Code", monospace; }

/* ===== Container ===== */
.container { max-width: 1160px; margin: 0 auto; padding: 0 24px; }

/* ===== Header ===== */
.header {
    position: sticky; top: 0; z-index: 100;
    background: rgba(255,255,255,0.82);
    backdrop-filter: blur(16px);
    border-bottom: 1px solid transparent;
    transition: border-color 300ms ease;
}
.header.scrolled { border-bottom-color: var(--border); }

.nav {
    max-width: 1160px; margin: 0 auto; padding: 0 24px;
    display: flex; align-items: center; justify-content: space-between;
    height: 64px;
}

.nav-brand { display: flex; align-items: center; gap: 10px; font-size: 1.25rem; font-weight: 650; color: var(--text); }
.nav-brand:hover { color: var(--accent); }
.nav-brand-text { display: flex; flex-direction: column; gap: 2px; line-height: 1.2; }
.nav-brand-title { font-size: 1.25rem; font-weight: 650; }
.nav-brand-subtitle { font-size: 0.78rem; font-weight: 500; color: var(--text-secondary); }
.nav-brand:hover .nav-brand-subtitle { color: var(--accent); }
.nav-logo { width: 32px; height: 32px; border-radius: 8px; }

.nav-menu { display: flex; list-style: none; gap: 32px; }
.nav-menu a { color: var(--text-secondary); font-size: 0.95rem; font-weight: 500; position: relative; }
.nav-menu a:hover { color: var(--accent); }
.nav-menu a::after {
    content: ''; position: absolute; bottom: -4px; left: 0; width: 100%; height: 2px;
    background: var(--accent); border-radius: 2px;
    transform: scaleX(0); transform-origin: left; transition: transform 200ms ease;
}
.nav-menu a:hover::after { transform: scaleX(1); }

.nav-toggle { display: none; background: none; border: none; cursor: pointer; flex-direction: column; gap: 5px; padding: 4px; }
.nav-toggle span { display: block; width: 24px; height: 2px; background: var(--text); border-radius: 2px; transition: 200ms ease; }

/* ===== Page Layout ===== */
.page-layout { display: flex; gap: 40px; padding: 48px 0; }
.content-main { flex: 1; min-width: 0; max-width: 700px; }

/* ===== Sidebar ===== */
.sidebar { width: 300px; flex-shrink: 0; display: flex; flex-direction: column; gap: 20px; }
.sidebar-card {
    background: var(--surface); border-radius: var(--radius);
    padding: 24px; box-shadow: var(--shadow);
}
.sidebar-card h4 { font-size: 1rem; margin-bottom: 12px; color: var(--text); }

.author-card { text-align: center; }
.author-avatar { width: 72px; height: 72px; border-radius: 50%; margin-bottom: 12px; object-fit: cover; }
.author-card h3 { font-size: 1.15rem; margin-bottom: 6px; }
.author-bio { font-size: 0.9rem; color: var(--text-secondary); line-height: 1.6; }
.author-social { margin-top: 12px; display: flex; justify-content: center; gap: 12px; }
.social-link { font-size: 0.85rem; color: var(--accent); }

.category-list { list-style: none; }
.category-list li { padding: 6px 0; }
.category-list a { color: var(--text-secondary); font-size: 0.9rem; }
.category-list a:hover { color: var(--accent); }

.tag-cloud { display: flex; flex-wrap: wrap; gap: 8px; }
.tag-item {
    display: inline-block; padding: 4px 12px;
    background: var(--accent-light); color: var(--accent);
    border-radius: 20px; font-size: 0.82rem; transition: all 200ms ease;
}
.tag-item:hover { background: var(--accent); color: #fff; }

/* ===== Post Card ===== */
.post-card {
    background: var(--surface); border-radius: var(--radius);
    padding: 28px; margin-bottom: 24px;
    box-shadow: var(--shadow);
    transition: transform 250ms cubic-bezier(0.16,1,0.3,1), box-shadow 250ms cubic-bezier(0.16,1,0.3,1);
}
.post-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-hover); }
.post-pinned { border-left: 3px solid var(--accent); }

.post-cover { display: block; margin: -28px -28px 20px; border-radius: var(--radius) var(--radius) 0 0; overflow: hidden; }
.post-cover img { width: 100%; height: 200px; object-fit: cover; transition: transform 300ms ease; }
.post-card:hover .post-cover img { transform: scale(1.02); }

.post-title { font-size: 1.4rem; font-weight: 650; line-height: 1.4; margin-bottom: 8px; }
.post-title a { color: var(--text); }
.post-title a:hover { color: var(--accent); }

.post-meta { display: flex; align-items: center; gap: 16px; font-size: 0.85rem; color: var(--text-secondary); flex-wrap: wrap; }
.post-category {
    background: var(--accent-light); color: var(--accent);
    padding: 2px 10px; border-radius: 20px; font-weight: 500;
}

.post-summary { margin-top: 12px; color: var(--text-secondary); font-size: 0.95rem; }
.post-tags { margin-top: 12px; display: flex; gap: 8px; flex-wrap: wrap; }

/* ===== Page Header ===== */
.page-header { margin-bottom: 32px; }
.page-header h1 { font-size: 1.75rem; font-weight: 650; margin-bottom: 6px; }
.page-header p { color: var(--text-secondary); }

/* ===== Post Detail ===== */
.post-layout { display: flex; gap: 40px; padding: 48px 0; }
.post-detail { flex: 1; max-width: 700px; margin: 0 auto; }

.post-header { margin-bottom: 36px; }
.post-header h1 { font-size: 1.75rem; font-weight: 650; line-height: 1.4; margin-bottom: 12px; }

.post-content { font-size: 1rem; }
.post-content h2 { font-size: 1.35em; font-weight: 650; margin: 2em 0 0.6em; }
.post-content h3 { font-size: 1.15em; font-weight: 650; margin: 1.6em 0 0.5em; }
.post-content p { margin: 1em 0; }
.post-content ul, .post-content ol { margin: 1em 0; padding-left: 1.5em; }
.post-content li { margin: 0.4em 0; }
.post-content blockquote {
    border-left: 3px solid var(--accent); padding: 0.6em 1em;
    margin: 1.2em 0; background: var(--accent-light); border-radius: 0 8px 8px 0;
    color: var(--text-secondary);
}
.post-content pre {
    background: #f4f5f7; border-radius: var(--radius-sm); padding: 20px;
    overflow-x: auto; font-size: 0.88rem; line-height: 1.6;
    border-left: 3px solid var(--accent);
}
.post-content :not(pre) > code {
    background: var(--accent-light); color: var(--accent);
    padding: 2px 8px; border-radius: 4px; font-size: 0.88em;
}
.post-content img { border-radius: var(--radius-sm); }
.post-content a { text-decoration: underline; text-underline-offset: 2px; }

.post-copyright {
    margin-top: 40px; padding: 16px 20px;
    background: var(--accent-light); border-radius: var(--radius-sm);
    font-size: 0.85rem; color: var(--text-secondary);
}

/* ===== Post Nav ===== */
.post-nav {
    display: flex; justify-content: space-between; gap: 16px;
    max-width: 700px; margin: 0 auto 48px; padding: 24px 0; border-top: 1px solid var(--border);
}
.post-prev, .post-next { flex: 1; font-size: 0.95rem; font-weight: 500; }
.post-next { text-align: right; }

/* ===== Buttons ===== */
.btn-primary {
    display: inline-block; padding: 10px 24px;
    background: linear-gradient(135deg, var(--accent), #00b3b3);
    color: #fff; border: none; border-radius: var(--radius-sm);
    font-size: 0.95rem; font-weight: 600; cursor: pointer;
    transition: filter 200ms ease, transform 200ms ease;
}
.btn-primary:hover { filter: brightness(1.1); transform: translateY(-1px); color: #fff; }

/* ===== Footer ===== */
.footer { margin-top: 80px; padding: 40px 0; border-top: 1px solid var(--border); }
.footer-inner { max-width: 1160px; margin: 0 auto; padding: 0 24px; text-align: center; }
.footer p { color: var(--text-secondary); font-size: 0.85rem; margin: 4px 0; }
.footer-beians { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 16px; margin: 8px 0; }
.footer-beian { display: inline-flex; align-items: center; gap: 4px; color: var(--text-secondary); font-size: 0.85rem; transition: color 200ms ease; }
.footer-beian:hover { color: var(--accent); }
.footer-beian-icon { display: block; flex-shrink: 0; object-fit: contain; }
.footer-rss { margin-top: 8px; }

/* ===== Empty State ===== */
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-secondary); font-size: 1rem; }

/* ===== Error Page ===== */
.error-page { text-align: center; padding: 120px 20px; }
.error-page h1 { font-size: 4rem; font-weight: 700; color: var(--accent); }
.error-page p { margin: 12px 0 24px; color: var(--text-secondary); }

/* ===== TOC ===== */
.toc { width: 220px; flex-shrink: 0; position: sticky; top: 80px; align-self: flex-start; max-height: calc(100vh - 100px); overflow-y: auto; }
.toc.is-empty { display: none; }
.toc-title { font-weight: 650; margin-bottom: 12px; font-size: 0.9rem; color: var(--text); }
.toc-list a { display: block; padding: 4px 0; font-size: 0.82rem; color: var(--text-secondary); border-left: 2px solid transparent; padding-left: 12px; transition: all 200ms ease; }
.toc-list a:hover, .toc-list a.active { color: var(--accent); border-left-color: var(--accent); }

/* ===== Archive ===== */
.archive-section { margin-bottom: 32px; }
.archive-month { font-size: 1.15rem; font-weight: 650; margin-bottom: 12px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.archive-list { list-style: none; }
.archive-item { display: flex; gap: 16px; padding: 8px 0; align-items: flex-start; }
.archive-item time { color: var(--text-secondary); font-size: 0.9rem; white-space: nowrap; min-width: 40px; }

/* ===== Link Grid ===== */
.link-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.link-card {
    background: var(--surface); border-radius: var(--radius); padding: 20px;
    box-shadow: var(--shadow); display: flex; align-items: center; gap: 14px;
    transition: all 250ms cubic-bezier(0.16,1,0.3,1);
}
.link-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-hover); color: inherit; }
.link-card img { width: 40px; height: 40px; border-radius: 8px; object-fit: cover; flex-shrink: 0; }
.link-card strong { display: block; font-size: 0.95rem; color: var(--text); }
.link-card p { font-size: 0.82rem; color: var(--text-secondary); margin-top: 2px; }

/* ===== Guestbook ===== */
.guestbook-form {
    background: var(--surface); border-radius: var(--radius); padding: 24px;
    box-shadow: var(--shadow); margin-bottom: 32px; display: flex; flex-direction: column; gap: 12px;
}
.guestbook-form input, .guestbook-form textarea {
    width: 100%; padding: 12px 16px; border: 1px solid var(--border); border-radius: var(--radius-sm);
    font-size: 0.95rem; font-family: inherit; resize: vertical;
    transition: border-color 200ms ease;
}
.guestbook-form input:focus, .guestbook-form textarea:focus {
    outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-light);
}
.guestbook-form button { align-self: flex-end; }

.message-item {
    background: var(--surface); border-radius: var(--radius); padding: 20px 24px;
    box-shadow: var(--shadow); margin-bottom: 16px;
}
.message-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.message-header strong { color: var(--text); }
.message-header time { font-size: 0.82rem; color: var(--text-secondary); }
.message-content { color: var(--text-secondary); font-size: 0.95rem; }

/* ===== Search ===== */
.search-form { display: flex; gap: 12px; margin-bottom: 32px; }
.search-form input {
    flex: 1; padding: 12px 16px; border: 1px solid var(--border);
    border-radius: var(--radius-sm); font-size: 0.95rem; font-family: inherit;
    transition: border-color 200ms ease;
}
.search-form input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-light); }

/* ===== Pagination ===== */
.pagination { margin-top: 32px; }
.pagination-inner { display: flex; align-items: center; justify-content: center; gap: 8px; }
.pagination-inner a, .page-current {
    display: inline-flex; align-items: center; justify-content: center;
    width: 40px; height: 40px; border-radius: 50%;
    font-size: 0.9rem; font-weight: 500; transition: all 200ms ease;
}
.pagination-inner a { background: var(--surface); box-shadow: var(--shadow); color: var(--text-secondary); }
.pagination-inner a:hover { background: var(--accent); color: #fff; box-shadow: var(--shadow-hover); }
.page-current { background: linear-gradient(135deg, var(--accent), #00b3b3); color: #fff; }
.page-prev, .page-next { width: auto !important; padding: 0 16px !important; border-radius: 20px !important; }

/* ===== Responsive ===== */
@media (max-width: 1023px) {
    .toc { display: none; }
    .sidebar { width: 240px; }
    .page-layout { gap: 24px; }
}

@media (max-width: 767px) {
    html { font-size: 16px; }
    .container { padding: 0 16px; }
    .nav { padding: 0 16px; }
    .nav-toggle { display: flex; }
    .nav-menu {
        display: none; position: fixed; top: 64px; left: 0; right: 0;
        background: rgba(255,255,255,0.95); backdrop-filter: blur(12px);
        flex-direction: column; gap: 0; padding: 12px 0;
        border-bottom: 1px solid var(--border);
    }
    .nav-menu.open { display: flex; }
    .nav-menu a { display: block; padding: 12px 24px; }
    .nav-brand-subtitle { display: none; }
    .page-layout { flex-direction: column; padding: 32px 0; }
    .content-main { max-width: 100%; }
    .sidebar { width: 100%; }
    .post-layout { flex-direction: column; padding: 32px 0; }
    .post-detail { max-width: 100%; }
    .post-card { padding: 20px; }
    .post-nav { flex-direction: column; }
    .link-grid { grid-template-columns: 1fr; }
    .search-form { flex-direction: column; }
}
