/* ==========================================================================
   Bastion: a research-notebook theme for writing about cloud security,
   DevOps and systems.
   ========================================================================== */

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

:root {
    --font-sans: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --font-serif: "Source Serif 4", "Source Serif Pro", Georgia, "Times New Roman", serif;
    --font-mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

    --wrap: 1040px;
    --measure: 720px;
    --gutter: clamp(16px, 4vw, 32px);
    --radius: 10px;

    --bg: #fafaf7;
    --bg-elev: #ffffff;
    --bg-sunk: #f0f0ea;
    --fg: #16181b;
    --fg-muted: #4d545c;
    --fg-faint: #656c74;
    --border: #e2e2da;
    --border-strong: #cfcfc6;
    --accent: #0b7a6c;
    --accent-soft: rgba(11, 122, 108, 0.12);
    --accent-line: rgba(11, 122, 108, 0.35);
    --grid-line: rgba(22, 24, 27, 0.055);
    --shadow: 0 1px 2px rgba(16, 24, 27, 0.06), 0 12px 32px -12px rgba(16, 24, 27, 0.28);

    /* Terminal panes (whoami card, code blocks) stay dark in both themes. */
    --term-bg: #11181b;
    --term-border: #11181b;
    --term-rule: #222d32;
    --term-fg: #e2e8e6;
    --term-dim: #93a1a7;
    --term-accent: #5ad1b8;

    --tok-comment: #7f9099;
    --tok-keyword: #f2a07b;
    --tok-string: #a8d98a;
    --tok-func: #7cc4f8;
    --tok-number: #e8c46f;
    --tok-type: #c4a7ff;
    --tok-builtin: #5ad1b8;
    --tok-op: #b3bec3;
    --tok-del: #ff8a80;
    --tok-ins: #8fe39a;

    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg: #0e1113;
        --bg-elev: #141a1d;
        --bg-sunk: #181f23;
        --fg: #e4e7e5;
        --fg-muted: #a7b0b5;
        --fg-faint: #808b91;
        --border: #232b30;
        --border-strong: #313b41;
        --accent: #5ad1b8;
        --accent-soft: rgba(90, 209, 184, 0.14);
        --accent-line: rgba(90, 209, 184, 0.4);
        --grid-line: rgba(228, 231, 229, 0.045);
        --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 16px 40px -16px rgba(0, 0, 0, 0.7);
        --term-bg: #131b1f;
        --term-border: #263137;
        color-scheme: dark;
    }
}

:root[data-theme="dark"] {
    --bg: #0e1113;
    --bg-elev: #141a1d;
    --bg-sunk: #181f23;
    --fg: #e4e7e5;
    --fg-muted: #a7b0b5;
    --fg-faint: #808b91;
    --border: #232b30;
    --border-strong: #313b41;
    --accent: #5ad1b8;
    --accent-soft: rgba(90, 209, 184, 0.14);
    --accent-line: rgba(90, 209, 184, 0.4);
    --grid-line: rgba(228, 231, 229, 0.045);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 16px 40px -16px rgba(0, 0, 0, 0.7);
    --term-bg: #131b1f;
    --term-border: #263137;
    color-scheme: dark;
}

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

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

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    scroll-padding-top: 5rem;
}

body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--bg);
    color: var(--fg);
    font-family: var(--font-sans);
    font-size: 1rem;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

main {
    flex: 1;
}

a {
    color: var(--accent);
}

img,
svg {
    vertical-align: middle;
}

::selection {
    background: var(--accent-soft);
}

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

.i {
    width: 1.1em;
    height: 1.1em;
    flex: none;
}

.i-sm {
    width: 0.95em;
    height: 0.95em;
}

.skip-link {
    position: absolute;
    left: -9999px;
    top: 0.75rem;
    z-index: 100;
    padding: 0.5rem 0.9rem;
    border-radius: 6px;
    background: var(--fg);
    color: var(--bg);
    font-weight: 600;
    text-decoration: none;
}

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

.container {
    width: 100%;
    max-width: calc(var(--wrap) + 2 * var(--gutter));
    margin-inline: auto;
    padding-inline: var(--gutter);
}

