/* ==========================================================================
   Ink — a quiet typographic Ghost theme, set in the system font
   ========================================================================== */

/* Tokens ----------------------------------------------------------------- */

:root {
    /* Type families */
    --font-system: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-serif: ui-serif, "New York", Georgia, "Times New Roman", serif;
    --font-body: var(--gh-font-body, var(--font-system));
    --font-heading: var(--gh-font-heading, var(--font-serif));
    --font-ui: var(--font-system);
    --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

    /* Type sizes. UI sizes are rem; titles are em of the body size. */
    --size-base: clamp(1.0625rem, 0.98rem + 0.4vw, 1.1875rem);
    --size-label: 0.7rem;    /* caps metadata: dates, counts, meta, footer */
    --size-ui: 0.8rem;       /* caps navigation: site title, nav, section titles */
    --size-ui-text: 0.85rem; /* sentence-case UI text: snippet dates, tags, forms */
    --size-caption: 0.75rem;
    --title-sm: 1em;         /* compact list rows */
    --title-md: 1.15em;      /* entry titles: post list, snippets, reading now */
    --title-lg: 1.6em;       /* page-level: archive title, reading now (large) */
    --title-xl: clamp(1.6em, 1.3em + 1.5vw, 2em); /* article title */

    --leading: 1.55;
    --leading-tight: 1.25;
    --leading-list: 1.3;

    /* Spacing scale */
    --space-1: 0.5rem;
    --space-2: 1rem;
    --space-3: 1.5rem;
    --space-4: 2.5rem;
    --space-5: 3.5rem;

    /* Layout */
    --measure: 36rem;
    --gutter: clamp(1.25rem, 5vw, 3rem);
    --date-column: 7.5rem;

    /* Shape and motion */
    --radius-sm: 2px; /* book covers, thumbnails */
    --radius: 4px;    /* images, code */
    --radius-lg: 6px; /* controls */
    --transition: 0.15s ease;
    --lightbox-bg: rgb(22 16 10 / 0.95); /* warm near-black in both schemes */

    /* Warm paper palette (from the eink mockup). Accent is fixed rather than
       taken from Ghost's accent setting so it can shift for dark mode.
       Text roles: --color-muted for navigation and secondary text,
       --color-faint for metadata (dates, counts, separators). */
    --accent: #a0522d;
    --accent-soft: #e8ddd4;
    --color-bg: #f5f0e8;
    --color-text: #2a2520;
    --color-muted: #5c5650;
    --color-faint: #8c8880;
    --color-rule: #d4cfc6;
    --color-panel: #ede8df;
    --color-mark: #f0dcb4;

    color-scheme: light dark;
}

/* Dark — warm backlight. Follows system on "Auto", forced on "Dark" */
@media (prefers-color-scheme: dark) {
    html.scheme-auto {
        --accent: #d4762a;
        --accent-soft: #3d2810;
        --color-bg: #1a1208;
        --color-text: #e8d4a0;
        --color-muted: #b8a878;
        --color-faint: #7a6e50;
        --color-rule: #332918;
        --color-panel: #221a0c;
        --color-mark: #5a4010;
    }
}
html.scheme-dark {
    --accent: #d4762a;
    --accent-soft: #3d2810;
    --color-bg: #1a1208;
    --color-text: #e8d4a0;
    --color-muted: #b8a878;
    --color-faint: #7a6e50;
    --color-rule: #332918;
    --color-panel: #221a0c;
    --color-mark: #5a4010;
    color-scheme: dark;
}
html.scheme-light { color-scheme: light; }

/* Reset ------------------------------------------------------------------ */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body, h1, h2, h3, h4, h5, h6, p, figure, blockquote, ul, ol, dl, dd { margin: 0; }
img, video, svg, iframe { display: block; max-width: 100%; height: auto; }
button, input { font: inherit; color: inherit; }

/* Base ------------------------------------------------------------------- */

body {
    background: var(--color-bg);
    color: var(--color-text);
    font-family: var(--font-body);
    font-size: var(--size-base);
    line-height: var(--leading);
    font-kerning: normal;
    font-variant-numeric: oldstyle-nums proportional-nums;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    padding: 0 var(--gutter);
}

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

::selection { background: color-mix(in srgb, var(--accent) 22%, transparent); }

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

