:root {
    --bg: #ffffff;
    --fg: #18181b;
    --muted: #71717a;
    --line: #e4e4e7;
    --surface: #fafafa;
    --code-bg: #f4f4f5;
    --accent: #18181b;
    --header-bg: rgba(255, 255, 255, 0.86);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
    --radius: 10px;
    --wrap: 760px;
}

[data-theme="dark"] {
    --bg: #101012;
    --fg: #e7e7ea;
    --muted: #9b9ba3;
    --line: #2a2a2e;
    --surface: #17171a;
    --code-bg: #1c1c20;
    --accent: #e7e7ea;
    --header-bg: rgba(16, 16, 18, 0.86);
    --shadow: none;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--fg);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
        "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    font-size: 16px;
    line-height: 1.75;
    -webkit-font-smoothing: antialiased;
}

a {
    color: inherit;
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
    text-underline-offset: 3px;
}

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

.wrap {
    width: 100%;
    max-width: var(--wrap);
    margin: 0 auto;
    padding: 0 20px;
}

.skip-link {
    position: absolute;
    left: -9999px;
    top: 0;
    background: var(--fg);
    color: var(--bg);
    padding: 8px 14px;
    z-index: 100;
}

.skip-link:focus {
    left: 12px;
    top: 12px;
}

/* Header */
.site-header {
    position: sticky;
    top: 0;
    z-index: 20;
    background: var(--header-bg);
    border-bottom: 1px solid var(--line);
}

.header-inner {
    display: flex;
    align-items: center;
    gap: 20px;
    min-height: 60px;
}

.brand {
    font-family: "Noto Serif SC", "Songti SC", Georgia, serif;
    font-size: 19px;
    font-weight: 600;
    letter-spacing: 0.02em;
    white-space: nowrap;
}

.site-nav {
    display: flex;
    align-items: center;
    gap: 18px;
    overflow-x: auto;
    flex: 1;
    scrollbar-width: none;
    font-size: 14px;
    color: var(--muted);
}

.site-nav::-webkit-scrollbar {
    display: none;
}

.site-nav a {
    white-space: nowrap;
}

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

.theme-toggle {
    flex: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border: 1px solid var(--line);
    border-radius: 50%;
    background: transparent;
    color: var(--fg);
    cursor: pointer;
}

.theme-toggle:hover {
    background: var(--surface);
}

.theme-toggle svg {
    fill: none;
    stroke: currentColor;
    stroke-width: 1.7;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.theme-toggle .icon-sun {
    display: none;
}

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

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

/* Hero */
.hero {
    padding: 72px 0 56px;
}

.hero.has-image {
    position: relative;
    margin-top: 24px;
    padding: 96px 32px;
    border-radius: var(--radius);
    overflow: hidden;
    background-image: var(--hero-image);
    background-size: cover;
    background-position: center;
    color: #ffffff;
    text-align: center;
}

.hero.has-image::before {
    content: "";
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.48);
}

.hero-inner {
    position: relative;
}

.hero-title {
    margin: 0 0 10px;
    font-family: "Noto Serif SC", "Songti SC", Georgia, serif;
    font-size: 40px;
    font-weight: 600;
    letter-spacing: 0.04em;
}

.hero-desc {
    margin: 0;
    color: var(--muted);
    font-size: 15px;
}

.hero.has-image .hero-desc {
    color: rgba(255, 255, 255, 0.82);
}

/* Post list */
.post-list {
    border-top: 1px solid var(--line);
}

.post-card {
    display: grid;
    grid-template-columns: 1fr;
    gap: 18px;
    padding: 28px 0;
    border-bottom: 1px solid var(--line);
}

.post-card:has(.card-cover) {
    grid-template-columns: 1fr 200px;
    align-items: start;
}

.card-cover {
    order: 2;
    display: block;
    overflow: hidden;
    border-radius: var(--radius);
    background: var(--surface);
    aspect-ratio: 4 / 3;
}

.card-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.4s ease;
}

.card-cover:hover img {
    transform: scale(1.03);
}

.card-body {
    order: 1;
    min-width: 0;
}

.card-meta,
.post-meta {
    margin: 0 0 8px;
    color: var(--muted);
    font-size: 13px;
    letter-spacing: 0.01em;
}

.card-meta span,
.post-meta span {
    margin: 0 6px;
    color: var(--line);
}

.card-title {
    margin: 0 0 8px;
    font-family: "Noto Serif SC", "Songti SC", Georgia, serif;
    font-size: 22px;
    font-weight: 600;
    line-height: 1.45;
}