.eyebrow {
    margin: 0;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    letter-spacing: 0.02em;
    color: var(--accent);
}

.eyebrow a {
    color: inherit;
}

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

.site-header {
    position: sticky;
    top: 0;
    z-index: 20;
    background: var(--bg);
    background: color-mix(in srgb, var(--bg) 86%, transparent);
    -webkit-backdrop-filter: saturate(1.4) blur(10px);
    backdrop-filter: saturate(1.4) blur(10px);
    border-bottom: 1px solid var(--border);
}

.site-header-inner {
    display: flex;
    align-items: center;
    gap: 1rem;
    min-height: 3.75rem;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    color: var(--fg);
    text-decoration: none;
    font-family: var(--font-mono);
    font-weight: 500;
    font-size: 1.02rem;
    letter-spacing: -0.01em;
}

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

.site-nav {
    margin-left: auto;
}

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

.site-nav a {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.4rem 0.7rem;
    border-radius: 6px;
    color: var(--fg-muted);
    font-size: 0.93rem;
    font-weight: 500;
    text-decoration: none;
    white-space: nowrap;
    transition: color 0.15s, background-color 0.15s;
}

.site-nav a:hover {
    color: var(--fg);
    background: var(--bg-sunk);
}

.site-nav a[aria-current="page"] {
    color: var(--fg);
    background: var(--bg-sunk);
}

.theme-toggle {
    display: grid;
    place-items: center;
    width: 2.25rem;
    height: 2.25rem;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: transparent;
    color: var(--fg-muted);
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s;
}

.theme-toggle:hover {
    color: var(--fg);
    border-color: var(--border-strong);
}

/* Show the icon of the mode you would switch to. */
.theme-toggle .i-sun {
    display: none;
}

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

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

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .theme-toggle .i-sun {
        display: block;
    }

    :root:not([data-theme="light"]) .theme-toggle .i-moon {
        display: none;
    }
}

@media (max-width: 640px) {
    .site-header {
        position: static;
    }

    .site-header-inner {
        flex-wrap: wrap;
        row-gap: 0;
        padding-top: 0.6rem;
    }

    .theme-toggle {
        margin-left: auto;
    }

    .site-nav {
        order: 3;
        margin: 0 calc(-1 * var(--gutter));
        padding: 0.25rem var(--gutter) 0.5rem;
        width: calc(100% + 2 * var(--gutter));
        overflow-x: auto;
        scrollbar-width: none;
    }

    .site-nav a {
        padding-inline: 0.6rem;
    }

    .site-nav li:first-child a {
        margin-left: -0.6rem;
    }
}

/* ---------- Buttons ---------- */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.6rem 1rem;
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    background: var(--bg-elev);
    color: var(--fg);
    font-size: 0.93rem;
    font-weight: 500;
    line-height: 1.2;
    text-decoration: none;
    transition: border-color 0.15s, background-color 0.15s, color 0.15s;
}

.btn:hover {
    border-color: var(--fg-faint);
}

.btn-primary {
    background: var(--fg);
    border-color: var(--fg);
    color: var(--bg);
}

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

/* ---------- Tags ---------- */

.tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

.tag {
    display: inline-block;
    padding: 0.12rem 0.5rem;
    border: 1px solid var(--border);
    border-radius: 5px;
    background: var(--bg-sunk);
    color: var(--fg-muted);
    font-family: var(--font-mono);
    font-size: 0.75rem;
    line-height: 1.5;
    text-decoration: none;
    transition: color 0.15s, border-color 0.15s;
}

.tag::before {
    content: "#";
    color: var(--fg-faint);
}

.tag:hover {
    color: var(--accent);
    border-color: var(--accent-line);
}

/* ---------- Hero ---------- */

.hero {
    position: relative;
    isolation: isolate;
    overflow: hidden;
    padding: clamp(3rem, 8vw, 5.5rem) 0 clamp(2.75rem, 6vw, 4.5rem);
    border-bottom: 1px solid var(--border);
}

