/* ===== 字体与变量 ===== */
:root {
    /* 苹果系统字体栈 */
    --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
    --font-mono: "SF Mono", "SFMono-Regular", Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;

    /* Light 主题 */
    --bg: #f5f5f7;
    --surface: #ffffff;
    --surface-hover: #fafafa;
    --text-primary: #1d1d1f;
    --text-secondary: #6e6e73;
    --text-tertiary: #86868b;
    --border: rgba(0, 0, 0, 0.08);
    --border-strong: rgba(0, 0, 0, 0.12);
    --accent: #0071e3;
    --accent-hover: #0077ed;
    --tag-bg: rgba(0, 113, 227, 0.08);
    --tag-color: #0071e3;
    --code-bg: #f5f5f7;
    --code-inline: #e03e3e;
    --pre-bg: #1c1c1e;
    --pre-color: #f5f5f7;
    --shadow: 0 1px 2px rgba(0,0,0,0.04), 0 4px 12px rgba(0,0,0,0.04);
    --shadow-hover: 0 2px 4px rgba(0,0,0,0.04), 0 8px 24px rgba(0,0,0,0.08);
    --radius: 12px;
    --radius-sm: 8px;
    --sidebar-width: 220px;
    --content-max: 640px;
}

/* Dark 主题 */
[data-theme="dark"] {
    --bg: #000000;
    --surface: #1c1c1e;
    --surface-hover: #2c2c2e;
    --text-primary: #f5f5f7;
    --text-secondary: #a1a1a6;
    --text-tertiary: #6e6e73;
    --border: rgba(255, 255, 255, 0.08);
    --border-strong: rgba(255, 255, 255, 0.12);
    --accent: #0a84ff;
    --accent-hover: #409cff;
    --tag-bg: rgba(10, 132, 255, 0.12);
    --tag-color: #0a84ff;
    --code-bg: #2c2c2e;
    --code-inline: #ff6b6b;
    --pre-bg: #0c0c0e;
    --pre-color: #f5f5f7;
    --shadow: 0 1px 2px rgba(0,0,0,0.2), 0 4px 12px rgba(0,0,0,0.2);
    --shadow-hover: 0 2px 4px rgba(0,0,0,0.2), 0 8px 24px rgba(0,0,0,0.3);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-sans);
    background-color: var(--bg);
    color: var(--text-primary);
    line-height: 1.6;
    font-size: 15px;
    font-weight: 400;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    letter-spacing: -0.01em;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.container {
    max-width: 960px;
    margin: 0 auto;
    padding: 0 24px;
}

/* ===== 头部导航 ===== */
.site-header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 14px 0;
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.site-header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.site-title {
    font-size: 17px;
    font-weight: 600;
    color: var(--text-primary);
    text-decoration: none;
    letter-spacing: -0.02em;
}

.site-title:hover {
    color: var(--accent);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 20px;
}

.site-nav {
    display: flex;
    gap: 20px;
}

.nav-link {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: color 0.2s;
    letter-spacing: -0.01em;
}

.nav-link:hover {
    color: var(--accent);
}

/* 主题切换按钮 */
.theme-toggle {
    background: var(--code-bg);
    border: 1px solid var(--border);
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 15px;
    color: var(--text-secondary);
    transition: all 0.2s;
    padding: 0;
    line-height: 1;
}

.theme-toggle:hover {
    border-color: var(--border-strong);
    color: var(--text-primary);
    transform: scale(1.05);
}

.theme-icon {
    display: none;
}

[data-theme="dark"] .theme-icon.dark,
[data-theme="light"] .theme-icon.light {
    display: inline;
}

/* ===== 主内容区 ===== */
.main-content {
    min-height: calc(100vh - 140px);
    padding: 40px 0;
}

/* ===== 首页两栏布局 ===== */
.home-layout {
    display: flex;
    gap: 48px;
    align-items: flex-start;
}

/* ===== 侧边栏 ===== */
.sidebar {
    width: var(--sidebar-width);
    flex-shrink: 0;
    position: sticky;
    top: 80px;
}

.sidebar-inner {
    text-align: center;
}

.avatar-wrap {
    margin-bottom: 16px;
}

.avatar {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    object-fit: cover;
    box-shadow: var(--shadow);
    border: 3px solid var(--surface);
    transition: box-shadow 0.3s, transform 0.3s;
}

.avatar:hover {
    transform: scale(1.03);
    box-shadow: var(--shadow-hover);
}

