:root {
    --paper: #f6f3ec;
    --paper-raised: #fbf9f4;
    --ink: #24211c;
    --ink-soft: #5f5a51;
    --muted: #8b8377;
    --rule: #ddd6c9;
    --rule-strong: #c7bdad;
    --accent: #984128;
    --accent-dark: #74301e;
    --danger: #9b3226;
    --serif: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", "Noto Serif SC",
        "Source Han Serif SC", "Songti SC", SimSun, Georgia, serif;
    --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
        "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    --mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
    --shell: 1040px;
    --reading: 710px;
}

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

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

body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--paper);
    color: var(--ink);
    font-family: var(--sans);
    font-size: 16px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

::selection {
    background: #e8cdbf;
    color: var(--ink);
}

a {
    color: inherit;
}

button,
input,
textarea {
    font: inherit;
}

button {
    color: inherit;
}

img {
    max-width: 100%;
}

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

.shell {
    width: min(calc(100% - 48px), var(--shell));
    margin-inline: auto;
}

.skip-link {
    position: absolute;
    left: 16px;
    top: -60px;
    z-index: 10;
    padding: 10px 16px;
    background: var(--ink);
    color: var(--paper);
    text-decoration: none;
}

.skip-link:focus {
    top: 16px;
}

/* Header and footer */

.site-header {
    border-bottom: 1px solid var(--rule);
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    padding-block: 26px;
}

.brand {
    font-family: var(--serif);
    font-size: 1.35rem;
    font-weight: 600;
    letter-spacing: -0.025em;
    text-decoration: none;
}

.brand-mark {
    color: var(--accent);
}

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

.site-nav a {
    position: relative;
    color: var(--ink-soft);
    font-size: 0.86rem;
    letter-spacing: 0.06em;
    text-decoration: none;
    transition: color 160ms ease;
}

.site-nav a::after {
    content: "";
    position: absolute;
    left: 0;
    right: 100%;
    bottom: -5px;
    height: 1px;
    background: var(--accent);
    transition: right 180ms ease;
}

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

.site-nav a:hover::after {
    right: 0;
}

.site-main {
    flex: 1;
    padding-block: 72px 104px;
}

.site-footer {
    border-top: 1px solid var(--rule);
    color: var(--muted);
    font-size: 0.78rem;
    letter-spacing: 0.03em;
}

.footer-inner {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 16px;
    padding-block: 28px;
}

.footer-copy {
    justify-self: start;
}

.footer-icp {
    justify-self: center;
    color: var(--muted);
    text-decoration: none;
    text-underline-offset: 4px;
    transition: color 160ms ease;
}

.footer-icp:hover {
    color: var(--accent);
    text-decoration: underline;
}

.footer-author {
    justify-self: end;
}

/* Shared type */

.eyebrow {
    margin: 0 0 18px;
    color: var(--accent);
    font-size: 0.68rem;
    font-weight: 600;
    line-height: 1;
    letter-spacing: 0.2em;
    text-transform: uppercase;
}

.page-subtitle {
    max-width: 36em;
    margin: 14px 0 0;
    color: var(--ink-soft);
}

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--muted);
    font-size: 0.82rem;
    text-decoration: none;
    transition: color 160ms ease;
}

.back-link:hover {
    color: var(--accent);
}

.text-link {
    border: 0;
    padding: 0;
    background: none;
    color: var(--ink-soft);
    font-size: 0.82rem;
    text-decoration: none;
    text-underline-offset: 4px;
    cursor: pointer;
    transition: color 160ms ease;
}

.text-link:hover {
    color: var(--accent);
    text-decoration: underline;
}

.text-link.danger {
    color: var(--danger);
}

.text-link.danger:hover {
    color: #7f241b;
}

/* Buttons */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    min-height: 44px;
    padding: 10px 20px;
    border: 1px solid transparent;
    border-radius: 2px;
    font-size: 0.86rem;
    font-weight: 500;
    letter-spacing: 0.02em;
    line-height: 1.2;
    text-decoration: none;
    cursor: pointer;
    transition: background-color 160ms ease, border-color 160ms ease, color 160ms ease;
}

.btn-primary {
    background: var(--ink);
    color: var(--paper-raised);
}

.btn-primary:hover {
    background: var(--accent);
}

.btn-ghost {
    border-color: var(--rule-strong);
    background: transparent;
    color: var(--ink-soft);
}