.sr-only {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.skip-link {
    position: absolute; left: 1rem; top: -3rem; z-index: 10;
    padding: 0.5rem 0.75rem; background: var(--accent); color: var(--color-bg);
    font-family: var(--font-ui); font-size: var(--size-ui);
}
.skip-link:focus { top: 1rem; }

/* Caps label — the one UI label style. Size defaults to --size-label;
   navigation-level labels step up to --size-ui below. */
.label,
.site-title,
.nav a,
.section-title,
.pagination,
.site-footer,
.post-item-date,
.article-meta,
.reading-now-label,
.reading-now-meta,
.follow-also,
.shelf-bar,
.book-year,
.bookshelf .book-date {
    font-family: var(--font-ui);
    font-size: var(--size-label);
    font-weight: 500;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    font-variant-numeric: lining-nums tabular-nums;
}
.site-title,
.nav a,
.section-title,
.pagination { font-size: var(--size-ui); }


/* Serif titles share family, weight and leading; sizes come from the --title-* scale */
.post-item-title,
.snippet-title,
.reading-now-title,
.post-nav-title,
.follow-text {
    font-family: var(--font-heading);
    font-weight: 500;
    line-height: var(--leading-tight);
}

/* Header ----------------------------------------------------------------- */

.site-header {
    max-width: var(--measure);
    margin: 0 auto;
    padding: 2rem 0 0;
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-areas: "title actions" "nav nav";
    row-gap: 0.25rem;
    align-items: center;
}

.site-title {
    grid-area: title;
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    font-weight: 600;
    justify-self: start;
}
.site-icon {
    width: 1.25rem;
    height: 1.25rem;
    border-radius: var(--radius-sm);
    /* Hang the icon so the title text aligns with the column */
    margin-left: calc(-1.25rem - 0.6rem);
}

.site-nav { grid-area: nav; }

.nav {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem 1.25rem;
    padding: 0;
    list-style: none;
}
.nav a { color: var(--color-muted); transition: color var(--transition); }
.nav a:hover,
.nav .nav-current a { color: var(--accent); }

.site-actions { grid-area: actions; align-items: center; gap: 0.9rem; }
.site-actions a,
.scheme-toggle {
    display: inline-flex;
    color: var(--color-text);
    transition: color var(--transition);
}
.site-actions a:hover,
.scheme-toggle:hover { color: var(--accent); }

/* Light/dark toggle — moon in light mode, sun in dark mode */
.scheme-toggle { padding: 0; border: 0; background: none; cursor: pointer; }
.scheme-toggle .icon-sun,
html.scheme-dark .scheme-toggle .icon-moon { display: none; }
html.scheme-dark .scheme-toggle .icon-sun { display: block; }
@media (prefers-color-scheme: dark) {
    html.scheme-auto .scheme-toggle .icon-moon { display: none; }
    html.scheme-auto .scheme-toggle .icon-sun { display: block; }
}

/* Main ------------------------------------------------------------------- */

.site-main {
    max-width: var(--measure);
    margin: 0 auto;
    padding: clamp(3rem, 8vw, 5rem) 0 4rem;
}

/* Home sections ---------------------------------------------------------- */

.home-section + .home-section { margin-top: var(--space-5); }

.section-title {
    margin-bottom: var(--space-2);
    color: var(--color-muted);
}
.section-title a { transition: color var(--transition); }
.section-title span { display: inline-block; transition: transform var(--transition); }
.section-title a:hover { color: var(--accent); }
.section-title a:hover span { transform: translateX(3px); }

/* Post lists ------------------------------------------------------------- */

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

.post-item { position: relative; }
.post-item + .post-item { margin-top: var(--space-3); }

/* Date in a fixed left column, title and excerpt to the right */
.post-item-link {
    display: grid;
    grid-template-columns: var(--date-column) 1fr;
    column-gap: var(--space-2);
    align-items: baseline;
}
.post-item-date { color: var(--color-faint); white-space: nowrap; }
.post-item-title {
    display: block;
    font-size: var(--title-md);
    transition: color var(--transition);
}
.post-item-link:hover .post-item-title { color: var(--accent); }
.post-item-excerpt {
    display: block;
    margin-top: 0.3rem;
    color: var(--color-muted);
    font-size: 0.88em;
    line-height: 1.5;
}

/* Featured marker hangs in the left margin */
.post-item.is-featured .post-item-title::before {
    content: "*";
    position: absolute;
    left: -1rem;
    color: var(--accent);
    font-family: var(--font-ui);
}

/* Compact lists (home Blog and Snippets sections, /blog/): long titles wrap, so rows get room */
.post-list.is-compact .post-item + .post-item { margin-top: var(--space-2); }
.post-list.is-compact .post-item-title {
    font-size: var(--title-sm);
    line-height: var(--leading-list);
    text-wrap: pretty;
}

/* Archive headers (tag, author) ----------------------------------------- */

.archive-header { margin-bottom: var(--space-4); }
.archive-header .label { color: var(--color-faint); margin-bottom: var(--space-1); }
.archive-title {
    font-family: var(--font-heading);
    font-size: var(--title-lg);
    font-weight: 600;
    line-height: var(--leading-tight);
}
.archive-description { margin-top: 0.75rem; color: var(--color-muted); }

/* Pagination ------------------------------------------------------------- */

.pagination {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-top: var(--space-4);
    color: var(--color-faint);
}
.pagination a { color: var(--color-text); transition: color var(--transition); }
.pagination a:hover { color: var(--accent); }

/* Snippets — microblog feed: date, optional title, then the post ---------- */

.snippet + .snippet {
    margin-top: var(--space-3);
    padding-top: var(--space-3);
    border-top: 1px solid var(--color-rule);
}
.snippet-date {
    display: block;
    margin-bottom: 0.3rem;
    font-family: var(--font-ui);
    font-size: var(--size-ui-text);
    line-height: 1.4;
    color: var(--color-faint);
    font-variant-numeric: lining-nums tabular-nums;
    transition: color var(--transition);
}
.snippet-date:hover { color: var(--accent); }
.snippet-title {
    margin-bottom: 0.3rem;
    font-size: var(--title-md);
}
.snippet-title a { transition: color var(--transition); }
.snippet-title a:hover { color: var(--accent); }
.snippet-body { font-size: 0.95em; }
.snippet-body > .kg-card { margin-top: 0.9rem; margin-bottom: 0.9rem; }
/* Inside the feed, wide/full cards stay within the column */
.snippet-body .kg-width-wide,
.snippet-body .kg-width-full {
    width: 100%;
    left: auto;
    transform: none;
}
.snippet-body .kg-width-full img { border-radius: var(--radius) !important; }
.snippet-more { margin-top: var(--space-3); }

/* Books (shared) --------------------------------------------------------- */

.book-cover {
    display: block;
    width: 100%;
    aspect-ratio: 2 / 3;
    object-fit: cover;
    border-radius: var(--radius-sm);
    box-shadow: 0 1px 2px rgb(0 0 0 / 0.12), 0 4px 10px -4px rgb(0 0 0 / 0.2);
}
.book-cover-blank {
    display: flex;
    align-items: flex-end;
    padding: 0.4rem;
    background: var(--color-panel);
    font-family: var(--font-heading);
    font-size: 0.65rem;
    line-height: 1.2;
    color: var(--color-muted);
}

/* Home: five most recent covers */
.book-row {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 0.9rem;
    padding: 0;
    list-style: none;
}
.book-row a { display: block; transition: transform var(--transition); }
.book-row a:hover { transform: translateY(-2px); }

/* Currently reading — the one book in progress (home + bookshelf).
   The single book page header (.book-header) shares these styles at the large size. */
.reading-now,
.book-header {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    margin-bottom: var(--space-3);
}
.reading-now-book { flex-shrink: 0; width: 4.5rem; }
/* A few page edges behind the cover so it reads as a book in hand */
.reading-now .book-cover,
.book-header .book-cover {
    box-shadow:
        2px 2px 0 -0.5px var(--color-bg), 2px 2px 0 0 var(--color-rule),
        4px 4px 0 -0.5px var(--color-bg), 4px 4px 0 0 var(--color-rule),
        0 6px 14px -6px rgb(0 0 0 / 0.3);
    transition: transform var(--transition);
}
.reading-now:hover .book-cover { transform: rotate(-1.5deg) translateY(-2px); }
.reading-now-info { display: flex; flex-direction: column; gap: 0.3rem; min-width: 0; }
.reading-now-label { color: var(--accent); }
.reading-now-meta { color: var(--color-faint); }
.reading-now-title {
    font-size: var(--title-md);
    text-wrap: balance;
    transition: color var(--transition);
}
.reading-now:hover .reading-now-title { color: var(--accent); }
.reading-now-note {
    margin-top: 0.4rem;
    color: var(--color-muted);
    font-size: 0.9em;
    line-height: 1.5;
}
.reading-now.is-large,
.book-header { gap: 1.75rem; margin-bottom: 0; }
.reading-now.is-large .reading-now-book,
.book-header .reading-now-book { width: 7.5rem; }
.reading-now.is-large .reading-now-title,
.book-header .reading-now-title { font-size: var(--title-lg); }
.book-header a.reading-now-label { transition: color var(--transition); }
.book-header a.reading-now-label:hover { color: var(--color-text); }

/* Single book page: notes, or an empty state when there are none */
.book-notes {
    margin-top: var(--space-4);
    padding-top: var(--space-4);
    border-top: 1px solid var(--color-rule);
}
.book-notes-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.6rem;
    padding: var(--space-4) var(--space-3);
    border: 1px dashed var(--color-rule);
    border-radius: var(--radius-lg);
    color: var(--color-faint);
    text-align: center;
}
.book-notes-empty p {
    font-family: var(--font-heading);
    font-style: italic;
    color: var(--color-muted);
}

