/* CSS Variables */
:root {
    --bg: #fafafa;
    --bg-secondary: #f5f5f5;
    --text: #111;
    --text-secondary: #444;
    --text-muted: #888;
    --border: #eaeaea;
    --code-bg: #f5f5f5;
}

[data-theme="dark"] {
    --bg: #0a0a0a;
    --bg-secondary: #111;
    --text: #ededed;
    --text-secondary: #a0a0a0;
    --text-muted: #666;
    --border: #222;
    --code-bg: #141414;
}

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

/* Base */
html {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif, 'PingFang SC', 'Microsoft YaHei';
    font-size: 16px;
    line-height: 1.6;
    color: var(--text);
    background: var(--bg);
    transition: background-color 0.2s, color 0.2s;
}

.container {
    max-width: 680px;
    margin: 0 auto;
    padding: 48px 24px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.site-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 24px;
    margin-bottom: 48px;
    border-bottom: 1px solid var(--border);
}

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

.site-title:hover {
    opacity: 0.7;
}

.site-nav {
    display: flex;
    align-items: center;
    gap: 16px;
}

.site-nav a {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 14px;
    transition: color 0.15s;
}

.site-nav a:hover {
    color: var(--text);
}

.lang-switch {
    display: flex;
    align-items: center;
    padding: 2px;
    transition: opacity 0.15s !important;
}

.lang-switch:hover {
    opacity: 0.6;
}

/* Theme Toggle */
.theme-toggle {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    transition: color 0.15s;
}

.theme-toggle:hover {
    color: var(--text);
}

.theme-toggle .sun-icon { display: none; }
.theme-toggle .moon-icon { display: block; }
[data-theme="dark"] .theme-toggle .sun-icon { display: block; }
[data-theme="dark"] .theme-toggle .moon-icon { display: none; }

/* Main */
main {
    flex: 1;
}

.page-title {
    font-size: 24px;
    font-weight: 600;
    margin-bottom: 32px;
    color: var(--text);
    letter-spacing: -0.02em;
}

.intro {
    color: var(--text-muted);
    font-size: 16px;
    margin-bottom: 40px;
}

/* Post List */
.post-list {
    list-style: none;
}

.post-item {
    padding: 16px 0;
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 16px;
    border-bottom: 1px solid var(--border);
}

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

.post-item a {
    color: var(--text);
    text-decoration: none;
    font-size: 16px;
    font-weight: 500;
    transition: opacity 0.15s;
}

.post-item a:hover {
    opacity: 0.6;
}

.post-item-main {
    flex: 1;
    min-width: 0;
}

.post-item-desc {
    color: var(--text-muted);
    font-size: 14px;
    margin-top: 4px;
    line-height: 1.5;
}

.post-item time {
    color: var(--text-muted);
    font-size: 14px;
    flex-shrink: 0;
    font-variant-numeric: tabular-nums;
}

/* Post */
.post-header {
    margin-bottom: 48px;
}

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

.post-meta {
    color: var(--text-muted);
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}

.post-meta .separator {
    color: var(--border);
}

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

.tag {
    display: inline-block;
    padding: 2px 10px;
    border: 1px solid var(--border);
    color: var(--text-muted);
    border-radius: 4px;
    font-size: 13px;
    text-decoration: none;
    transition: border-color 0.15s;
}

.tag:hover {
    border-color: var(--text-muted);
    color: var(--text-secondary);
}

/* Post Description */
.post-desc {
    color: var(--text-muted);
    font-size: 16px;
    line-height: 1.6;
    margin-top: 16px;
}

/* Post Description Separator */
.post-header:has(.post-desc) {
    margin-bottom: 0;
}

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

/* Post Preface */
.post-preface {
    font-size: 16px;
    line-height: 1.8;
    color: var(--text-secondary);
    margin-bottom: 32px;
}

/* Table of Contents */
.toc {
    margin-bottom: 48px;
    padding-left: 20px;
    border-left: 2px solid var(--border);
}

.toc ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

.toc li {
    margin: 4px 0;
}

.toc li.toc-h3 {
    padding-left: 14px;
}

.toc a {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 14px;
    transition: color 0.15s;
}

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

/* TOC Layout */
.post-with-toc {
    position: relative;
}

.toc-sidebar {
    display: none;
}

.toc-sidebar .toc {
    position: sticky;
    top: 24px;
    margin-bottom: 0;
    max-height: calc(100vh - 48px);
    overflow-y: auto;
}

.toc-sidebar .toc-title {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 12px;
}

.toc-sidebar .toc a.active {
    color: var(--text);
}

@media (min-width: 1200px) {
    .toc-sidebar {
        position: absolute;
        top: 0;
        bottom: 0;
        left: -232px;
        width: 200px;
        display: block;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.2s;
    }

    .toc-sidebar.visible {
        opacity: 1;
        pointer-events: auto;
    }
}

/* Post Content */
.post-content {
    line-height: 1.8;
    font-size: 16px;
}