/* Faint blueprint grid behind the hero. */
.hero::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    background-image:
        linear-gradient(var(--grid-line) 1px, transparent 1px),
        linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
    background-size: 32px 32px;
    background-position: -1px -1px;
    -webkit-mask-image: radial-gradient(ellipse 70% 90% at 75% 40%, #000 10%, transparent 75%);
    mask-image: radial-gradient(ellipse 70% 90% at 75% 40%, #000 10%, transparent 75%);
}

.hero-inner {
    display: grid;
    grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
    gap: clamp(2rem, 5vw, 4rem);
    align-items: center;
}

.hero-title {
    margin: 0.6rem 0 1rem;
    font-size: clamp(2.4rem, 6vw, 3.6rem);
    font-weight: 700;
    line-height: 1.04;
    letter-spacing: -0.035em;
}

.hero-lead {
    max-width: 34em;
    margin: 0;
    color: var(--fg-muted);
    font-family: var(--font-serif);
    font-size: clamp(1.1rem, 2vw, 1.25rem);
    line-height: 1.6;
}

.hero-lead a {
    color: var(--fg);
    text-decoration-color: var(--accent-line);
    text-underline-offset: 0.2em;
}

.hero-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
    margin-top: 2rem;
}

.hero-social {
    display: flex;
    gap: 0.15rem;
    margin: 0 0 0 0.25rem;
    padding: 0;
    list-style: none;
}

.hero-social a {
    display: grid;
    place-items: center;
    width: 2.4rem;
    height: 2.4rem;
    border-radius: 8px;
    color: var(--fg-muted);
    transition: color 0.15s, background-color 0.15s;
}

.hero-social a:hover {
    color: var(--fg);
    background: var(--bg-sunk);
}

@media (max-width: 860px) {
    .hero-inner {
        grid-template-columns: minmax(0, 1fr);
    }
}

/* ---------- Terminal pane ---------- */

.term {
    overflow: hidden;
    border: 1px solid var(--term-border);
    border-radius: var(--radius);
    background: var(--term-bg);
    color: var(--term-fg);
    box-shadow: var(--shadow);
    font-family: var(--font-mono);
    font-size: 0.86rem;
}

.term-bar {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.6rem 1rem;
    border-bottom: 1px solid var(--term-rule);
    color: var(--term-dim);
    font-size: 0.75rem;
}

/* "Session up" indicator. */
.term-bar::before {
    content: "";
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--term-accent);
    box-shadow: 0 0 0 3px rgba(90, 209, 184, 0.18);
}

.term-body {
    padding: 1rem 1.15rem 1.15rem;
    line-height: 1.75;
}

.term-body p {
    margin: 0;
    overflow-wrap: anywhere;
}

.term .cmd::before {
    content: "$ ";
    color: var(--term-accent);
}

.term .out {
    color: var(--term-dim);
}

.term .out + .cmd {
    margin-top: 0.55rem;
}

.term .out-err {
    color: var(--tok-del);
}

.term .out-ls {
    display: flex;
    flex-wrap: wrap;
    column-gap: 1.1em;
}

.term .out-ls a {
    color: var(--term-accent);
    text-decoration: none;
}

.term .out-ls a:hover {
    text-decoration: underline;
    text-underline-offset: 0.2em;
}

.cursor {
    display: inline-block;
    width: 0.55em;
    height: 1.1em;
    background: var(--term-accent);
    vertical-align: text-bottom;
    animation: blink 1.1s steps(1, end) infinite;
}

@keyframes blink {
    50% {
        opacity: 0;
    }
}

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

.home-section {
    padding-top: clamp(2.5rem, 6vw, 3.75rem);
}

.section-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0.5rem;
}