.card-excerpt {
    margin: 0 0 12px;
    color: var(--muted);
    font-size: 15px;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.empty {
    padding: 48px 0;
    color: var(--muted);
    text-align: center;
}

/* Archive */
.archive-header {
    padding: 56px 0 8px;
}

.archive-header h1 {
    margin: 0;
    font-family: "Noto Serif SC", "Songti SC", Georgia, serif;
    font-size: 30px;
    font-weight: 600;
}

/* Single post */
.post {
    padding: 56px 0 24px;
}

.post-header {
    margin-bottom: 32px;
}

.post-title {
    margin: 0;
    font-family: "Noto Serif SC", "Songti SC", Georgia, serif;
    font-size: 34px;
    font-weight: 600;
    line-height: 1.35;
    letter-spacing: 0.01em;
}

.post-cover {
    margin: 0 0 32px;
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--surface);
}

.post-content {
    font-size: 17px;
    line-height: 1.9;
}

.post-content > * + * {
    margin-top: 1.1em;
}

.post-content h2,
.post-content h3,
.post-content h4 {
    margin-top: 2em;
    font-family: "Noto Serif SC", "Songti SC", Georgia, serif;
    line-height: 1.4;
}

.post-content h2 {
    font-size: 26px;
}

.post-content h3 {
    font-size: 21px;
}

.post-content a {
    border-bottom: 1px solid var(--line);
}

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

.post-content blockquote {
    margin: 1.6em 0;
    padding: 4px 0 4px 20px;
    border-left: 3px solid var(--line);
    color: var(--muted);
}

.post-content code {
    padding: 0.15em 0.4em;
    background: var(--code-bg);
    border-radius: 4px;
    font-size: 0.9em;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.post-content pre {
    padding: 18px 20px;
    background: var(--code-bg);
    border-radius: var(--radius);
    overflow-x: auto;
    line-height: 1.65;
}

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

.post-content img {
    border-radius: var(--radius);
}

.post-content hr {
    border: 0;
    border-top: 1px solid var(--line);
    margin: 2.4em 0;
}

.post-content table {
    width: 100%;
    border-collapse: collapse;
    font-size: 15px;
}

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

.post-meta .post-views {
    margin: 0;
    color: var(--muted);
}

.post-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 40px;
}

.post-like {
    margin: 0;
}

.like-button {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: transparent;
    color: var(--fg);
    font: inherit;
    font-size: 14px;
    cursor: pointer;
    transition: border-color 0.2s ease, background-color 0.2s ease;
}

.like-button:hover {
    border-color: var(--fg);
    background: var(--surface);
}

.like-button:focus-visible {
    outline: 2px solid var(--fg);
    outline-offset: 3px;
}

.like-button svg {
    fill: none;
    stroke: currentColor;
    stroke-width: 1.6;
}

.like-count {
    color: var(--muted);
    font-variant-numeric: tabular-nums;
}

.post-toc {
    margin: 0 0 32px;
    padding: 12px 16px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    font-size: 14px;
}

.post-toc[hidden] {
    display: none;
}

.post-toc summary {
    min-height: 44px;
    align-content: center;
    cursor: pointer;
    font-weight: 600;
}

.post-toc ol {
    margin: 8px 0 0;
    padding: 0;
    list-style: none;
}

.post-toc a {
    display: block;
    padding: 10px 0;
    overflow-wrap: anywhere;
}

.post-toc .toc-subheading {
    padding-left: 20px;
}

.post-toc a:focus-visible,
.post-toc summary:focus-visible,
.post-related a:focus-visible {
    outline: 2px solid var(--fg);
    outline-offset: 3px;
}

.post-content h2,
.post-content h3 {
    scroll-margin-top: 88px;
}

.post-related {
    margin-top: 40px;
    padding-top: 24px;
    border-top: 1px solid var(--line);
}

.post-related h2 {
    margin: 0 0 12px;
    font-size: 20px;
}

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

.post-related a {
    display: block;
    padding: 10px 0;
    overflow-wrap: anywhere;
}

.archive-index ul {
    padding: 0;
    list-style: none;
}

.archive-index li a {
    display: block;
    padding: 10px 0;
    border-bottom: 1px solid var(--line);
    overflow-wrap: anywhere;
}

.archive-tags ul {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 0;
    list-style: none;
}

.archive-tags a {
    display: inline-block;
    padding: 10px 14px;
    border: 1px solid var(--line);
    border-radius: 999px;
    font-size: 14px;
}