.post-content h2 {
    font-size: 22px;
    font-weight: 600;
    margin-top: 48px;
    margin-bottom: 16px;
    color: var(--text);
    letter-spacing: -0.02em;
}

.post-content h3 {
    font-size: 18px;
    font-weight: 600;
    margin-top: 32px;
    margin-bottom: 12px;
    color: var(--text);
}

.post-content p {
    margin-bottom: 20px;
    color: var(--text-secondary);
}

.post-content ul, .post-content ol {
    margin-bottom: 20px;
    padding-left: 24px;
    color: var(--text-secondary);
}

.post-content li {
    margin-bottom: 8px;
}

.post-content li::marker {
    color: var(--text-muted);
}

.post-content a {
    color: var(--text);
    text-decoration: underline;
    text-underline-offset: 3px;
    text-decoration-color: var(--border);
    transition: text-decoration-color 0.15s;
}

.post-content a:hover {
    text-decoration-color: var(--text);
}

.post-content strong {
    color: var(--text);
    font-weight: 600;
}

/* Code */
.post-content code {
    font-family: 'Fira Code', monospace;
    font-size: 0.875em;
    background: var(--code-bg);
    padding: 2px 5px;
    border-radius: 3px;
}

.post-content pre {
    position: relative;
    background: var(--code-bg);
    padding: 20px;
    border-radius: 6px;
    overflow-x: auto;
    margin: 24px 0;
    border: 1px solid var(--border);
}

.post-content pre code {
    background: none;
    padding: 0;
    border: none;
    font-size: 14px;
    line-height: 1.6;
}

.copy-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    padding: 4px 10px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 12px;
    color: var(--text-muted);
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.15s;
}

.post-content pre:hover .copy-btn {
    opacity: 1;
}

.copy-btn:hover {
    border-color: var(--text-muted);
    color: var(--text-secondary);
}

/* Blockquote */
.post-content blockquote {
    border-left: 2px solid var(--border);
    padding: 0 0 0 20px;
    margin: 24px 0;
    color: var(--text-muted);
}

/* Tables */
.post-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 24px 0;
    font-size: 15px;
}

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

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

.post-content td {
    color: var(--text-secondary);
}

/* Horizontal Rule */
.post-content hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 32px 0;
}

/* Strikethrough */
.post-content del {
    color: var(--text-muted);
}

/* Task List */
.post-content ul:has(input[type="checkbox"]) {
    list-style: none;
    padding-left: 4px;
}

.post-content input[type="checkbox"] {
    margin-right: 6px;
    accent-color: var(--text-muted);
}

/* Images */
.post-content img {
    max-width: 100%;
    border-radius: 6px;
    margin: 24px 0;
    border: 1px solid var(--border);
}

/* Post Navigation */
.post-nav {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-top: 48px;
    padding-top: 24px;
    border-top: 1px solid var(--border);
}

.post-nav-item {
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: 6px;
    text-decoration: none;
    transition: border-color 0.15s;
}

.post-nav-item:hover {
    border-color: var(--text-muted);
}

.post-nav-item.next {
    text-align: right;
}

.post-nav-label {
    display: block;
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 4px;
}

.post-nav-title {
    display: block;
    color: var(--text);
    font-weight: 500;
    font-size: 14px;
}

/* Archive */
.archive {
    padding-left: 24px;
    font-size: 16px;
    line-height: 1.8;
}

.archive > li {
    font-size: 18px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 16px;
}

.archive ul {
    padding-left: 24px;
    margin-top: 4px;
}

.archive ul li {
    font-weight: 400;
    font-size: 16px;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

.archive ul li a {
    margin-left: 6px;
    color: var(--text);
    text-decoration: underline;
    text-underline-offset: 3px;
    text-decoration-color: var(--border);
    transition: text-decoration-color 0.15s;
}

.archive ul li a:hover {
    text-decoration-color: var(--text);
}

.archive-desc {
    color: var(--text-muted);
    font-size: 14px;
    margin-top: 2px;
    line-height: 1.5;
}

/* Tags Page */
.tags-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 40px;
}

/* 404 Page */
.not-found {
    text-align: center;
    padding: 80px 0;
}

.not-found h1 {
    font-size: 48px;
    font-weight: 700;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.not-found p {
    color: var(--text-muted);
    margin-bottom: 24px;
}

.not-found a {
    color: var(--text);
    text-decoration: underline;
    text-underline-offset: 3px;
}

/* Footer */
.site-footer {
    margin-top: 64px;
    padding-top: 24px;
    border-top: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 13px;
    text-align: center;
}

/* Responsive */
@media (max-width: 640px) {
    .container {
        padding: 32px 16px;
    }

    .site-header {
        flex-direction: column;
        gap: 12px;
        text-align: center;
    }

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

    .post-item {
        flex-direction: column;
        gap: 4px;
    }

    .post-nav {
        grid-template-columns: 1fr;
    }
}

/* Selection */
::selection {
    background: var(--text);
    color: var(--bg);
}
