:root {
    --bg: #ffffff;
    --surface: #f5f5f3;
    --text: #111111;
    --muted: #737373;
    --faint: #a8a8a8;
    --line: #d8d8d5;
    --strong-line: #111111;
    --code-bg: #f3f3f1;
    --selection-bg: #111111;
    --selection-text: #ffffff;
    --header-bg: rgba(255, 255, 255, 0.88);
}

:root.dark-mode {
    --bg: #121212;
    --surface: #1b1b1b;
    --text: #ededed;
    --muted: #a5a5a5;
    --faint: #737373;
    --line: #353535;
    --strong-line: #ededed;
    --code-bg: #1b1b1b;
    --selection-bg: #ededed;
    --selection-text: #121212;
    --header-bg: rgba(18, 18, 18, 0.88);
}

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

html {
    min-width: 320px;
    scroll-behavior: smooth;
    background: var(--bg);
}

body {
    min-height: 100vh;
    margin: 0;
    color: var(--text);
    background: var(--bg);
    font-family: "Helvetica Neue", Helvetica, Arial, "PingFang SC", "Microsoft YaHei", sans-serif;
    line-height: 1.7;
    transition: color 300ms ease, background-color 300ms ease;
}

button,
a {
    -webkit-tap-highlight-color: transparent;
}

button {
    color: inherit;
    font: inherit;
}

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

::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    border-radius: 999px;
    background: var(--muted);
}