.archive-tags span {
    color: var(--muted);
}

.post-footer {
    margin-top: 48px;
    padding-top: 24px;
    border-top: 1px solid var(--line);
}

.post-tags {
    margin-bottom: 20px;
    font-size: 13px;
    color: var(--muted);
}

.post-tags a {
    display: inline-block;
    margin: 0 8px 6px 0;
    padding: 2px 10px;
    border: 1px solid var(--line);
    border-radius: 999px;
}

.post-tags a:hover {
    text-decoration: none;
    border-color: var(--fg);
    color: var(--fg);
}

.post-nav {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 12px;
    font-size: 14px;
    color: var(--muted);
}

.post-nav a {
    color: var(--fg);
}

/* Pagination */
.page-navigator {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    margin: 40px 0;
    padding: 0;
    list-style: none;
    font-size: 14px;
}

.page-navigator li a,
.page-navigator li span {
    display: inline-block;
    min-width: 36px;
    padding: 6px 10px;
    text-align: center;
    border: 1px solid var(--line);
    border-radius: 999px;
    color: var(--muted);
}

.page-navigator li a:hover,
.page-navigator li.current a {
    color: var(--bg);
    background: var(--fg);
    border-color: var(--fg);
    text-decoration: none;
}

/* Comments */
.comments {
    margin: 24px 0 64px;
    padding-top: 32px;
    border-top: 1px solid var(--line);
}

.comments-title,
.respond-title {
    margin: 0 0 20px;
    font-family: "Noto Serif SC", "Songti SC", Georgia, serif;
    font-size: 20px;
    font-weight: 600;
}

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

.comment-list .comment-list {
    margin-top: 16px;
    padding-left: 20px;
    border-left: 1px solid var(--line);
}

.comment-body {
    padding: 16px 0;
    border-bottom: 1px solid var(--line);
}

.comment-author {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
}

.comment-author img {
    border-radius: 50%;
    filter: grayscale(1);
}

.comment-author cite {
    font-style: normal;
    font-weight: 600;
}

.comment-meta {
    margin: 4px 0 8px;
    font-size: 12px;
    color: var(--muted);
}

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

.comment-reply {
    margin-top: 6px;
    font-size: 13px;
}

.respond {
    margin-top: 40px;
}

.form-row {
    margin: 0 0 14px;
}

.form-row label {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    color: var(--muted);
}

.form-row input,
.form-row textarea {
    width: 100%;
    padding: 10px 12px;
    background: var(--bg);
    color: var(--fg);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    font: inherit;
    font-size: 15px;
}

.form-row input:focus,
.form-row textarea:focus {
    outline: none;
    border-color: var(--fg);
}

.button {
    display: inline-block;
    padding: 9px 22px;
    background: var(--fg);
    color: var(--bg);
    border: 1px solid var(--fg);
    border-radius: 999px;
    font-size: 14px;
    cursor: pointer;
}

.button:hover {
    opacity: 0.82;
    text-decoration: none;
}

.logged-in,
.comments-closed {
    color: var(--muted);
    font-size: 14px;
}

/* 404 */
.error-page {
    padding: 120px 0;
    text-align: center;
}

.error-code {
    margin: 0;
    font-family: "Noto Serif SC", "Songti SC", Georgia, serif;
    font-size: 72px;
    line-height: 1;
    color: var(--line);
}

.error-page h1 {
    margin: 16px 0 8px;
    font-size: 24px;
}

.error-page p {
    color: var(--muted);
}

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

.site-footer p {
    margin: 4px 0;
}

.site-footer a {
    color: var(--fg);
}

/* Theme transition */
html {
    color-scheme: light;
}

[data-theme="dark"] {
    color-scheme: dark;
}

/* Mobile */
@media (max-width: 640px) {
    .header-inner {
        gap: 12px;
        min-height: 56px;
    }

    .brand {
        font-size: 17px;
    }

    .site-nav {
        gap: 14px;
        font-size: 13px;
    }

    .hero {
        padding: 44px 0 32px;
    }

    .hero.has-image {
        padding: 64px 20px;
    }

    .hero-title {
        font-size: 30px;
    }

    .post-card:has(.card-cover) {
        grid-template-columns: 1fr;
    }

    .card-cover {
        order: 0;
        aspect-ratio: 16 / 9;
    }

    .card-title {
        font-size: 19px;
    }

    .post {
        padding-top: 32px;
    }

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

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

    .post-nav {
        flex-direction: column;
    }
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }

    *,
    *::before,
    *::after {
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
    }
}