/* Image topics (photos, drawings, …) */
.image-strip {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: var(--space-1);
    padding: 0;
    list-style: none;
}
.image-strip img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: var(--radius-sm); }

/* Bookshelf page --------------------------------------------------------- */

.shelf-reading { margin-bottom: var(--space-5); }

.shelf-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-2);
    margin-bottom: var(--space-2);
    color: var(--color-faint);
}
.view-toggle {
    display: inline-flex;
    padding: 2px;
    border: 1px solid var(--color-rule);
    border-radius: var(--radius-lg);
}
.view-toggle button {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.3rem 0.6rem;
    border: 0;
    border-radius: var(--radius);
    background: none;
    color: var(--color-muted);
    font: inherit;
    letter-spacing: inherit;
    text-transform: inherit;
    cursor: pointer;
    transition: color var(--transition), background-color var(--transition);
}
.view-toggle button:hover { color: var(--accent); }
/* Selected state follows the <html> flag set before first paint, so it never animates on load */
html:not([data-book-view="list"]) .view-toggle [data-view="grid"],
html[data-book-view="list"] .view-toggle [data-view="list"] { background: var(--color-panel); color: var(--color-text); }

/* Grid (default) */
.book-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: var(--space-3) 0.9rem;
    padding: 0;
    list-style: none;
}
.book-cell a { position: relative; display: block; transition: transform var(--transition); }
.book-cell a:hover { transform: translateY(-2px); }
.bookshelf .book-date { display: none; }
.bookshelf .book-title {
    position: absolute; width: 1px; height: 1px; overflow: hidden;
    clip: rect(0 0 0 0); white-space: nowrap;
}