.site-header {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 76px;
    padding: 0 3rem;
    border-bottom: 1px solid transparent;
    background: var(--header-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
}

.site-header.is-scrolled {
    border-bottom-color: var(--line);
}

.site-logo {
    color: var(--text);
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    text-decoration: none;
    transition: opacity 180ms ease;
}

.site-logo:hover {
    opacity: 0.58;
}

.header-meta {
    display: flex;
    align-items: center;
    gap: 1.25rem;
}

.header-label {
    color: var(--muted);
    font-size: 0.66rem;
    font-weight: 600;
    letter-spacing: 0.2em;
}

.theme-toggle {
    position: relative;
    display: grid;
    width: 36px;
    height: 36px;
    padding: 0;
    place-items: center;
    border: 0;
    border-radius: 50%;
    background: transparent;
    cursor: pointer;
    transition: background-color 180ms ease, transform 180ms ease;
}

.theme-toggle:hover {
    background: var(--surface);
    transform: rotate(12deg);
}

.theme-toggle:focus-visible,
.site-logo:focus-visible,
.timeline-item:focus-visible,
.back-button:focus-visible,
.back-link:focus-visible,
.markdown-body a:focus-visible {
    outline: 2px solid var(--text);
    outline-offset: 4px;
}

.theme-toggle__light,
.theme-toggle__dark {
    position: absolute;
    font-size: 1.05rem;
    line-height: 1;
    transition: opacity 200ms ease, transform 300ms ease;
}

.theme-toggle__dark {
    opacity: 0;
    transform: scale(0.5);
}

:root.dark-mode .theme-toggle__light {
    opacity: 0;
    transform: scale(0.5);
}

:root.dark-mode .theme-toggle__dark {
    opacity: 1;
    transform: scale(1);
}

main {
    width: 100%;
}

.view {
    width: min(100% - 3rem, 900px);
    margin: 0 auto;
}

.view--active {
    animation: view-in 520ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

.archive-heading {
    padding: clamp(4.5rem, 10vw, 8rem) 0 clamp(4rem, 8vw, 6.5rem);
    text-align: center;
}

.eyebrow {
    margin: 0 0 1.4rem;
    color: var(--muted);
    font-size: 0.65rem;
    font-weight: 600;
    letter-spacing: 0.28em;
}

.archive-heading h1 {
    margin: 0;
    font-family: Didot, "Bodoni MT", "Times New Roman", "Songti SC", serif;
    font-size: clamp(2.8rem, 8vw, 5.4rem);
    font-weight: 400;
    letter-spacing: 0.08em;
    line-height: 1.08;
}

.archive-intro {
    margin: 1.5rem 0 0;
    color: var(--muted);
    font-family: "Songti SC", SimSun, serif;
    font-size: 0.9rem;
    letter-spacing: 0.18em;
}

.timeline {
    position: relative;
    padding: 0 0 9rem;
}

.timeline::before {
    position: absolute;
    top: 0;
    bottom: 9rem;
    left: 50%;
    width: 1px;
    background: var(--line);
    content: "";
    transform: translateX(-50%);
}

.timeline::after {
    position: absolute;
    bottom: calc(9rem - 4px);
    left: 50%;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--text);
    content: "";
    transform: translateX(-50%);
}

.timeline-item {
    position: relative;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 86px minmax(0, 1fr);
    align-items: center;
    min-height: 148px;
    color: var(--text);
    text-decoration: none;
    animation: timeline-entry 620ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

.timeline-item::before {
    position: absolute;
    top: 50%;
    left: 50%;
    z-index: 1;
    width: 11px;
    height: 11px;
    border: 2px solid var(--bg);
    border-radius: 50%;
    background: var(--text);
    box-shadow: 0 0 0 1px var(--text);
    content: "";
    transform: translate(-50%, -50%);
    transition: width 240ms ease, height 240ms ease, background-color 240ms ease;
}

.timeline-year {
    justify-self: end;
    font-family: Didot, "Bodoni MT", "Times New Roman", serif;
    font-size: clamp(2.9rem, 7vw, 4.8rem);
    font-weight: 400;
    letter-spacing: -0.035em;
    line-height: 1;
    transition: transform 300ms cubic-bezier(0.22, 1, 0.36, 1);
}

.timeline-copy {
    grid-column: 3;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    min-width: 0;
    padding-bottom: 0.65rem;
    border-bottom: 1px solid var(--line);
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 500;
    letter-spacing: 0.16em;
    transition: color 220ms ease, border-color 220ms ease;
}

.timeline-arrow {
    color: var(--text);
    font-size: 1rem;
    letter-spacing: 0;
    transition: transform 220ms ease;
}

.timeline-item:hover .timeline-year {
    transform: translateX(-8px);
}

.timeline-item:hover .timeline-copy {
    color: var(--text);
    border-bottom-color: var(--text);
}

.timeline-item:hover .timeline-arrow {
    transform: translate(4px, -4px);
}

.timeline-item:hover::before {
    width: 17px;
    height: 17px;
    background: var(--bg);
}

.timeline-loading,
.timeline-empty {
    position: relative;
    z-index: 2;
    display: flex;
    min-height: 148px;
    align-items: center;
    justify-content: center;
    gap: 0.8rem;
    color: var(--muted);
    background: var(--bg);
    font-size: 0.75rem;
    letter-spacing: 0.12em;
}

.timeline-loading__line {
    width: 28px;
    height: 1px;
    overflow: hidden;
    background: var(--line);
}

.timeline-loading__line::after {
    display: block;
    width: 100%;
    height: 100%;
    background: var(--text);
    content: "";
    animation: loading-line 1.2s ease-in-out infinite;
}

.article-view {
    max-width: 760px;
    padding: 0 0 8rem;
}

.article-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 120px;
    border-bottom: 1px solid var(--line);
}

.back-button,
.back-link {
    display: inline-flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0;
    border: 0;
    background: transparent;
    cursor: pointer;
    font-size: 0.75rem;
    font-weight: 500;
    letter-spacing: 0.12em;
    transition: opacity 180ms ease;
}

.back-button:hover,
.back-link:hover {
    opacity: 0.55;
}

.article-year {
    font-family: Didot, "Bodoni MT", "Times New Roman", serif;
    font-size: 1.25rem;
}

.article-status {
    padding: 7rem 0;
    color: var(--muted);
    text-align: center;
    font-size: 0.8rem;
    letter-spacing: 0.12em;
}

.article-status:empty {
    display: none;
}

.article-status__error {
    margin-bottom: 1.5rem;
    color: var(--text);
    font-family: Didot, "Bodoni MT", "Times New Roman", serif;
    font-size: 1.75rem;
    letter-spacing: 0.05em;
}

.markdown-body {
    padding-top: clamp(3.5rem, 8vw, 6rem);
    color: var(--text);
    font-family: "Songti SC", SimSun, Georgia, serif;
    font-size: 1.05rem;
    overflow-wrap: break-word;
}

.markdown-body:empty {
    display: none;
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4,
.markdown-body h5,
.markdown-body h6 {
    color: var(--text);
    font-family: Didot, "Bodoni MT", "Times New Roman", "Songti SC", serif;
    font-weight: 500;
    line-height: 1.3;
    scroll-margin-top: 110px;
}

.markdown-body h1 {
    margin: 0 0 3.5rem;
    font-size: clamp(2.5rem, 7vw, 4.6rem);
    font-weight: 400;
    letter-spacing: 0.035em;
}

.markdown-body h2 {
    margin: 4.5rem 0 1.4rem;
    padding-top: 1.1rem;
    border-top: 1px solid var(--strong-line);
    font-size: 1.85rem;
}

.markdown-body h3 {
    margin: 3rem 0 1rem;
    font-size: 1.35rem;
}

.markdown-body h4,
.markdown-body h5,
.markdown-body h6 {
    margin: 2.5rem 0 0.8rem;
    font-size: 1.05rem;
}

.markdown-body p {
    margin: 0 0 1.65rem;
}

.markdown-body a {
    color: inherit;
    text-decoration-color: var(--faint);
    text-decoration-thickness: 1px;
    text-underline-offset: 0.25em;
    transition: text-decoration-color 180ms ease;
}

.markdown-body a:hover {
    text-decoration-color: var(--text);
}

.markdown-body strong {
    font-weight: 700;
}

.markdown-body hr {
    width: 72px;
    height: 3px;
    margin: 4.5rem auto;
    border: 0;
    background: var(--text);
}

.markdown-body blockquote {
    margin: 2.5rem 0;
    padding: 0.15rem 0 0.15rem 1.5rem;
    border-left: 3px solid var(--text);
    color: var(--muted);
    font-size: 1.15rem;
    font-style: italic;
}

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

.markdown-body ul,
.markdown-body ol {
    margin: 0 0 1.8rem;
    padding-left: 1.6rem;
}

.markdown-body li {
    margin: 0.45rem 0;
    padding-left: 0.25rem;
}

.markdown-body li::marker {
    color: var(--muted);
}

.markdown-body .task-list-item {
    list-style: none;
}

.markdown-body input[type="checkbox"] {
    width: 0.9rem;
    height: 0.9rem;
    margin: 0 0.55rem 0 -1.45rem;
    accent-color: var(--text);
}

.markdown-body img,
.markdown-body video {
    display: block;
    max-width: 100%;
    height: auto;
    margin: 2.5rem auto;
}

.markdown-body figure {
    margin: 2.5rem 0;
}

.markdown-body figcaption {
    margin-top: -1.8rem;
    color: var(--muted);
    text-align: center;
    font-size: 0.75rem;
}

.markdown-body code {
    padding: 0.16em 0.38em;
    border-radius: 2px;
    background: var(--code-bg);
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
    font-size: 0.86em;
}

.markdown-body pre {
    position: relative;
    margin: 2.5rem 0;
    padding: 1.4rem 1.5rem;
    overflow-x: auto;
    border: 1px solid var(--line);
    background: var(--code-bg);
    line-height: 1.65;
}

.markdown-body pre code {
    padding: 0;
    border: 0;
    background: transparent;
    color: inherit;
    font-size: 0.83rem;
}

.markdown-body .table-wrap {
    margin: 2.5rem 0;
    overflow-x: auto;
}

.markdown-body table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.92rem;
}

.markdown-body th,
.markdown-body td {
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--line);
    text-align: left;
}

