:root {
    --paper: #f6f3ec;
    --paper-raised: #fcfbf8;
    --ink: #1f1c18;
    --ink-soft: #5c564c;
    --ink-faint: #7d766c;
    --line: #e4ddd2;
    --line-strong: #d4cdc1;
    --accent: #8d4030;
    --code-bg: #f1ece3;
    --shadow: 0 1px 1px rgba(72, 49, 32, 0.05), 0 12px 28px rgba(72, 49, 32, 0.1);
    --serif: "Iowan Old Style", Palatino, "Palatino Linotype", "Songti SC", "Noto Serif SC", "Source Han Serif SC", "STSong", PMingLiU, serif;
    --sans: "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Source Han Sans SC", "Microsoft YaHei", "Segoe UI", sans-serif;
    --mono: "SFMono-Regular", "Cascadia Code", "Source Code Pro", Menlo, Consolas, monospace;
    --page: 50rem;
    color-scheme: light;
}

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

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    background: var(--paper);
    color: var(--ink);
    font-family: var(--sans);
    font-size: 1.0625rem;
    line-height: 1.75;
    text-rendering: optimizeLegibility;
}

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

a {
    color: var(--accent);
    text-underline-offset: 0.18em;
}

a:hover {
    color: var(--ink);
}

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 3px;
}

:focus:not(:focus-visible) {
    outline: none;
}

.skip-link {
    position: absolute;
    left: 1rem;
    top: -4rem;
    z-index: 20;
    padding: 0.45rem 0.75rem;
    background: var(--ink);
    color: var(--paper);
    text-decoration: none;
}

.skip-link:focus {
    top: 0.75rem;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--paper);
    border-bottom: 1px solid var(--line);
}

.topbar-inner,
.footer-inner,
.page {
    width: min(calc(100% - 2.5rem), var(--page));
    margin-inline: auto;
}

.topbar-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    min-height: 4.25rem;
    flex-wrap: wrap;
}

.brand {
    font-family: var(--serif);
    font-size: 1.45rem;
    color: var(--ink);
    text-decoration: none;
    letter-spacing: 0.01em;
}