/* Year headings span the full row in both views (added by main.js) */
.book-year {
    grid-column: 1 / -1;
    display: flex;
    align-items: baseline;
    gap: 0.75rem;
    margin-top: var(--space-2);
    padding-bottom: var(--space-1);
    border-bottom: 1px solid var(--color-rule);
    color: var(--color-faint);
}
.book-year:first-child { margin-top: 0; }
.book-year h2 {
    font: inherit;
    font-weight: 600;
    color: var(--color-text);
}

/* List view — same rhythm as the compact post lists */
html[data-book-view="list"] .bookshelf { display: block; }
html[data-book-view="list"] .bookshelf .book-year { margin-top: var(--space-4); margin-bottom: var(--space-2); }
html[data-book-view="list"] .bookshelf .book-year:first-child { margin-top: 0; }
html[data-book-view="list"] .bookshelf .book-cell + .book-cell { margin-top: 0.7rem; }
html[data-book-view="list"] .bookshelf .book-cell a {
    display: grid;
    grid-template-columns: 4.5rem 1.6rem 1fr;
    align-items: center;
    column-gap: 0.9rem;
}
html[data-book-view="list"] .bookshelf .book-cell a:hover { transform: none; }
html[data-book-view="list"] .bookshelf .book-cover {
    grid-column: 2;
    grid-row: 1;
    width: 1.6rem;
    border-radius: var(--radius-sm);
    box-shadow: 0 1px 2px rgb(0 0 0 / 0.15);
}
html[data-book-view="list"] .bookshelf .book-cover-blank span { display: none; }
html[data-book-view="list"] .bookshelf .book-date {
    display: block;
    grid-column: 1;
    grid-row: 1;
    color: var(--color-faint);
}
html[data-book-view="list"] .bookshelf .book-title {
    position: static; width: auto; height: auto; overflow: visible; clip: auto; white-space: normal;
    grid-column: 3;
    grid-row: 1;
    font-family: var(--font-heading);
    font-size: var(--title-sm);
    font-weight: 500;
    line-height: var(--leading-list);
    text-wrap: pretty;
    transition: color var(--transition);
}
html[data-book-view="list"] .bookshelf .book-cell a:hover .book-title { color: var(--accent); }