.btn-ghost:hover {
    border-color: var(--ink-soft);
    color: var(--ink);
}

/* Home */

.home-hero {
    max-width: 780px;
    margin-bottom: 86px;
}

.home-hero h1 {
    margin: 0;
    font-family: var(--serif);
    font-size: clamp(3.15rem, 8vw, 5.7rem);
    font-weight: 500;
    line-height: 0.98;
    letter-spacing: -0.055em;
}

.home-intro {
    max-width: 30em;
    margin: 28px 0 0;
    color: var(--ink-soft);
    font-family: var(--serif);
    font-size: clamp(1.08rem, 2vw, 1.28rem);
    line-height: 1.8;
}

.section-heading {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 24px;
    padding-bottom: 18px;
    border-bottom: 1px solid var(--rule-strong);
}

.section-heading h2 {
    margin: 0;
    font-family: var(--serif);
    font-size: 1.02rem;
    font-weight: 600;
    letter-spacing: 0.08em;
}

.section-count {
    color: var(--muted);
    font-size: 0.76rem;
    letter-spacing: 0.08em;
}

.post-card {
    display: grid;
    grid-template-columns: 152px minmax(0, 1fr);
    gap: 34px;
    padding: 38px 0 40px;
    border-bottom: 1px solid var(--rule);
}

.post-date {
    padding-top: 10px;
    color: var(--muted);
    font-size: 0.76rem;
    line-height: 1.5;
    letter-spacing: 0.025em;
}

.post-card h3 {
    margin: 0 0 12px;
    font-family: var(--serif);
    font-size: clamp(1.55rem, 3.4vw, 2.15rem);
    font-weight: 500;
    line-height: 1.28;
    letter-spacing: -0.02em;
}

.post-card h3 a {
    text-decoration: none;
    transition: color 160ms ease;
}

.post-card h3 a:hover {
    color: var(--accent);
}

.post-excerpt {
    max-width: 40em;
    margin: 0 0 18px;
    color: var(--ink-soft);
    font-size: 0.94rem;
    line-height: 1.8;
}

.read-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--ink);
    font-size: 0.8rem;
    font-weight: 500;
    letter-spacing: 0.03em;
    text-decoration: none;
}

.read-link span {
    color: var(--accent);
    transition: transform 160ms ease;
}

.read-link:hover span {
    transform: translateX(4px);
}

.empty-state {
    margin-top: 1px;
    padding: 72px 0 56px;
    border-bottom: 1px solid var(--rule);
}

.empty-state .eyebrow {
    margin-bottom: 20px;
}

.empty-state h2 {
    margin: 0 0 12px;
    font-family: var(--serif);
    font-size: clamp(1.8rem, 4vw, 2.5rem);
    font-weight: 500;
    letter-spacing: -0.025em;
}

.empty-state p:not(.eyebrow) {
    margin: 0 0 26px;
    color: var(--ink-soft);
}

.empty-state-compact {
    padding-top: 48px;
}

/* Article */

.article {
    max-width: var(--reading);
    margin-inline: auto;
}

.article-header {
    margin: 38px 0 48px;
    padding-bottom: 34px;
    border-bottom: 1px solid var(--rule-strong);
}

.article-header h1 {
    margin: 0;
    font-family: var(--serif);
    font-size: clamp(2.5rem, 6vw, 4rem);
    font-weight: 500;
    line-height: 1.15;
    letter-spacing: -0.04em;
    overflow-wrap: break-word;
}

.article-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 9px;
    margin-top: 24px;
    color: var(--muted);
    font-size: 0.78rem;
    letter-spacing: 0.02em;
}

.meta-divider {
    color: var(--rule-strong);
}

.prose {
    color: #2c2923;
    font-family: var(--serif);
    font-size: clamp(1.04rem, 1.8vw, 1.13rem);
    line-height: 1.95;
    overflow-wrap: break-word;
}

.prose > :first-child {
    margin-top: 0;
}

.prose > :last-child {
    margin-bottom: 0;
}

.prose p {
    margin: 0 0 1.5em;
}

.prose h2,
.prose h3,
.prose h4 {
    margin: 2.1em 0 0.75em;
    color: var(--ink);
    font-family: var(--serif);
    font-weight: 600;
    line-height: 1.35;
    letter-spacing: -0.02em;
}