.section-head h2 {
    margin: 0;
    color: var(--fg-faint);
    font-family: var(--font-mono);
    font-size: 0.78rem;
    font-weight: 500;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.section-link {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.92rem;
    font-weight: 500;
    text-decoration: none;
}

.section-link:hover {
    text-decoration: underline;
    text-underline-offset: 0.2em;
}

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

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

.post-item {
    position: relative;
    display: grid;
    grid-template-columns: 7rem minmax(0, 1fr);
    gap: 0.25rem 1.5rem;
    padding: 1.35rem 0;
    border-top: 1px solid var(--border);
}

.post-item-date {
    padding-top: 0.2rem;
    color: var(--fg-faint);
    font-family: var(--font-mono);
    font-size: 0.82rem;
    white-space: nowrap;
}

.post-item-body {
    max-width: var(--measure);
}

.post-item-title {
    margin: 0;
    font-size: 1.2rem;
    font-weight: 600;
    line-height: 1.35;
    letter-spacing: -0.01em;
    text-wrap: balance;
}

.post-item-title a {
    color: var(--fg);
    text-decoration: none;
    transition: color 0.15s;
}

/* The whole row is clickable; tags stay independently clickable above it. */
.post-item-title a::after {
    content: "";
    position: absolute;
    inset: 0;
}

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

.post-item-desc {
    margin: 0.35rem 0 0;
    color: var(--fg-muted);
    font-family: var(--font-serif);
    font-size: 1.02rem;
    line-height: 1.55;
}

.post-item .tags {
    position: relative;
    z-index: 1;
    margin-top: 0.7rem;
}

@media (max-width: 640px) {
    .post-item {
        grid-template-columns: minmax(0, 1fr);
    }

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

/* ---------- Archive & page heads ---------- */

.page-head {
    padding-top: clamp(2.5rem, 6vw, 4.5rem);
    padding-bottom: 0.5rem;
}

.page-title {
    margin: 0.3rem 0 0.75rem;
    font-size: clamp(2rem, 5vw, 2.75rem);
    font-weight: 700;
    line-height: 1.1;
    letter-spacing: -0.03em;
}

.page-lead {
    max-width: 38em;
    margin: 0 0 0.6rem;
    color: var(--fg-muted);
    font-family: var(--font-serif);
    font-size: 1.2rem;
    line-height: 1.55;
}

.page-sub {
    margin: 0;
    color: var(--fg-faint);
    font-family: var(--font-mono);
    font-size: 0.8rem;
}

.year-group {
    margin-top: 2.5rem;
}

.year-label {
    display: flex;
    align-items: center;
    gap: 0.9rem;
    margin: 0 0 0.25rem;
    color: var(--accent);
    font-family: var(--font-mono);
    font-size: 0.9rem;
    font-weight: 500;
}

.year-label::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--border);
}

.year-group .post-item:first-child {
    border-top: 0;
}

.tag-index {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 0.75rem;
    margin: 2rem 0 0;
    padding: 0;
    list-style: none;
}

.tag-index a {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.9rem 1.1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-elev);
    color: var(--fg);
    font-family: var(--font-mono);
    font-size: 0.92rem;
    text-decoration: none;
    transition: border-color 0.15s, color 0.15s;
}

.tag-index a:hover {
    border-color: var(--accent-line);
    color: var(--accent);
}

.tag-index-count {
    padding: 0.05rem 0.55rem;
    border-radius: 999px;
    background: var(--bg-sunk);
    color: var(--fg-muted);
    font-size: 0.78rem;
}

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

.post-head {
    --wrap: var(--measure);
    padding-top: clamp(2.5rem, 6vw, 4.5rem);
}

.post-head::after {
    content: "";
    display: block;
    height: 1px;
    margin-top: 2rem;
    background: var(--border);
}

.post-meta {
    margin: 0;
    color: var(--fg-faint);
    font-family: var(--font-mono);
    font-size: 0.8rem;
}

.post-meta a {
    color: var(--fg-muted);
    text-decoration: none;
}

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

.post-title {
    margin: 0.75rem 0 1rem;
    font-size: clamp(1.9rem, 4.6vw, 2.7rem);
    font-weight: 700;
    line-height: 1.12;
    letter-spacing: -0.03em;
    text-wrap: balance;
}

.post-lead {
    margin: 0 0 1.25rem;
    color: var(--fg-muted);
    font-family: var(--font-serif);
    font-size: 1.2rem;
    line-height: 1.55;
}