/* Subscribe + follow ----------------------------------------------------- */

.subscribe { font-family: var(--font-ui); }
.subscribe-label {
    display: block;
    margin-bottom: var(--space-1);
    font-size: var(--size-ui-text);
    color: var(--color-muted);
}
/* Field and button share one bordered unit; the button is a sienna text action */
.subscribe-row {
    display: flex;
    align-items: stretch;
    max-width: 28rem;
    border: 1px solid var(--color-rule);
    border-radius: var(--radius-lg);
    background: color-mix(in srgb, var(--color-panel) 55%, var(--color-bg));
    transition: border-color var(--transition), box-shadow var(--transition);
}
.subscribe-row:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 14%, transparent);
}
.subscribe-input {
    flex: 1;
    min-width: 0;
    padding: 0.7rem 0.9rem;
    border: 0;
    background: none;
    font-size: var(--size-ui-text);
}
.subscribe-input:focus { outline: none; }
.subscribe-input::placeholder { color: var(--color-faint); }
.subscribe-button {
    flex-shrink: 0;
    border: 0;
    border-left: 1px solid var(--color-rule);
    border-radius: 0 var(--radius-lg) var(--radius-lg) 0;
    padding: 0 var(--space-2);
    background: none;
    color: var(--accent);
    font-size: var(--size-ui-text);
    font-weight: 600;
    cursor: pointer;
    transition: background-color var(--transition);
}
.subscribe-button span { display: inline-block; transition: transform var(--transition); }
.subscribe-button:hover { background: var(--accent-soft); }
.subscribe-button:hover span { transform: translateX(3px); }
.subscribe-message { display: none; margin-top: 0.6rem; font-size: var(--size-ui-text); }
.subscribe-form.success .subscribe-success,
.subscribe-form.error .subscribe-error { display: block; }
.subscribe-form.success .subscribe-row { display: none; }
.subscribe-form.loading .subscribe-button { opacity: 0.5; }

.follow-text {
    margin-bottom: var(--space-2);
    font-size: var(--title-md);
    line-height: 1.4;
}
.follow-also {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem var(--space-2);
    margin-top: var(--space-2);
    color: var(--color-faint);
}
.follow-also a { color: var(--color-muted); transition: color var(--transition); }
.follow-also a:hover { color: var(--accent); }

/* Article ---------------------------------------------------------------- */

.article-header { margin-bottom: var(--space-4); }

.article-title {
    font-family: var(--font-heading);
    font-size: var(--title-xl);
    font-weight: 600;
    line-height: var(--leading-tight);
    letter-spacing: -0.01em;
    text-wrap: balance;
}
.article-dek {
    margin-top: 0.4rem;
    font-size: var(--title-md);
    font-style: italic;
    line-height: 1.35;
    color: var(--color-muted);
}
.article-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0 0.6rem;
    margin-top: 1.25rem;
    color: var(--color-faint);
}
.article-meta a { transition: color var(--transition); }
.article-meta a:hover { color: var(--accent); }

.article-image { margin: 0 0 var(--space-4); }
.article-image img { width: 100%; border-radius: var(--radius); }

figcaption {
    margin-top: 0.6rem;
    font-family: var(--font-ui);
    font-size: var(--size-caption);
    line-height: 1.45;
    text-align: center;
    color: var(--color-muted);
}

/* Content ---------------------------------------------------------------- */

.gh-content { text-wrap: pretty; hanging-punctuation: first; }

.gh-content > * + * { margin-top: 1.1em; }
.gh-content > :first-child { margin-top: 0; }

.gh-content a {
    color: var(--accent);
    text-decoration: underline;
    text-decoration-color: color-mix(in srgb, var(--accent) 40%, transparent);
    text-decoration-thickness: 0.06em;
    text-underline-offset: 0.18em;
}
.gh-content a:hover { text-decoration-color: currentColor; }