.prose h2 {
    font-size: 1.65em;
}

.prose h3 {
    font-size: 1.3em;
}

.prose h4 {
    font-size: 1.1em;
}

.prose a {
    color: var(--accent);
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 4px;
}

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

.prose strong {
    font-weight: 650;
}

.prose ul,
.prose ol {
    margin: 0 0 1.5em;
    padding-left: 1.5em;
}

.prose li {
    margin: 0.35em 0;
    padding-left: 0.25em;
}

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

.prose blockquote {
    margin: 1.8em 0;
    padding: 0.2em 0 0.2em 1.35em;
    border-left: 2px solid var(--accent);
    color: var(--ink-soft);
    font-style: italic;
}

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

.prose code {
    padding: 0.15em 0.38em;
    border-radius: 2px;
    background: #eae4d8;
    font-family: var(--mono);
    font-size: 0.82em;
}

.prose pre {
    margin: 1.8em 0;
    padding: 22px 24px;
    overflow-x: auto;
    border: 1px solid var(--rule);
    background: #eee8dc;
    font-size: 0.85rem;
    line-height: 1.65;
}

.prose pre code {
    padding: 0;
    background: transparent;
    font-size: inherit;
}

.prose hr {
    margin: 2.5em 0;
    border: 0;
    border-top: 1px solid var(--rule);
}

.prose img {
    height: auto;
    margin: 1.8em 0;
}

.prose table {
    width: 100%;
    margin: 1.8em 0;
    border-collapse: collapse;
    font-family: var(--sans);
    font-size: 0.9rem;
}

.prose th,
.prose td {
    padding: 10px 12px;
    border: 1px solid var(--rule);
    text-align: left;
}

.prose th {
    background: #ece6da;
}

.article-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    margin-top: 64px;
    padding-top: 24px;
    border-top: 1px solid var(--rule);
}

/* Admin */

.page-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 32px;
    padding-bottom: 30px;
    border-bottom: 1px solid var(--rule-strong);
}

.page-head h1,
.editor-head h1 {
    margin: 0;
    font-family: var(--serif);
    font-size: clamp(2.3rem, 5vw, 3.2rem);
    font-weight: 500;
    line-height: 1.12;
    letter-spacing: -0.035em;
}

.page-head-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
}

.page-head-actions form {
    display: inline-flex;
    margin: 0;
}

.admin-list {
    border-bottom: 1px solid var(--rule);
}

.admin-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 36px;
    padding: 28px 0;
    border-bottom: 1px solid var(--rule);
}

.admin-row:last-child {
    border-bottom: 0;
}

.admin-meta {
    margin: 0 0 8px;
    color: var(--muted);
    font-size: 0.72rem;
    letter-spacing: 0.02em;
}

.admin-info h2 {
    margin: 0 0 6px;
    font-family: var(--serif);
    font-size: 1.42rem;
    font-weight: 500;
    line-height: 1.35;
    letter-spacing: -0.015em;
}

.admin-info h2 a {
    text-decoration: none;
}

.admin-info h2 a:hover {
    color: var(--accent);
}

.admin-excerpt {
    max-width: 46em;
    margin: 0;
    overflow: hidden;
    color: var(--ink-soft);
    font-size: 0.86rem;
    line-height: 1.7;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.admin-actions {
    display: flex;
    align-items: center;
    gap: 18px;
}

.admin-actions form {
    display: inline-flex;
    margin: 0;
}

.flash {
    margin-bottom: 36px;
    padding: 14px 18px;
    border-left: 2px solid var(--accent);
    background: #efe8dc;
    color: var(--ink-soft);
    font-size: 0.9rem;
}

/* Editor */

.editor-page {
    max-width: 780px;
    margin-inline: auto;
}

.editor-head {
    margin: 32px 0 38px;
    padding-bottom: 30px;
    border-bottom: 1px solid var(--rule-strong);
}

.editor-form {
    display: grid;
    gap: 30px;
}

.field {
    display: grid;
    gap: 9px;
}

.field label {
    font-size: 0.82rem;
    font-weight: 600;
    letter-spacing: 0.03em;
}

.label-note {
    margin-left: 6px;
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 400;
    letter-spacing: 0;
}

.text-input {
    width: 100%;
    border: 1px solid var(--rule-strong);
    border-radius: 2px;
    background: var(--paper-raised);
    color: var(--ink);
    transition: border-color 160ms ease, box-shadow 160ms ease;
}

.text-input:hover {
    border-color: #aaa08f;
}

.text-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(152, 65, 40, 0.1);
}