.nav-list {
    display: flex;
    gap: 1.15rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

.nav-list a {
    color: var(--ink-soft);
    text-decoration: none;
}

.nav-list a[aria-current="page"],
.nav-list a:hover {
    color: var(--ink);
}

.nav-toggle {
    display: none;
}

.page {
    padding: 3.25rem 0 4.5rem;
}

.intro {
    display: grid;
    grid-template-columns: minmax(0, 12.75rem) minmax(0, 1fr);
    gap: 1.35rem 1.85rem;
    align-items: start;
}

.intro-photo,
.intro-copy,
.portrait {
    min-width: 0;
    max-width: 100%;
}

.portrait {
    width: min(12.75rem, 100%);
    margin: 0;
    padding: 0.55rem;
    background: var(--paper-raised);
    border: 1px solid rgba(72, 49, 32, 0.14);
    border-radius: 1.35rem;
    box-shadow: var(--shadow);
}

.portrait img {
    display: block;
    width: 100%;
    max-width: 100%;
    height: auto;
    border-radius: 0.9rem;
}

.intro-copy {
    overflow-wrap: break-word;
}

.eyebrow {
    margin: 0 0 0.35rem;
    color: var(--ink-soft);
    font-size: 0.92rem;
}

h1,
.article-title,
.note-title {
    font-family: var(--serif);
    font-weight: 600;
    letter-spacing: -0.02em;
    line-height: 1.22;
}

.intro h1 {
    margin: 0;
    font-size: clamp(2.6rem, 7vw, 4.25rem);
}

.page-head h1 {
    margin: 0;
    font-size: clamp(2rem, 5vw, 2.75rem);
}

.quote {
    margin: 0.85rem 0 1rem;
    color: var(--ink-soft);
    font-family: var(--serif);
    font-size: 1.15rem;
    line-height: 1.55;
}

.intro p,
.page-head p {
    margin: 0.7rem 0;
}

.inline-links {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem 1rem;
    margin: 1.15rem 0 0;
    padding: 0;
    list-style: none;
}

.manage-edit {
    margin: 0.85rem 0 0;
    font-size: 0.92rem;
}

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

.manage-edit a + a {
    margin-left: 1rem;
}

.notes-section,
.links-section,
.tag-group {
    margin-top: 3.25rem;
}

h2 {
    margin: 2.2rem 0 0.75rem;
    font-family: var(--serif);
    font-size: 1.55rem;
    font-weight: 600;
    line-height: 1.3;
}

.notes {
    margin: 0.4rem 0 0;
    padding: 0;
    list-style: none;
}

.note a {
    display: grid;
    grid-template-columns: 6.4rem minmax(0, 1fr);
    column-gap: 1rem;
    row-gap: 0.15rem;
    padding: 1.05rem 0;
    border-top: 1px solid var(--line);
    color: inherit;
    text-decoration: none;
}

.notes .note:last-child a {
    border-bottom: 1px solid var(--line);
}

.note time,
.note-sub,
.note-tags,
.meta,
.dek,
.kicker {
    color: var(--ink-soft);
}

.note time {
    padding-top: 0.35rem;
    font-variant-numeric: tabular-nums;
    font-size: 0.95rem;
}

.note-title {
    font-size: 1.35rem;
}

.note-sub,
.note-tags {
    grid-column: 2;
}

.note-tags {
    color: var(--ink-faint);
    font-size: 0.92rem;
}

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

.page-head .dek,
.article-head .dek {
    font-size: 1.12rem;
}

.back {
    margin: 0 0 1.25rem;
}

.kicker {
    margin: 0;
    font-size: 0.95rem;
}

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

.article-title {
    margin: 0.35rem 0 0.5rem;
    font-size: clamp(2rem, 5vw, 2.8rem);
}

.meta {
    margin: 0.8rem 0 0;
    font-size: 0.95rem;
}

.toc {
    margin: 1.6rem 0 0.4rem;
    padding: 0.85rem 1rem;
    border: 1px solid var(--line);
    border-radius: 0.9rem;
    background: var(--paper-raised);
}

.toc summary {
    cursor: pointer;
    color: var(--ink-soft);
}

.toc nav {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    margin-top: 0.7rem;
}

.toc a {
    color: var(--ink-soft);
    text-decoration: none;
}

.toc a.toc-sub {
    padding-left: 0.9rem;
}

.prose {
    font-size: 1.05rem;
}

.prose h2,
.prose h3,
.prose h4 {
    scroll-margin-top: 5.5rem;
}

.prose h3 {
    margin: 1.6rem 0 0.45rem;
    font-size: 1.2rem;
}

.prose p,
.prose ul,
.prose ol {
    margin: 0.85rem 0;
}

.page blockquote {
    margin: 1.4rem 0;
    padding: 0.1rem 0 0.1rem 1rem;
    border-left: 2px solid var(--accent);
    color: var(--ink-soft);
}

.page blockquote p {
    margin: 0.35rem 0;
}

.prose code {
    font-family: var(--mono);
    font-size: 0.9em;
    background: var(--code-bg);
    padding: 0.08em 0.35em;
    border-radius: 0.3em;
}

.prose pre,
.highlight pre {
    overflow-x: auto;
    margin: 1.2rem 0;
    padding: 0.95rem 1rem;
    background: var(--code-bg);
    border: 1px solid var(--line);
    border-radius: 0.85rem;
    line-height: 1.6;
}

.prose pre code,
.highlight pre code {
    background: transparent;
    padding: 0;
    white-space: pre;
}

.highlight .c,
.highlight .c1,
.highlight .cm,
.highlight .cs {
    color: #7d766c;
    font-style: italic;
}

.highlight .k,
.highlight .kd,
.highlight .kn,
.highlight .kr,
.highlight .ow {
    color: #8d4030;
}

.highlight .s,
.highlight .s1,
.highlight .s2,
.highlight .sb,
.highlight .sc {
    color: #2f6a48;
}

.highlight .nf,
.highlight .nc,
.highlight .nb {
    color: #3d4f73;
}

.highlight .mi,
.highlight .m,
.highlight .mf {
    color: #80531f;
}

.table-scroll {
    overflow-x: auto;
    margin: 1.2rem 0;
    border: 1px solid var(--line);
    border-radius: 0.85rem;
}

.prose table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
}