.sidebar-name {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
    letter-spacing: -0.02em;
}

.sidebar-bio {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.7;
    margin-bottom: 16px;
}

.sidebar-links {
    display: flex;
    justify-content: center;
    gap: 12px;
}

.sidebar-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--text-secondary);
    text-decoration: none;
    padding: 6px 12px;
    border-radius: 100px;
    background: var(--code-bg);
    border: 1px solid var(--border);
    transition: all 0.2s;
}

.sidebar-link:hover {
    color: var(--accent);
    border-color: var(--border-strong);
    background: var(--surface-hover);
}

/* ===== 文章列表 ===== */
.post-list-wrap {
    flex: 1;
    min-width: 0;
}

.post-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.post-card {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    transition: box-shadow 0.25s, transform 0.25s;
    border: 1px solid var(--border);
}

.post-card:hover {
    box-shadow: var(--shadow-hover);
    transform: translateY(-2px);
}

.post-card-link {
    display: block;
    padding: 24px 28px;
    text-decoration: none;
    color: inherit;
}

.post-card-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
    line-height: 1.4;
    letter-spacing: -0.02em;
}

.post-card-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

.post-date {
    font-size: 12px;
    color: var(--text-tertiary);
    font-weight: 500;
}

.post-tags {
    display: flex;
    gap: 6px;
}

.tag {
    display: inline-block;
    padding: 2px 10px;
    background: var(--tag-bg);
    color: var(--tag-color);
    font-size: 11px;
    border-radius: 100px;
    font-weight: 500;
    letter-spacing: 0.02em;
}

.post-card-summary {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.7;
    letter-spacing: -0.01em;
}

/* ===== 文章详情页 ===== */
.post-article {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    padding: 40px;
    max-width: var(--content-max);
    margin: 0 auto;
}

.post-header {
    margin-bottom: 28px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border);
}

.post-title {
    font-size: 26px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.3;
    margin-bottom: 12px;
    letter-spacing: -0.03em;
}

.post-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