.gh-content h2,
.gh-content h3,
.gh-content h4 {
    font-family: var(--font-heading);
    line-height: var(--leading-tight);
    font-weight: 600;
}
.gh-content h2 { font-size: 1.25em; margin-top: 2.2em; }
.gh-content h3 { font-size: 1.1em; margin-top: 1.8em; }
.gh-content h4 { font-size: 1em; margin-top: 1.6em; }
.gh-content :is(h2, h3, h4) + * { margin-top: 0.6em; }

.gh-content strong { font-weight: 600; }
.gh-content mark { background: var(--color-mark); color: inherit; padding: 0 0.1em; }

.gh-content ul,
.gh-content ol { padding-left: 1.3em; }
.gh-content li + li { margin-top: 0.35em; }

.gh-content blockquote:not([class]) {
    padding-left: 1.25em;
    border-left: 2px solid var(--accent);
    color: var(--color-muted);
    font-style: italic;
}
.gh-content blockquote.kg-blockquote-alt {
    font-size: 1.3em;
    line-height: 1.4;
    text-align: center;
    font-style: italic;
    color: var(--color-muted);
    padding: 0.5em 1em;
}

.gh-content hr {
    border: 0;
    height: auto;
    margin: 2.5em 0;
    text-align: center;
}
.gh-content hr::after {
    content: "* * *";
    color: var(--color-faint);
    letter-spacing: 0.5em;
}

.gh-content code {
    font-family: var(--font-mono);
    font-size: 0.85em;
    background: var(--color-panel);
    padding: 0.1em 0.3em;
    border-radius: var(--radius);
}
.gh-content pre {
    font-family: var(--font-mono);
    font-size: 0.8em;
    line-height: 1.6;
    background: var(--color-panel);
    padding: 1em 1.25em;
    overflow-x: auto;
    border-radius: var(--radius);
}
.gh-content pre code { background: none; padding: 0; font-size: inherit; }

.gh-content table {
    width: 100%;
    border-collapse: collapse;
    font-family: var(--font-ui);
    font-size: 0.85em;
    font-variant-numeric: lining-nums tabular-nums;
}
.gh-content th,
.gh-content td { padding: 0.5em 0.75em 0.5em 0; border-bottom: 1px solid var(--color-rule); text-align: left; }
.gh-content th { font-weight: 600; }

.gh-content figure img { border-radius: var(--radius); }
.gh-content > figure,
.gh-content > .kg-card { margin-top: 2em; margin-bottom: 2em; }
.gh-content > .kg-card + *,
.gh-content > figure + * { margin-top: 0; }

/* Paragraph options (theme settings) */
.text-justified .gh-content p {
    text-align: justify;
    hyphens: auto;
    -webkit-hyphens: auto;
}
.paragraphs-indented .gh-content p + p {
    margin-top: 0;
    text-indent: 1.5em;
}

/* End mark after the last paragraph */
.post-template .gh-content > p:last-child:not(:empty)::after {
    content: "";
    display: inline-block;
    width: 0.3em;
    height: 0.3em;
    margin-left: 0.4em;
    background: var(--accent);
    vertical-align: 0.15em;
}

/* Koenig card widths — break out of the measure */
.kg-width-wide {
    position: relative;
    width: min(56rem, 100vw - 2 * var(--gutter));
    left: 50%;
    transform: translateX(-50%);
}
.kg-width-full {
    position: relative;
    width: 100vw;
    left: 50%;
    transform: translateX(-50%);
}
.kg-width-full img { border-radius: 0 !important; }
.kg-width-full figcaption { padding: 0 var(--gutter); }

/* Embeds: iframes are sized from their width/height attributes by main.js */
.kg-embed-card { display: flex; flex-direction: column; align-items: center; }
.kg-embed-card iframe { max-width: 100%; }
.kg-embed-card iframe.is-responsive { width: 100%; height: auto; }

/* Gallery lightbox (main.js) --------------------------------------------- */

.kg-gallery-image img { cursor: zoom-in; }

