/* ========== 重置 ========== */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    height: 100%;
    overflow-x: hidden;
}

/* ========== 主题变量 ========== */
:root {
    --bg:             #131417;
    --bg-sidebar:     #131417;
    --bg-card:        #1e1f24;
    --text:           #c9d1d9;
    --text-muted:     #6b7280;
    --accent:         #58a6ff;
    --border:         #2d333b;
    --code-bg:        #161b22;
    --hover-bg:       #1e2028;
}

[data-theme="light"] {
    --bg:             #fafaf9;
    --bg-sidebar:     #fafaf9;
    --bg-card:        #ffffff;
    --text:           #1f2937;
    --text-muted:     #9ca3af;
    --accent:         #2563eb;
    --border:         #e5e7eb;
    --code-bg:        #f3f4f6;
    --hover-bg:       #f5f5f4;
}

/* ========== 全局 ========== */
body {
    background: var(--bg);
    color: var(--text);
    font-family: "Noto Serif SC", "Georgia", serif;
    font-size: 16px;
    line-height: 1.7;
    -webkit-font-smoothing: antialiased;
}

a {
    color: var(--accent);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* ========== 整体布局 ========== */
.layout {
    display: flex;
    min-height: 90vh;
    max-width: 1100px;
    margin: 0 auto;
    align-items: stretch;
}

/* ========== 左侧导航栏 ========== */
.sidebar {
    width: 220px;
    min-width: 220px;
    padding: 3rem 1.5rem;
    border-right: 1px solid var(--border);
    position: sticky;
    top: 0;
    height: 90vh;
    display: flex;
    flex-direction: column;
    background: var(--bg-sidebar);
}

.profile {
    margin-bottom: 2rem;
}

.site-name {
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: 0.2rem;
    color: var(--text);
}

.site-desc {
    color: var(--text-muted);
    font-size: 0.8rem;
    line-height: 1.5;
}

/* 导航链接 */
.site-nav {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.site-nav a {
    color: var(--text-muted);
    text-decoration: none;
    padding: 0.4rem 0.7rem;
    border-radius: 6px;
    font-size: 0.9rem;
    transition: all 0.2s ease;
}

.site-nav a:hover {
    color: var(--text);
    background: var(--hover-bg);
    text-decoration: none;
}

.site-nav a.active {
    color: var(--accent);
    background: var(--hover-bg);
    font-weight: 600;
}

/* ========== 右侧内容区 ========== */
.content {
    flex: 1;
    padding: 3rem 2.5rem;
    min-width: 0;
    min-height: 90vh;
    display: flex;
    flex-direction: column;
}

/* ========== 面包屑导航 ========== */
.breadcrumb {
    margin-bottom: 1.5rem;
    font-size: 0.85rem;
    font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
    flex: 0 0 auto;
    justify-content: normal;
    overflow-x: visible;
    overflow-y: visible;
}

.breadcrumb a {
    color: var(--text-muted);
    text-decoration: none;
}

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

.breadcrumb .separator {
    color: var(--text-muted);
    margin: 0 0.4rem;
    opacity: 0.5;
}

.breadcrumb .current {
    color: var(--text);
}

/* ========== 英雄区 ========== */
.hero {
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
}

.hero h2 {
    font-size: 1.4rem;
    font-weight: 600;
    margin-bottom: 0.4rem;
    color: var(--text);
}

.hero p {
    color: var(--text-muted);
    font-size: 0.9rem;
    line-height: 1.6;
}

/* ========== 文章列表项 ========== */
.post-item {
    padding: 1rem 0;
    border-bottom: 1px solid var(--border);
    background: none;
    box-shadow: none;
    border-radius: 0;
    margin: 0;
}

.post-item:last-child {
    border-bottom: none;
}

.post-title-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.post-title-row h3 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
}

.post-title-row h3 a {
    color: var(--text);
    text-decoration: none;
}

.post-title-row h3 a:hover {
    color: var(--accent);
    text-decoration: none;
}

.post-item .meta {
    color: var(--text-muted);
    font-size: 0.8rem;
    margin-top: 0.2rem;
}

.post-item .meta .date {
    font-family: -apple-system, "SF Pro Text", "PingFang SC", sans-serif;
    letter-spacing: 0.5px;
}

/* 标题旁边的小标签 */
.tag-inline {
    font-size: 0.7rem;
    color: var(--text-muted);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 0.05em 0.4em;
    text-decoration: none;
    line-height: 1.4;
    transition: all 0.2s ease;
}

.tag-inline:hover {
    color: var(--accent);
    border-color: var(--accent);
    text-decoration: none;
}

/* ========== 文章详情页 ========== */
.post-header {
    flex: 0 0 auto;
    margin-bottom: 1.2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.post-header h1 {
    font-size: 1.6rem;
    font-weight: 700;
    line-height: 1.4;
    margin-bottom: 0.5rem;
    color: var(--text);
}

.post-meta {
    display: flex;
    align-items: center;
    color: var(--text-muted);
    font-size: 0.85rem;
    font-family: -apple-system, "PingFang SC", sans-serif;
}

.post-meta .date {
    font-family: "JetBrains Mono", monospace;
    font-size: 0.8rem;
    color: #8b949e;
}

.post-meta .dot {
    margin: 0 0.5rem;
    opacity: 0.4;
}

.post-meta .author {
    color: var(--accent);
}

/* ========== 文章正文 ========== */
.post-content {
    max-width: 700px;
    font-size: 16px;
    line-height: 1.85;
    flex: 0 0 auto;
}

.post-content h2 {
    font-size: 1.4rem;
    font-weight: 700;
    margin-top: 2.5rem;
    margin-bottom: 0.8rem;
    padding-bottom: 0.3rem;
    border-bottom: 1px solid var(--border);
    color: var(--text);
}

.post-content h3 {
    font-size: 1.15rem;
    font-weight: 600;
    margin-top: 2rem;
    margin-bottom: 0.6rem;
    color: var(--text);
}

.post-content h4 {
    font-size: 1rem;
    font-weight: 600;
    margin-top: 1.5rem;
    margin-bottom: 0.5rem;
}

.post-content p {
    margin-bottom: 1.2em;
}

.post-content a {
    color: var(--accent);
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 3px;
}

.post-content a:hover {
    text-decoration-thickness: 2px;
}

.post-content img {
    max-width: 100%;
    border-radius: 6px;
    margin: 1.5em auto;
    display: block;
}

.post-content blockquote {
    border-left: 3px solid var(--accent);
    padding: 0.5rem 1rem;
    margin: 1.5em 0;
    color: var(--text-muted);
    background: var(--bg-card);
    border-radius: 0 6px 6px 0;
}

.post-content blockquote p:last-child {
    margin-bottom: 0;
}

.post-content ul,
.post-content ol {
    margin-bottom: 1.2em;
    padding-left: 1.5em;
}

.post-content li {
    margin-bottom: 0.4em;
}

.post-content li ul,
.post-content li ol {
    margin-top: 0.4em;
    margin-bottom: 0;
}

/* 行内代码 */
.post-content code {
    background: var(--code-bg);
    padding: 0.15em 0.4em;
    border-radius: 4px;
    font-size: 0.88em;
    font-family: "JetBrains Mono", "Fira Code", monospace;
    color: #e6b450;
}

/* 代码块 */
.post-content pre {
    background: var(--code-bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 1rem 1.2rem;
    overflow-x: auto;
    font-family: "JetBrains Mono", "Fira Code", monospace;
    font-size: 13px;
    line-height: 1.65;
    margin-bottom: 1.5em;
    position: relative;
}

.post-content pre code {
    background: none;
    padding: 0;
    font-size: inherit;
    color: var(--text);
}

/* 代码块语言标签 */
.post-content pre::before {
    content: attr(data-lang);
    position: absolute;
    top: 0.4rem;
    right: 0.8rem;
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    font-family: -apple-system, sans-serif;
}

/* 水平线 */
.post-content hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 2.5em 0;
}

/* 表格 */
.post-content table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1.5em;
    font-size: 0.9rem;
}

.post-content th,
.post-content td {
    border: 1px solid var(--border);
    padding: 0.6rem 0.8rem;
    text-align: left;
}

.post-content th {
    background: var(--code-bg);
    font-weight: 600;
}

.post-content tr:hover {
    background: var(--hover-bg);
}

/* 提示框 */
.post-content .note {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-left: 3px solid var(--accent);
    border-radius: 0 6px 6px 0;
    padding: 0.8rem 1rem;
    margin: 1.5em 0;
    font-size: 0.9rem;
}

.post-content .note::before {
    content: "💡 ";
}

/* ========== 目录 ========== */
.toc {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.8rem 1.2rem;
    margin-bottom: 2rem;
    flex: 0 0 auto;
}

.toc summary {
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text);
    padding: 0.2rem 0;
    list-style: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.toc summary::before {
    content: "▼";
    font-size: 0.6rem;
    color: var(--text-muted);
    transition: transform 0.2s ease;
}

.toc[open] summary::before {
    transform: rotate(0deg);
}

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

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

.toc ul {
    list-style: none;
    margin-top: 0.5rem;
    padding-left: 0.8rem;
    border-top: 1px solid var(--border);
    padding-top: 0.5rem;
}

.toc li {
    margin: 0.3rem 0;
}

.toc a {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.88rem;
    padding: 0.15rem 0;
    display: inline-block;
}

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

/* ========== 文章标签 ========== */
.post-tags {
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    flex: 0 0 auto;
}

.tag {
    display: inline-block;
    font-size: 0.75rem;
    color: var(--accent);
    border: 1px solid var(--accent);
    border-radius: 4px;
    padding: 0.1em 0.5em;
    margin-left: 0.2rem;
    text-decoration: none;
}

.tag:hover {
    background: var(--accent);
    color: var(--bg);
    text-decoration: none;
}

/* ========== 上下篇导航 ========== */
.post-nav {
    display: flex;
    justify-content: space-between;
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
    flex: 0 0 auto;
}

.post-nav a {
    color: var(--accent);
    font-size: 0.9rem;
    text-decoration: none;
    max-width: 45%;
}

.post-nav a:hover {
    text-decoration: underline;
}

/* ========== 分页 ========== */
.pagination {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
}

.pagination a,
.pagination span {
    padding: 0.3rem 0.7rem;
    border-radius: 4px;
    font-size: 0.85rem;
    color: var(--text-muted);
    text-decoration: none;
}

.pagination a:hover {
    background: var(--hover-bg);
    color: var(--text);
    text-decoration: none;
}

.pagination .current {
    background: var(--hover-bg);
    color: var(--accent);
    font-weight: 600;
}

/* ========== 归档页 ========== */
.archive-year {
    margin-bottom: 2rem;
}

.archive-year h3 {
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: 0.8rem;
    color: var(--text);
}

.archive-item {
    display: flex;
    align-items: baseline;
    gap: 1rem;
    padding: 0.5rem 0;
    border-bottom: 1px dashed var(--border);
}

.archive-item:last-child {
    border-bottom: none;
}

.archive-item .date {
    color: var(--text-muted);
    font-family: "JetBrains Mono", monospace;
    font-size: 0.78rem;
    min-width: 90px;
    flex-shrink: 0;
}

.archive-item a {
    color: var(--text);
    text-decoration: none;
    font-size: 0.95rem;
}

.archive-item a:hover {
    color: var(--accent);
}

/* ========== 标签页 ========== */
.tag-cloud {
    display: flex;
    flex-wrap: wrap;
    gap: 0.8rem;
    margin-top: 1.5rem;
}

.tag-item {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.4rem 1rem;
    border: 1px solid var(--border);
    border-radius: 20px;
    text-decoration: none;
    transition: all 0.2s ease;
}

.tag-item:hover {
    border-color: var(--accent);
    text-decoration: none;
}

.tag-item .tag-name {
    color: var(--text);
    font-size: 0.9rem;
}

.tag-item .tag-count {
    background: var(--code-bg);
    color: var(--text-muted);
    font-size: 0.75rem;
    padding: 0.1rem 0.4rem;
    border-radius: 10px;
    min-width: 20px;
    text-align: center;
}

.tag-item:hover .tag-name {
    color: var(--accent);
}

/* ========== 代码高亮 ========== */
.chroma {
    background: #1e1e2e;
    border-radius: 6px;
    padding: 1rem 1.2rem;
    overflow-x: auto;
    margin-bottom: 1.5em;
    font-family: "JetBrains Mono", monospace;
    font-size: 13px;
    line-height: 1.65;
}

.chroma .lnt  { color: #6b7280; margin-right: 0.8rem; }
.chroma .k   { color: #ff79c6; }
.chroma .kd  { color: #ff79c6; }
.chroma .kt  { color: #8be9fd; }
.chroma .kn  { color: #ff79c6; }
.chroma .kr  { color: #ff79c6; }
.chroma .kc  { color: #bd93f9; }
.chroma .s   { color: #f1fa8c; }
.chroma .sa  { color: #f1fa8c; }
.chroma .sb  { color: #f1fa8c; }
.chroma .sc  { color: #f1fa8c; }
.chroma .dl  { color: #f1fa8c; }
.chroma .sd  { color: #6272a4; }
.chroma .s2  { color: #f1fa8c; }
.chroma .si  { color: #f1fa8c; }
.chroma .se  { color: #ff6e6e; }
.chroma .sh  { color: #f1fa8c; }
.chroma .sr  { color: #f1fa8c; }
.chroma .sx  { color: #f1fa8c; }
.chroma .fm  { color: #50fa7b; }
.chroma .fn  { color: #50fa7b; }
.chroma .c   { color: #6272a4; font-style: italic; }
.chroma .ch  { color: #6272a4; font-style: italic; }
.chroma .cm  { color: #6272a4; font-style: italic; }
.chroma .c1  { color: #6272a4; font-style: italic; }
.chroma .cs  { color: #6272a4; font-style: italic; }
.chroma .cpf { color: #6272a4; font-style: italic; }
.chroma .o   { color: #ff79c6; }
.chroma .ow  { color: #ff79c6; }
.chroma .p   { color: #f8f8f2; }
.chroma .n   { color: #f8f8f2; }
.chroma .nb  { color: #8be9fd; }
.chroma .nc  { color: #8be9fd; }
.chroma .no  { color: #bd93f9; }
.chroma .nd  { color: #50fa7b; }
.chroma .ni  { color: #f8f8f2; }
.chroma .ne  { color: #ff6e6e; }
.chroma .nf  { color: #50fa7b; }
.chroma .nl  { color: #f1fa8c; }
.chroma .nn  { color: #f8f8f2; }
.chroma .nt  { color: #ff79c6; }
.chroma .nv  { color: #f8f8f2; }
.chroma .vg  { color: #f8f8f2; }
.chroma .vi  { color: #f8f8f2; }
.chroma .vm  { color: #f8f8f2; }
.chroma .na  { color: #50fa7b; }
.chroma .bp  { color: #f8f8f2; }
.chroma .ge  { font-style: italic; }
.chroma .gs  { font-weight: 700; }
.chroma .w   { color: #f8f8f2; }

/* ========== Footer ========== */
footer {
    margin-top: auto;
    text-align: center;
    padding: 0.6rem 0;
    border-top: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 0.75rem;
    font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
    flex: 0 0 auto;
}

footer .dot {
    margin: 0 0.5rem;
    opacity: 0.4;
}

footer a {
    color: var(--text-muted);
    text-decoration: none;
}

footer a:hover {
    color: var(--accent);
}

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

    .sidebar {
        width: 100%;
        min-width: auto;
        height: auto;
        position: relative;
        padding: 1.5rem;
        border-right: none;
        border-bottom: 1px solid var(--border);
    }

    .site-nav {
        flex-direction: row;
        gap: 0.3rem;
        flex-wrap: wrap;
    }

    .site-nav a {
        font-size: 0.85rem;
        padding: 0.3rem 0.6rem;
    }

    .content {
        padding: 1.5rem 1rem;
    }

    .hero h2 {
        font-size: 1.2rem;
    }

    .post-header h1 {
        font-size: 1.3rem;
    }

    .post-meta {
        flex-wrap: wrap;
        gap: 0.2rem;
    }

    .post-content {
        font-size: 15px;
    }

    .post-content pre {
        font-size: 12px;
        padding: 0.8rem;
    }

    .toc {
        padding: 0.6rem 1rem;
    }

    .post-nav {
        flex-direction: column;
        gap: 0.8rem;
    }

    .post-nav a {
        max-width: 100%;
    }
}

@media (max-width: 480px) {
    .sidebar {
        padding: 1rem;
    }

    .site-name {
        font-size: 1.1rem;
    }

    .content {
        padding: 1rem 0.8rem;
    }
}