/* ===== 目录 ===== */
.post-toc {
    margin-bottom: 28px;
    padding: 16px 20px;
    background: var(--code-bg);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

.post-toc details summary {
    font-weight: 600;
    cursor: pointer;
    color: var(--text-primary);
    font-size: 14px;
    outline: none;
    list-style: none;
    user-select: none;
}

.post-toc details summary::-webkit-details-marker {
    display: none;
}

.post-toc details summary::before {
    content: "▸ ";
    display: inline-block;
    transition: transform 0.2s;
    margin-right: 2px;
}

.post-toc details[open] summary::before {
    transform: rotate(90deg);
}

.post-toc ul {
    list-style: none;
    padding-left: 0;
    margin-top: 10px;
}

.post-toc ul ul {
    padding-left: 18px;
}

.post-toc li {
    margin: 5px 0;
}

.post-toc a {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 13px;
    transition: color 0.2s;
    line-height: 1.6;
}

.post-toc a:hover {
    color: var(--accent);
}

/* ===== Markdown 正文样式 ===== */
.markdown-body {
    font-size: 15px;
    line-height: 1.8;
    color: var(--text-primary);
    letter-spacing: -0.01em;
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4 {
    font-weight: 600;
    margin-top: 32px;
    margin-bottom: 14px;
    color: var(--text-primary);
    line-height: 1.3;
    letter-spacing: -0.02em;
}

.markdown-body h1 { font-size: 24px; }
.markdown-body h2 { font-size: 20px; border-bottom: 1px solid var(--border); padding-bottom: 8px; margin-top: 36px; }
.markdown-body h3 { font-size: 17px; margin-top: 28px; }
.markdown-body h4 { font-size: 15px; margin-top: 24px; }

.markdown-body p {
    margin-bottom: 16px;
}

.markdown-body a {
    color: var(--accent);
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: border-color 0.2s;
}

.markdown-body a:hover {
    border-bottom-color: var(--accent);
}

.markdown-body ul,
.markdown-body ol {
    margin-bottom: 16px;
    padding-left: 24px;
}

.markdown-body li {
    margin: 5px 0;
}

.markdown-body blockquote {
    margin: 20px 0;
    padding: 12px 18px;
    border-left: 3px solid var(--accent);
    background: var(--code-bg);
    color: var(--text-secondary);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    font-style: italic;
}

.markdown-body blockquote p:last-child {
    margin-bottom: 0;
}

.markdown-body code {
    font-family: var(--font-mono);
    font-size: 0.85em;
    background: var(--code-bg);
    padding: 2px 6px;
    border-radius: 4px;
    color: var(--code-inline);
    font-weight: 500;
}

.markdown-body pre {
    background: var(--pre-bg);
    padding: 18px;
    border-radius: var(--radius-sm);
    overflow-x: auto;
    margin-bottom: 18px;
    border: 1px solid var(--border);
}

.markdown-body pre code {
    background: none;
    padding: 0;
    color: var(--pre-color);
    font-size: 13px;
    line-height: 1.6;
    font-weight: 400;
}

/* 代码高亮 */
.highlight {
    background: var(--pre-bg);
    border-radius: var(--radius-sm);
    overflow-x: auto;
    border: 1px solid var(--border);
}

.highlight pre {
    margin: 0;
    background: none;
    border: none;
}

.markdown-body table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 18px;
    font-size: 14px;
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.markdown-body th,
.markdown-body td {
    padding: 10px 14px;
    border: 1px solid var(--border);
    text-align: left;
}

.markdown-body th {
    background: var(--code-bg);
    font-weight: 600;
    color: var(--text-primary);
}

.markdown-body tr:nth-child(even) {
    background: var(--surface-hover);
}

.markdown-body hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 28px 0;
}

.markdown-body img {
    max-width: 100%;
    height: auto;
    border-radius: var(--radius-sm);
    display: block;
    margin: 18px auto;
}

/* ===== 文章底部 ===== */
.post-footer {
    margin-top: 40px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

.back-link {
    color: var(--accent);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
}

.back-link:hover {
    text-decoration: underline;
}

/* ===== 关于页 ===== */
.about-page {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    padding: 40px;
    max-width: var(--content-max);
    margin: 0 auto;
}

.about-page h1 {
    font-size: 26px;
    font-weight: 700;
    margin-bottom: 20px;
    letter-spacing: -0.03em;
}

.about-page p {
    margin-bottom: 14px;
    color: var(--text-secondary);
    line-height: 1.7;
}

.about-page code {
    font-family: var(--font-mono);
    background: var(--code-bg);
    padding: 2px 7px;
    border-radius: 4px;
    font-size: 0.88em;
    color: var(--code-inline);
}

.about-page pre {
    background: var(--pre-bg);
    padding: 18px;
    border-radius: var(--radius-sm);
    overflow-x: auto;
    margin: 16px 0;
    border: 1px solid var(--border);
}

.about-page pre code {
    background: none;
    padding: 0;
    color: var(--pre-color);
    font-size: 13px;
}

/* ===== 空状态 ===== */
.empty-state {
    text-align: center;
    padding: 80px 20px;
    color: var(--text-tertiary);
}

.empty-state p {
    margin: 8px 0;
    font-size: 14px;
}

.empty-state code {
    background: var(--code-bg);
    padding: 2px 7px;
    border-radius: 4px;
    font-size: 0.9em;
    font-family: var(--font-mono);
}

/* ===== 页脚 ===== */
.site-footer {
    border-top: 1px solid var(--border);
    padding: 24px 0;
    text-align: center;
    color: var(--text-tertiary);
    font-size: 13px;
    background: var(--surface);
    transition: background-color 0.3s, border-color 0.3s;
}

/* ===== 响应式 ===== */
@media (max-width: 800px) {
    .home-layout {
        flex-direction: column;
        gap: 32px;
    }

    .sidebar {
        width: 100%;
        position: static;
        top: auto;
    }

    .sidebar-inner {
        display: flex;
        align-items: center;
        gap: 16px;
        text-align: left;
    }

    .avatar-wrap {
        margin-bottom: 0;
        flex-shrink: 0;
    }

    .avatar {
        width: 64px;
        height: 64px;
    }

    .sidebar-info {
        flex: 1;
        min-width: 0;
    }

    .sidebar-name {
        margin-bottom: 4px;
    }

    .sidebar-bio {
        margin-bottom: 8px;
    }

    .sidebar-links {
        justify-content: flex-start;
    }
}

@media (max-width: 640px) {
    .container {
        padding: 0 16px;
    }

    .post-article,
    .about-page {
        padding: 24px 20px;
    }

    .post-title {
        font-size: 22px;
    }

    .post-card-link {
        padding: 20px 22px;
    }

    .main-content {
        padding: 24px 0;
    }

    .markdown-body h1 { font-size: 20px; }
    .markdown-body h2 { font-size: 18px; }
    .markdown-body h3 { font-size: 16px; }
}