.lightbox {
    width: 100vw;
    height: 100dvh;
    max-width: none;
    max-height: none;
    margin: 0;
    padding: 0;
    border: 0;
    background: var(--lightbox-bg);
    color: #f5f0e8;
    overscroll-behavior: contain;
}
.lightbox::backdrop { background: transparent; }
.lightbox[open] { display: grid; place-items: center; animation: lightbox-in var(--transition); }
@keyframes lightbox-in { from { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .lightbox[open] { animation: none; } }

.lightbox-figure {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-2);
    width: 100%;
    height: 100%;
    padding: var(--space-5) clamp(1rem, 8vw, 6rem);
    justify-content: center;
}
.lightbox-image {
    max-width: 100%;
    max-height: calc(100dvh - 2 * var(--space-5) - 2rem);
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: var(--radius-sm);
}
.lightbox-caption {
    font-family: var(--font-ui);
    font-size: var(--size-ui-text);
    text-align: center;
    color: rgb(245 240 232 / 0.75);
}
.lightbox-count {
    position: absolute;
    top: var(--space-3);
    left: var(--space-3);
    font-family: var(--font-ui);
    font-size: var(--size-label);
    font-weight: 500;
    letter-spacing: 0.08em;
    font-variant-numeric: lining-nums tabular-nums;
    color: rgb(245 240 232 / 0.6);
}
.lightbox-btn {
    position: absolute;
    display: grid;
    place-items: center;
    width: 2.75rem;
    height: 2.75rem;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: none;
    color: rgb(245 240 232 / 0.75);
    cursor: pointer;
    transition: color var(--transition), background-color var(--transition);
}
.lightbox-btn:hover { color: #f5f0e8; background: rgb(245 240 232 / 0.1); }
.lightbox-btn[hidden] { display: none; }
.lightbox-close { top: var(--space-2); right: var(--space-2); }
.lightbox-prev,
.lightbox-next { top: 50%; transform: translateY(-50%); }
.lightbox-prev { left: var(--space-2); }
.lightbox-next { right: var(--space-2); }

/* Article footer --------------------------------------------------------- */

.article-footer {
    margin-top: var(--space-5);
    padding-top: var(--space-3);
    border-top: 1px solid var(--color-rule);
}
.article-tags {
    margin-bottom: var(--space-3);
    font-family: var(--font-ui);
    font-size: var(--size-ui-text);
    color: var(--color-muted);
}
.article-tags a { transition: color var(--transition); }
.article-tags a:hover { color: var(--accent); }
.article-comments { margin-top: var(--space-4); }

.post-nav {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    margin-top: var(--space-4);
    padding-top: var(--space-3);
    border-top: 1px solid var(--color-rule);
}
.post-nav-link { display: flex; flex-direction: column; gap: 0.3rem; }
.post-nav-next { grid-column: 2; text-align: right; }
.post-nav-link .label { color: var(--color-faint); }
.post-nav-title { font-size: var(--title-sm); transition: color var(--transition); }
.post-nav-link:hover .post-nav-title { color: var(--accent); }

/* Error ------------------------------------------------------------------ */

.error .label { color: var(--color-faint); margin-bottom: var(--space-1); }
.error p:last-child { margin-top: var(--space-3); }
.error a { color: var(--accent); }

/* Footer ----------------------------------------------------------------- */

.site-footer {
    max-width: var(--measure);
    margin: 0 auto;
    padding: 2rem 0 3rem;
    border-top: 1px solid var(--color-rule);
    color: var(--color-muted);
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 0.75rem 2rem;
}
.footer-meta { display: flex; flex-wrap: wrap; gap: 0 0.6rem; }
.footer-meta span + span::before { content: "·"; margin-right: 0.6rem; color: var(--color-faint); }
.footer-meta a { transition: color var(--transition); }
.footer-meta a:hover { color: var(--accent); }
.footer-nav { display: flex; flex-wrap: wrap; gap: var(--space-1) 1.25rem; }
.site-footer .nav a { color: inherit; font-size: inherit; }
.site-footer .nav a:hover { color: var(--accent); }

/* Small screens ---------------------------------------------------------- */

@media (max-width: 40rem) {
    .site-icon { margin-left: 0; }
    .post-item.is-featured .post-item-title::before { position: static; margin-right: 0.3em; }
    .post-item-link { grid-template-columns: 1fr; row-gap: 0.15rem; }
    .book-row { grid-template-columns: repeat(4, 1fr); }
    .book-row li:nth-child(5) { display: none; }
    .image-strip { grid-template-columns: repeat(3, 1fr); }
    .image-strip li:nth-child(n+4) { display: none; }
    .book-grid { grid-template-columns: repeat(3, 1fr); }
    html[data-book-view="list"] .bookshelf .book-cell a { grid-template-columns: 3.5rem 1.4rem 1fr; column-gap: 0.7rem; }
}