.text-input::placeholder {
    color: #aaa293;
}

.title-input {
    padding: 15px 16px;
    font-family: var(--serif);
    font-size: clamp(1.35rem, 3vw, 1.8rem);
    line-height: 1.35;
}

.summary-input {
    padding: 12px 16px;
    font-size: 0.94rem;
    line-height: 1.7;
    resize: vertical;
}

.content-input {
    min-height: 430px;
    padding: 18px 18px;
    font-family: var(--serif);
    font-size: 1.02rem;
    line-height: 1.85;
    resize: vertical;
}

.field-hint {
    margin: -1px 0 0;
    color: var(--muted);
    font-size: 0.76rem;
}

.field-error {
    color: var(--danger);
    font-size: 0.78rem;
}

.field-error:empty {
    display: none;
}

.validation-summary {
    color: var(--danger);
    font-size: 0.84rem;
}

.validation-summary:empty,
.validation-summary ul:empty {
    display: none;
}

.validation-summary ul {
    margin: 0;
    padding-left: 1.2em;
}

.form-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-top: 8px;
}

/* Authentication */

.auth-page {
    max-width: 460px;
    margin-inline: auto;
    padding-block: 20px 30px;
}

.auth-head {
    margin: 34px 0 32px;
    padding-bottom: 28px;
    border-bottom: 1px solid var(--rule-strong);
}

.auth-head h1 {
    margin: 0;
    font-family: var(--serif);
    font-size: clamp(2.3rem, 6vw, 3.1rem);
    font-weight: 500;
    line-height: 1.12;
    letter-spacing: -0.035em;
}

.auth-head p:not(.eyebrow) {
    margin: 14px 0 0;
    color: var(--ink-soft);
    line-height: 1.75;
}

.auth-form {
    display: grid;
    gap: 22px;
}

.auth-note {
    margin: 30px 0 0;
    padding-top: 20px;
    border-top: 1px dashed var(--rule);
    color: var(--muted);
    font-size: 0.76rem;
    line-height: 1.75;
}

.auth-note code {
    padding: 0.1em 0.3em;
    background: #eae4d8;
    font-family: var(--mono);
    font-size: 0.95em;
}

/* Error */

.error-page {
    max-width: 620px;
    padding-block: 40px 20px;
}

.error-page h1 {
    margin: 0 0 18px;
    font-family: var(--serif);
    font-size: clamp(2.6rem, 6vw, 4.2rem);
    font-weight: 500;
    line-height: 1.1;
    letter-spacing: -0.04em;
}

.error-page > p:not(.eyebrow):not(.request-id) {
    margin: 0 0 30px;
    color: var(--ink-soft);
    font-size: 1.02rem;
}

.request-id {
    margin-top: 36px;
    color: var(--muted);
    font-size: 0.72rem;
    overflow-wrap: anywhere;
}

.request-id code {
    font-family: var(--mono);
}

/* Responsive */

@media (max-width: 720px) {
    .shell {
        width: min(calc(100% - 36px), var(--shell));
    }

    .site-main {
        padding-block: 48px 72px;
    }

    .header-inner {
        padding-block: 20px;
    }

    .site-nav {
        gap: 20px;
    }

    .home-hero {
        margin-bottom: 60px;
    }

    .post-card {
        grid-template-columns: 1fr;
        gap: 12px;
        padding: 30px 0 32px;
    }

    .post-date {
        padding-top: 0;
    }

    .page-head {
        align-items: flex-start;
        flex-direction: column;
        gap: 22px;
    }

    .page-head-actions {
        width: 100%;
    }

    .admin-row {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .admin-actions {
        gap: 22px;
    }

    .admin-excerpt {
        white-space: normal;
    }

    .article-header {
        margin-top: 30px;
    }

    .article-footer {
        align-items: flex-start;
        flex-direction: column;
        gap: 16px;
    }

    .content-input {
        min-height: 360px;
    }

    .footer-inner {
        grid-template-columns: 1fr;
        justify-items: center;
        gap: 8px;
        text-align: center;
    }

    .footer-copy,
    .footer-author,
    .footer-icp {
        justify-self: center;
    }
}

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

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