.markdown-body th {
    border-bottom-color: var(--text);
    font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
    font-size: 0.72rem;
    letter-spacing: 0.08em;
}

.markdown-body details {
    margin: 2rem 0;
    padding: 1rem 0;
    border-top: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
}

.markdown-body summary {
    cursor: pointer;
    font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
    font-size: 0.82rem;
    font-weight: 600;
    letter-spacing: 0.08em;
}

.markdown-body kbd {
    padding: 0.15rem 0.4rem;
    border: 1px solid var(--line);
    border-bottom-width: 2px;
    border-radius: 3px;
    background: var(--surface);
    font-family: "SFMono-Regular", Consolas, monospace;
    font-size: 0.78em;
}

.markdown-body mark {
    color: inherit;
    background: var(--line);
}

.hljs-comment,
.hljs-quote {
    color: var(--muted);
    font-style: italic;
}

.hljs-keyword,
.hljs-selector-tag,
.hljs-built_in,
.hljs-name,
.hljs-tag {
    color: var(--text);
    font-weight: 700;
}

.hljs-string,
.hljs-title,
.hljs-section,
.hljs-attribute,
.hljs-literal,
.hljs-template-tag,
.hljs-template-variable,
.hljs-type,
.hljs-addition {
    color: var(--muted);
}