.post-layout {
    --wrap: 1320px;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    padding-top: 2.25rem;
}

.prose {
    width: 100%;
    max-width: var(--measure);
    margin-inline: auto;
}

/* ---------- Table of contents ---------- */

.toc {
    width: 100%;
    max-width: var(--measure);
    margin-inline: auto;
}

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

.toc a {
    display: block;
    padding: 0.28rem 0 0.28rem 0.85rem;
    border-left: 2px solid var(--border);
    color: var(--fg-muted);
    font-size: 0.84rem;
    line-height: 1.4;
    text-decoration: none;
    transition: color 0.15s, border-color 0.15s;
}

.toc ul ul a {
    padding-left: 1.65rem;
    font-size: 0.8rem;
}

.toc a:hover {
    color: var(--fg);
}

.toc a.is-active {
    border-left-color: var(--accent);
    color: var(--accent);
}

.toc strong,
.toc em {
    font-weight: inherit;
    font-style: inherit;
}

.toc code {
    font-family: var(--font-mono);
    font-size: 0.92em;
}

.toc-details {
    margin-bottom: 2.25rem;
    padding: 0.8rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-sunk);
}

.toc-details summary {
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
}

.toc-details[open] summary {
    margin-bottom: 0.75rem;
}

.toc-sticky {
    display: none;
}

.toc-title {
    margin: 0 0 0.75rem;
    color: var(--fg-faint);
    font-family: var(--font-mono);
    font-size: 0.72rem;
    font-weight: 500;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

@media (min-width: 1240px) {
    .post.has-toc .post-layout {
        grid-template-columns: minmax(0, 1fr) minmax(0, var(--measure)) minmax(0, 1fr);
        column-gap: 3rem;
    }

    .post.has-toc .prose {
        grid-column: 2;
        grid-row: 1;
    }

    .post.has-toc .toc {
        grid-column: 3;
        grid-row: 1;
        max-width: 260px;
        margin: 0;
    }

    .toc-details {
        display: none;
    }

    .toc-sticky {
        display: block;
        position: sticky;
        top: 5.5rem;
        max-height: calc(100vh - 7rem);
        overflow-y: auto;
        scrollbar-width: thin;
    }
}

/* ---------- Prose ---------- */

.prose {
    color: var(--fg);
    font-family: var(--font-serif);
    font-size: 1.135rem;
    line-height: 1.75;
    overflow-wrap: break-word;
}

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

.prose p,
.prose ul,
.prose ol,
.prose dl,
.prose table {
    margin: 0 0 1.3em;
}

.prose h1,
.prose h2,
.prose h3,
.prose h4,
.prose h5,
.prose h6 {
    position: relative;
    font-family: var(--font-sans);
    font-weight: 650;
    line-height: 1.3;
    letter-spacing: -0.015em;
    text-wrap: balance;
}

/* Posts use both # and ## for sections; size them alike under the page title. */
.prose h1,
.prose h2 {
    margin: 2.4em 0 0.75em;
    font-size: 1.55rem;
}

.prose h3 {
    margin: 2em 0 0.6em;
    font-size: 1.22rem;
}

.prose h4,
.prose h5,
.prose h6 {
    margin: 1.75em 0 0.5em;
    font-size: 1.05rem;
}

.heading-anchor {
    margin-left: 0.4em;
    color: var(--fg-faint);
    font-weight: 400;
    text-decoration: none;
    opacity: 0;
    transition: opacity 0.15s, color 0.15s;
}

.prose :is(h1, h2, h3, h4, h5, h6):hover .heading-anchor,
.heading-anchor:focus-visible {
    opacity: 1;
}

.heading-anchor:hover {
    color: var(--accent);
}

.prose a {
    color: var(--accent);
    text-decoration: underline;
    text-decoration-color: var(--accent-line);
    text-decoration-thickness: 1px;
    text-underline-offset: 0.2em;
    transition: text-decoration-color 0.15s;
}

.prose a:hover {
    text-decoration-color: currentColor;
}

.prose strong {
    font-weight: 600;
}

.prose ul,
.prose ol {
    padding-left: 1.4em;
}

.prose li + li,
.prose li > ul,
.prose li > ol {
    margin-top: 0.4em;
}

.prose li > ul,
.prose li > ol {
    margin-bottom: 0;
}

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

.prose blockquote {
    margin: 1.75em 0;
    padding: 0.15em 0 0.15em 1.25em;
    border-left: 3px solid var(--accent);
    color: var(--fg-muted);
    font-style: italic;
}

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

.prose hr {
    height: 1px;
    margin: 3em 0;
    border: 0;
    background: var(--border);
}

.prose img {
    display: block;
    max-width: 100%;
    height: auto;
    margin-inline: auto;
    border: 1px solid var(--border);
    border-radius: 8px;
}

.prose figure {
    margin: 2em 0;
}

.prose figcaption,
.prose figcaption h4 {
    margin: 0.75rem 0 0;
    color: var(--fg-faint);
    font-family: var(--font-mono);
    font-size: 0.8rem;
    font-weight: 400;
    letter-spacing: 0;
    text-align: center;
}

.prose table {
    display: block;
    width: 100%;
    overflow-x: auto;
    border-collapse: collapse;
    font-family: var(--font-sans);
    font-size: 0.95rem;
}

.prose th,
.prose td {
    padding: 0.55rem 0.85rem;
    border-bottom: 1px solid var(--border);
    text-align: left;
    vertical-align: top;
}

.prose th {
    border-bottom: 2px solid var(--border-strong);
    font-weight: 600;
}

/* Inline code */
.prose :not(pre) > code {
    padding: 0.1em 0.38em;
    border: 1px solid var(--border);
    border-radius: 5px;
    background: var(--bg-sunk);
    font-family: var(--font-mono);
    font-size: 0.84em;
    overflow-wrap: anywhere;
}

/* ---------- Code blocks ---------- */

.codeblock,
.prose > pre {
    margin: 1.75em 0;
    overflow: hidden;
    border: 1px solid var(--term-border);
    border-radius: var(--radius);
    background: var(--term-bg);
}

.codeblock-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    min-height: 2.25rem;
    padding: 0.3rem 0.45rem 0.3rem 1rem;
    border-bottom: 1px solid var(--term-rule);
    color: var(--term-dim);
    font-family: var(--font-mono);
    font-size: 0.72rem;
    letter-spacing: 0.04em;
    text-transform: lowercase;
}