.prose th,
.prose td {
    padding: 0.45rem 0.7rem;
    border-bottom: 1px solid var(--line);
    text-align: left;
    white-space: nowrap;
}

.prose .task-list {
    list-style: none;
    padding-left: 0;
}

.prose .task-list-item input {
    width: 1rem;
    height: 1rem;
    margin-right: 0.4rem;
    accent-color: var(--accent);
}

.facts {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem 1.5rem;
    margin: 0.4rem 0 0;
}

.facts div {
    padding-top: 0.75rem;
    border-top: 1px solid var(--line);
}

.facts dt {
    color: var(--ink-soft);
    font-size: 0.92rem;
}

.facts dd {
    margin: 0.15rem 0 0;
}

.pager {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-top: 2rem;
}

.pager a {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    color: inherit;
    text-decoration: none;
}

.pager a[rel="next"] {
    text-align: right;
}

.pager span {
    color: var(--ink-faint);
    font-size: 0.88rem;
}

.button,
.nav-toggle,
.lang-switch button {
    font: inherit;
    color: var(--ink);
    background: transparent;
    border: 1px solid var(--line-strong);
    border-radius: 999px;
    min-height: 2.75rem;
    padding: 0.4rem 0.95rem;
    cursor: pointer;
    text-decoration: none;
}

.button {
    display: inline-flex;
    align-items: center;
    background: var(--ink);
    color: var(--paper);
    border-color: var(--ink);
}

.button:hover {
    color: var(--paper);
}

.lang-switch {
    display: flex;
    gap: 0.5rem;
    margin: 1.6rem 0 0.4rem;
}

.lang-switch button[aria-pressed="true"] {
    border-color: var(--ink);
}

.tag-index {
    margin-bottom: 0.5rem;
}

.tag-index span {
    color: var(--ink-faint);
}

.embed iframe {
    width: 100%;
    height: min(70vh, 36rem);
    border: 1px solid var(--line);
    border-radius: 0.9rem;
    background: var(--paper-raised);
}

.comments {
    margin-top: 3rem;
    max-width: 100%;
}

.comments-note {
    color: var(--ink-soft);
}

.giscus {
    max-width: 100%;
}

.giscus-frame {
    width: 100%;
    max-width: 100%;
    border: 0;
    color-scheme: light;
}

.site-footer {
    border-top: 1px solid var(--line);
    padding: 1.4rem 0 2rem;
    color: var(--ink-soft);
    font-size: 0.92rem;
}

.site-footer p {
    margin: 0.2rem 0;
}

.empty {
    color: var(--ink-soft);
}

@media (max-width: 720px) {
    .topbar-inner,
    .footer-inner,
    .page {
        width: min(calc(100% - 2rem), var(--page));
    }

    .page {
        padding-top: 1.75rem;
    }

    .nav-toggle {
        display: inline-flex;
        align-items: center;
    }

    #site-nav {
        display: none;
        flex-basis: 100%;
        padding-bottom: 0.85rem;
    }

    #site-nav.is-open {
        display: block;
    }

    .nav-list {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.2rem;
    }

    .nav-list a {
        display: inline-flex;
        align-items: center;
        min-height: 2.75rem;
    }

    .intro {
        grid-template-columns: 1fr;
        justify-items: start;
        gap: 1.1rem;
    }

    .portrait {
        width: 10.75rem;
    }

    .note a,
    .note-sub,
    .note-tags {
        grid-column: 1;
    }

    .note a {
        grid-template-columns: 1fr;
    }

    .facts,
    .pager {
        grid-template-columns: 1fr;
    }

    .pager a[rel="next"] {
        text-align: left;
    }
}

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

    *,
    *::before,
    *::after {
        animation: none !important;
        transition: none !important;
    }
}

@media print {
    .topbar,
    .site-footer,
    .skip-link,
    .toc,
    .pager,
    .comments {
        display: none;
    }

    body {
        background: #fff;
    }
}