.hljs-number,
.hljs-symbol,
.hljs-bullet,
.hljs-variable,
.hljs-regexp,
.hljs-link {
    color: var(--text);
}

.hljs-meta,
.hljs-deletion {
    color: var(--faint);
}

.article-footer {
    margin-top: 6rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--line);
}

.noscript-message {
    margin: 3rem;
    text-align: center;
}

.flying-berry {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1000;
    width: clamp(74px, 8vw, 112px);
    pointer-events: none;
    user-select: none;
    will-change: transform;
    transition-property: transform;
    transition-timing-function: cubic-bezier(0.45, 0, 0.55, 1);
}

.flying-berry__direction {
    display: block;
    transition: transform 240ms ease;
}

.flying-berry img {
    display: block;
    width: 100%;
    height: auto;
    filter: drop-shadow(0 7px 8px rgba(0, 0, 0, 0.16));
    image-rendering: pixelated;
    animation: berry-flutter 900ms ease-in-out infinite alternate;
}

@keyframes view-in {
    from {
        opacity: 0;
        transform: translateY(14px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes loading-line {
    0% {
        transform: translateX(-105%);
    }
    50%,
    100% {
        transform: translateX(105%);
    }
}

@keyframes timeline-entry {
    from {
        opacity: 0;
        transform: translateY(18px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes berry-flutter {
    from {
        transform: translateY(-5px) rotate(-2deg);
    }
    to {
        transform: translateY(5px) rotate(2deg);
    }
}

@media (max-width: 700px) {
    .site-header {
        min-height: 64px;
        padding: 0 1.25rem;
    }

    .header-label {
        display: none;
    }

    .view {
        width: min(100% - 2.5rem, 900px);
    }

    .archive-heading {
        padding-top: 4.5rem;
    }

    .archive-heading h1 {
        letter-spacing: 0.04em;
    }

    .timeline::before,
    .timeline::after,
    .timeline-item::before {
        left: 38%;
    }

    .timeline-item {
        grid-template-columns: minmax(0, 38%) 42px minmax(0, 1fr);
        min-height: 126px;
    }

    .timeline-year {
        font-size: clamp(2.35rem, 13vw, 3.5rem);
    }

    .timeline-copy {
        font-size: 0.62rem;
        letter-spacing: 0.1em;
    }

    .timeline-arrow {
        display: none;
    }

    .article-nav {
        min-height: 92px;
    }

    .markdown-body {
        font-size: 1rem;
    }

    .markdown-body h1 {
        margin-bottom: 2.75rem;
    }

    .markdown-body h2 {
        margin-top: 3.5rem;
    }

    .markdown-body pre {
        margin-right: -1.25rem;
        margin-left: -1.25rem;
        padding-right: 1.25rem;
        padding-left: 1.25rem;
        border-right: 0;
        border-left: 0;
    }
}

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

    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    .flying-berry img {
        animation: none !important;
    }
}