.codeblock-copy {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.25rem 0.55rem;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--term-dim);
    font: inherit;
    cursor: pointer;
    transition: color 0.15s, background-color 0.15s;
}

.codeblock-copy:hover {
    background: rgba(255, 255, 255, 0.07);
    color: var(--term-fg);
}

.codeblock-copy .i-check,
.codeblock.is-copied .codeblock-copy .i-copy {
    display: none;
}

.codeblock.is-copied .codeblock-copy .i-check {
    display: inline;
}

.codeblock.is-copied .codeblock-copy {
    color: var(--term-accent);
}

.codeblock .highlight {
    margin: 0;
}

.codeblock pre,
.prose > pre {
    margin: 0;
    padding: 1rem 1.15rem 1.1rem;
    overflow-x: auto;
    background: transparent;
    color: var(--term-fg);
    font-size: 0.84rem;
    line-height: 1.65;
    tab-size: 4;
    scrollbar-width: thin;
    scrollbar-color: var(--term-rule) transparent;
}

.codeblock pre code,
.prose > pre code {
    font-family: var(--font-mono);
    font-size: inherit;
    background: none;
    border: 0;
    padding: 0;
    color: inherit;
}

/* Chroma tokens (markup.highlight.noClasses = false) */
.chroma .c, .chroma .ch, .chroma .cm, .chroma .c1, .chroma .cs { color: var(--tok-comment); font-style: italic; }
.chroma .cp, .chroma .cpf { color: var(--tok-keyword); }
.chroma .k, .chroma .kc, .chroma .kd, .chroma .kn, .chroma .kp, .chroma .kr, .chroma .ow { color: var(--tok-keyword); }
.chroma .kt, .chroma .nc, .chroma .nn, .chroma .ne { color: var(--tok-type); }
.chroma .nf, .chroma .fm, .chroma .nd, .chroma .na { color: var(--tok-func); }
.chroma .nb, .chroma .bp, .chroma .nt, .chroma .no { color: var(--tok-builtin); }
.chroma .nv, .chroma .vc, .chroma .vg, .chroma .vi, .chroma .vm { color: var(--term-fg); }
.chroma .s, .chroma .sa, .chroma .sb, .chroma .sc, .chroma .dl, .chroma .sd, .chroma .s2, .chroma .sh,
.chroma .sx, .chroma .s1, .chroma .ss, .chroma .sr { color: var(--tok-string); }
.chroma .se, .chroma .si { color: var(--tok-number); }
.chroma .m, .chroma .mb, .chroma .mf, .chroma .mh, .chroma .mi, .chroma .il, .chroma .mo, .chroma .l, .chroma .ld { color: var(--tok-number); }
.chroma .o, .chroma .p { color: var(--tok-op); }
.chroma .gd { color: var(--tok-del); }
.chroma .gi { color: var(--tok-ins); }
.chroma .gh, .chroma .gu { color: var(--tok-func); font-weight: 600; }
.chroma .gp { color: var(--term-accent); user-select: none; }
.chroma .go { color: var(--term-dim); }
.chroma .ge { font-style: italic; }
.chroma .gs { font-weight: 600; }
.chroma .err, .chroma .gr, .chroma .gt { color: var(--tok-del); }
.chroma .hl { display: block; background: rgba(255, 255, 255, 0.06); }
.chroma .ln, .chroma .lnt { margin-right: 1em; color: var(--term-dim); user-select: none; }

/* ---------- Post footer ---------- */

.post-foot {
    --wrap: var(--measure);
    margin-top: 3.5rem;
}

.post-nav {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border);
}

.post-nav-link {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    padding: 1rem 1.15rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-elev);
    color: var(--fg);
    text-decoration: none;
    transition: border-color 0.15s;
}

.post-nav-link:hover {
    border-color: var(--accent-line);
}

.post-nav-link.next {
    grid-column: 2;
    align-items: flex-end;
    text-align: right;
}

.post-nav-label {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    color: var(--fg-faint);
    font-family: var(--font-mono);
    font-size: 0.75rem;
}

.post-nav-title {
    font-weight: 600;
    line-height: 1.35;
}

.post-nav-link:hover .post-nav-title {
    color: var(--accent);
}

@media (max-width: 640px) {
    .post-nav {
        grid-template-columns: minmax(0, 1fr);
    }

    .post-nav-link.next {
        grid-column: auto;
    }
}

.comments {
    margin-top: 3rem;
}

.comments-title {
    margin: 0 0 1.25rem;
    color: var(--fg-faint);
    font-family: var(--font-mono);
    font-size: 0.78rem;
    font-weight: 500;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

/* ---------- 404 ---------- */

.notfound {
    --wrap: var(--measure);
    padding-top: clamp(3rem, 8vw, 5.5rem);
}

.notfound .term {
    margin-bottom: 2.75rem;
}

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

.site-footer {
    margin-top: clamp(4rem, 10vw, 6.5rem);
    padding: 1.75rem 0 2rem;
    border-top: 1px solid var(--border);
}

.site-footer-inner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1rem 2rem;
    color: var(--fg-faint);
    font-family: var(--font-mono);
    font-size: 0.8rem;
}

.footer-copy {
    margin: 0;
}

.footer-links {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1.25rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

.footer-links a {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    color: var(--fg-muted);
    text-decoration: none;
    transition: color 0.15s;
}

.footer-links a:hover {
    color: var(--accent);
}

/* ---------- Motion & print ---------- */

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation: none !important;
        transition: none !important;
    }
}

@media print {
    .site-header,
    .site-footer,
    .toc,
    .post-nav,
    .comments,
    .codeblock-copy,
    .heading-anchor {
        display: none !important;
    }

    .prose a {
        color: inherit;
    }
}
