/* ── Self-hosted fonts ─────────────────────────────────── */

/* Newsreader is a variable font — one file covers all weights */
@font-face {
    font-family: 'Newsreader';
    font-style: normal;
    font-weight: 100 900;
    font-display: swap;
    src: url('/fonts/newsreader-latin-ext.woff2') format('woff2');
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
    font-family: 'Newsreader';
    font-style: normal;
    font-weight: 100 900;
    font-display: swap;
    src: url('/fonts/newsreader-latin.woff2') format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
    font-family: 'Newsreader';
    font-style: italic;
    font-weight: 100 900;
    font-display: swap;
    src: url('/fonts/newsreader-italic-latin-ext.woff2') format('woff2');
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
    font-family: 'Newsreader';
    font-style: italic;
    font-weight: 100 900;
    font-display: swap;
    src: url('/fonts/newsreader-italic-latin.woff2') format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
    font-family: 'JetBrains Mono';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url('/fonts/jetbrains-mono-latin-ext.woff2') format('woff2');
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
    font-family: 'JetBrains Mono';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url('/fonts/jetbrains-mono-latin.woff2') format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* ── Skip link ──────────────────────────────────────────── */

.skip-link {
    position: absolute;
    top: 0;
    left: 1rem;
    z-index: 9999;
    padding: 0.5rem 1rem;
    background: var(--accent);
    color: #fff;
    font-family: var(--mono);
    font-size: 0.75rem;
    text-decoration: none;
    border-radius: 0 0 4px 4px;
    transform: translateY(-100%);
    transition: transform 0.1s ease;
}

.skip-link:focus {
    transform: translateY(0);
}

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

:root {
    --bg:        #f2e8d8;
    --text:      #1e1a14;
    --muted:     #7a6d5c;
    --border:    #d4c8b4;
    --accent:    #ff5d0d;
    --max-width: 720px;
    --serif:     'Newsreader', "Times New Roman", serif;
    --mono:      'JetBrains Mono', 'Fira Mono', Consolas, monospace;
}

[data-theme="dark"] {
    --bg:     #1a1610;
    --text:   #e8e0d0;
    --muted:  #7a7060;
    --border: #2c2820;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--serif);
    line-height: 1.65;
    padding: 0 1.5rem;
    transition: background 0.2s ease, color 0.2s ease;
}

.container {
    max-width: var(--max-width);
    margin: 0 auto;
}

/* ── Navigation ────────────────────────────────── */

nav {
    padding: 1.75rem 0;
    border-bottom: 1px solid var(--border);
}

.nav-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.nav-logo {
    display: inline-flex;
    align-items: center;
    text-decoration: none;
    color: var(--text);
}

.nav-logo svg {
    transition: transform 0.18s ease;
}

.nav-logo:hover svg {
    transform: translateY(-2px) scale(1.06);
}

.nav-logo svg {
    height: 2.8rem;
    width: auto;
    display: block;
}

.logo-dark { display: none; }
[data-theme="dark"] .logo-light { display: none; }
[data-theme="dark"] .logo-dark  { display: inline-flex; }

.nav-right {
    display: flex;
    align-items: center;
    gap: 2rem;
}

.nav-links {
    display: flex;
    gap: 2rem;
    list-style: none;
    align-items: center;
}

.nav-links a {
    color: var(--muted);
    text-decoration: none;
    font-family: var(--mono);
    font-size: 0.82rem;
    letter-spacing: 0.1em;
    transition: color 0.15s ease;
}

.nav-links a:hover,
.nav-links a.active {
    color: var(--accent);
}

.nav-slash {
    color: var(--accent);
    font-family: var(--mono);
}

#theme-toggle {
    background: none;
    border: none;
    color: var(--muted);
    font-family: var(--mono);
    font-size: 0.82rem;
    letter-spacing: 0.08em;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    transition: color 0.15s ease;
}

#theme-toggle:hover {
    color: var(--accent);
}

#nav-toggle {
    display: none;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px 2px;
    touch-action: manipulation;
}

#nav-toggle span {
    display: block;
    width: 20px;
    height: 2px;
    background: var(--text);
    border-radius: 1px;
    transition: transform 0.2s ease, opacity 0.2s ease;
}

nav.nav-open #nav-toggle span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
nav.nav-open #nav-toggle span:nth-child(2) { opacity: 0; transform: scaleX(0); }
nav.nav-open #nav-toggle span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ── Sections ──────────────────────────────────── */

section {
    padding: 3.5rem 0;
}

section + section {
    border-top: 1px solid var(--border);
}

/* ── Page title (interior pages) ──────────────── */

.page-title {
    font-family: var(--serif);
    font-size: clamp(2.5rem, 7vw, 3.25rem);
    font-weight: 700;
    letter-spacing: -0.025em;
    line-height: 1.1;
    margin-bottom: 1.4rem;
}

.page-intro {
    font-size: 1.25rem;
    font-style: italic;
    color: var(--muted);
    max-width: 560px;
    line-height: 1.85;
    margin-bottom: 2.5rem;
}

/* ── About ─────────────────────────────────────── */

.about-name {
    font-family: var(--serif);
    font-size: clamp(2.5rem, 7vw, 3.25rem);
    font-weight: 700;
    line-height: 1.1;
    letter-spacing: -0.025em;
    margin-bottom: 1.4rem;
}

.about-bio {
    font-size: 1.25rem;
    font-style: italic;
    color: var(--muted);
    max-width: 560px;
    line-height: 1.85;
    margin-bottom: 2.5rem;
}

/* ── Socials ───────────────────────────────────── */

.socials-label {
    font-family: var(--mono);
    font-size: 1rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--accent);
    margin-bottom: 0.65rem;
    text-align: center;
}

.socials-links {
    display: flex;
    gap: 1.75rem;
    flex-wrap: wrap;
    justify-content: center;
}

.socials-links a {
    color: var(--text);
    text-decoration: none;
    font-size: 1.15rem;
    border-bottom: 1px solid var(--border);
    padding-bottom: 2px;
    transition: color 0.15s ease, border-color 0.15s ease;
}

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

/* ── Section header ────────────────────────────── */

.section-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 2rem;
}

.section-title {
    font-family: var(--serif);
    font-size: 1.7rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    padding-left: 0.75rem;
    border-left: 2px solid var(--accent);
}

.see-more {
    font-family: var(--mono);
    font-size: 0.72rem;
    color: var(--muted);
    text-decoration: none;
    transition: color 0.15s ease;
}

.see-more:hover {
    color: var(--accent);
}

/* ── Articles ──────────────────────────────────── */

.article-entry {
    padding: 1.6rem 0;
    border-top: 1px solid var(--border);
}

.article-entry:last-child {
    border-bottom: 1px solid var(--border);
}

.article-title {
    font-family: var(--serif);
    font-size: 1.15rem;
    font-weight: 700;
    line-height: 1.3;
    margin-bottom: 0.3rem;
}

.article-title a {
    color: var(--text);
    text-decoration: none;
    transition: color 0.15s ease;
}

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

.article-subtitle {
    color: var(--muted);
    font-size: 0.9rem;
    line-height: 1.55;
    margin-bottom: 0.8rem;
}

.article-meta {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-family: var(--mono);
    font-size: 0.7rem;
    color: var(--muted);
    flex-wrap: wrap;
}

.sep {
    opacity: 0.35;
}

/* ── Projects ──────────────────────────────────── */

.project-entry {
    padding: 1.6rem 0;
    border-top: 1px solid var(--border);
}

.project-entry:last-child {
    border-bottom: 1px solid var(--border);
}


.project-title {
    font-family: var(--serif);
    font-size: 1.15rem;
    font-weight: 700;
    margin-bottom: 0.4rem;
}

.project-description {
    color: var(--muted);
    font-size: 0.9rem;
    line-height: 1.65;
    margin-bottom: 0.8rem;
}

.project-meta {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-family: var(--mono);
    font-size: 0.7rem;
    color: var(--muted);
    flex-wrap: wrap;
}

/* ── Tags ──────────────────────────────────────── */

.tags {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
}

.tag {
    font-family: var(--mono);
    font-size: 0.65rem;
    letter-spacing: 0.03em;
    color: var(--muted);
    border: 1px solid var(--border);
    padding: 0.1rem 0.45rem;
    border-radius: 2px;
    text-transform: lowercase;
}

a.tag {
    text-decoration: none;
    transition: color 0.15s ease, border-color 0.15s ease;
}

a.tag:hover,
a.tag.tag--active {
    color: var(--accent);
    border-color: var(--accent);
}

.tag-filter {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
    padding: 1rem 0;
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    margin-bottom: 0.25rem;
}

.no-results {
    padding: 1.6rem 0;
    color: var(--muted);
    font-family: var(--mono);
    font-size: 0.8rem;
    border-top: 1px solid var(--border);
}

/* ── 404 ────────────────────────────────────────── */

#not-found {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    padding: 5rem 0 4rem;
}

.not-found-code {
    font-family: var(--mono);
    font-size: 0.78rem;
    letter-spacing: 0.12em;
    color: var(--accent);
    margin-bottom: 1rem;
}

.not-found-heading {
    font-family: var(--serif);
    font-size: clamp(2.25rem, 8vw, 3.5rem);
    font-weight: 700;
    letter-spacing: -0.025em;
    line-height: 1.1;
    margin-bottom: 1.25rem;
}

.not-found-message {
    color: var(--muted);
    font-size: 1rem;
    line-height: 1.75;
    margin-bottom: 2.5rem;
}

.not-found-links {
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.not-found-links a {
    color: var(--text);
    text-decoration: none;
    font-size: 0.95rem;
    border-bottom: 1px solid var(--border);
    padding-bottom: 2px;
    transition: color 0.15s ease, border-color 0.15s ease;
}

.not-found-links a:hover {
    color: var(--accent);
    border-color: var(--accent);
}

/* ── Footer ────────────────────────────────────── */

footer {
    border-top: 1px solid var(--border);
    padding: 2.5rem 0 2rem;
    margin-top: 0.5rem;
}

.footer-grid {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 2rem;
    margin-bottom: 2rem;
}

.footer-brand {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.footer-name {
    font-family: var(--serif);
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text);
}

.footer-tagline {
    font-family: var(--mono);
    font-size: 0.7rem;
    color: var(--muted);
    letter-spacing: 0.04em;
}

.footer-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 1rem;
}

.footer-nav {
    display: flex;
    flex-direction: row;
    gap: 1.5rem;
}

.footer-nav a {
    font-family: var(--mono);
    font-size: 0.72rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--muted);
    text-decoration: none;
    transition: color 0.15s ease;
}

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

.footer-social {
    display: flex;
    flex-direction: row;
    gap: 1rem;
    align-items: center;
}

.footer-social a {
    color: var(--muted);
    text-decoration: none;
    display: flex;
    transition: color 0.15s ease;
}

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

.footer-bottom {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid var(--border);
    padding-top: 1.25rem;
    font-family: var(--mono);
    font-size: 0.65rem;
    color: var(--muted);
}

#footer-theme-toggle {
    font-family: var(--mono);
    font-size: 0.65rem;
    color: var(--muted);
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    transition: color 0.15s ease;
    letter-spacing: 0.04em;
}

#footer-theme-toggle:hover {
    color: var(--accent);
}

@media (max-width: 600px) {
    .footer-grid {
        flex-direction: column;
        gap: 1.5rem;
    }

    .footer-right {
        align-items: flex-start;
    }

    .footer-nav {
        flex-wrap: wrap;
        gap: 0.75rem 1.25rem;
    }
}

/* ── Keyboard hint overlay ─────────────────────── */

#kb-hint {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    font-family: var(--mono);
    font-size: 0.68rem;
    letter-spacing: 0.04em;
    color: var(--bg);
    background: var(--text);
    padding: 0.45rem 0.9rem;
    border-radius: 3px;
    opacity: 0;
    transition: opacity 0.15s ease;
    pointer-events: none;
    z-index: 100;
}

#kb-hint.visible {
    opacity: 1;
}

#kb-hint strong {
    color: var(--accent);
    font-weight: 600;
}

/* ── First-visit keyboard toast ────────────────── */

#kb-toast {
    position: fixed;
    bottom: 1.5rem;
    left: 50%;
    transform: translateX(-50%);
    font-family: var(--mono);
    font-size: 0.68rem;
    letter-spacing: 0.03em;
    color: var(--bg);
    background: var(--text);
    padding: 0.5rem 1.1rem;
    border-radius: 3px;
    white-space: nowrap;
    opacity: 0;
    transition: opacity 0.4s ease;
    pointer-events: none;
    z-index: 100;
}

#kb-toast.visible {
    opacity: 1;
    pointer-events: auto;
}

#kb-toast strong {
    color: var(--accent);
    font-weight: 600;
}

#kb-toast-dismiss {
    background: none;
    border: none;
    color: var(--bg);
    font-family: var(--mono);
    font-size: 0.68rem;
    letter-spacing: 0.03em;
    cursor: pointer;
    opacity: 0.45;
    margin-left: 1rem;
    padding: 0;
    pointer-events: auto;
    transition: opacity 0.15s ease;
}

#kb-toast-dismiss:hover {
    opacity: 1;
}

/* ── Post page ─────────────────────────────────── */

.post {
    padding: 3.5rem 0;
}

.post-back {
    display: inline-block;
    font-family: var(--serif);
    font-size: 0.72rem;
    color: var(--muted);
    text-decoration: none;
    margin-bottom: 2.5rem;
    transition: color 0.15s ease;
}

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

.post-header {
    margin-bottom: 3rem;
    padding-bottom: 2rem;
    border-bottom: 1px solid var(--border);
}

.post-title {
    font-family: var(--serif);
    font-size: clamp(1.75rem, 7vw, 2.4em);
    font-weight: 700;
    line-height: 1.15;
    letter-spacing: -0.025em;
    margin-bottom: 0.65rem;
}

.post-subtitle {
    font-size: 1.25rem;
    font-style: italic;
    color: var(--muted);
    line-height: 1.6;
    margin-bottom: 1.25rem;
    max-width: 560px;
}

.post-meta {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-family: var(--mono);
    font-size: 0.7rem;
    color: var(--muted);
    flex-wrap: wrap;
}

/* ── Post content typography ───────────────────── */

.post-content {
    font-size: 1.05rem;
    line-height: 1.82;
    max-width: 660px;
}

.post-content h1,
.post-content h2 {
    font-family: var(--serif);
    font-size: 1.4rem;
    font-weight: 400;
    letter-spacing: -0.01em;
    margin: 2.75rem 0 1rem;
    padding-left: 0.75rem;
    border-left: 2px solid var(--accent);
}

.post-content h3 {
    font-family: var(--serif);
    font-size: 1.15rem;
    font-weight: 700;
    margin: 2rem 0 0.65rem;
}

.post-content h4 {
    font-family: var(--mono);
    font-size: 0.78rem;
    font-weight: 400;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--muted);
    margin: 1.75rem 0 0.5rem;
}

.post-content p {
    margin-bottom: 1.4rem;
    text-align: justify;
    -webkit-hyphens: auto;
    hyphens: auto;
}

.post-content p:last-child {
    margin-bottom: 0;
}

.post-content ul,
.post-content ol {
    margin: 0 0 1.4rem 1.4rem;
}

.post-content li {
    margin-bottom: 0.4rem;
}

.post-content blockquote {
    border-left: 2px solid var(--border);
    margin: 2rem 0;
    padding: 0.1rem 0 0.1rem 1.25rem;
    color: var(--muted);
    font-style: italic;
}

.post-content blockquote p {
    margin-bottom: 0;
}

.post-content a {
    color: var(--text);
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 3px;
    transition: color 0.15s ease;
}

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

.post-content hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 2.5rem 0;
}

.post-content img {
    max-width: 100%;
    height: auto;
    margin: 1.5rem 0;
    border-radius: 2px;
}

/* Inline code */
.post-content :not(pre) > code {
    font-family: var(--mono);
    font-size: 0.85em;
    background: rgba(212, 200, 180, 0.6);
    background: color-mix(in srgb, var(--border) 60%, transparent);
    padding: 0.15em 0.4em;
    border-radius: 2px;
}

/* Code blocks — pandoc wraps in div.sourceCode > pre > code */
.post-content div.sourceCode {
    margin: 1.75rem 0;
    border: 1px solid var(--border);
    border-radius: 3px;
    overflow-x: auto;
}

.post-content pre.sourceCode {
    margin: 0;
    padding: 1rem 1.25rem;
    overflow-x: auto;
}

.post-content pre.sourceCode > code {
    font-family: var(--mono);
    font-size: 0.875rem;
    line-height: 1.65;
    background: none;
    padding: 0;
}

[data-theme="dark"] .post-content div.sourceCode {
    background-color: #1e1d19;
}

/* color-mix() fallbacks for Safari < 16.2 */
[data-theme="dark"] .post-content :not(pre) > code {
    background: rgba(44, 40, 32, 0.9);
}

[data-theme="dark"] .post-content .b64-playground,
[data-theme="dark"] .post-content .simd-lanes,
[data-theme="dark"] .post-content .bitpack,
[data-theme="dark"] .post-content .bench {
    background: rgba(232, 224, 208, 0.03);
}

/* ── Post TOC ──────────────────────────────────── */

#TOC {
    font-family: var(--mono);
    font-size: 0.7rem;
    line-height: 1.65;
    margin-bottom: 2.5rem;
    padding: 1.1rem 1.25rem;
    border: 1px solid var(--border);
    border-radius: 2px;
}

#TOC::before {
    content: 'on this page';
    display: block;
    font-size: 0.62rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--accent);
    margin-bottom: 0.7rem;
}

#TOC ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

#TOC ul ul {
    padding-left: 1rem;
    margin-top: 0.2rem;
}

#TOC li {
    margin-bottom: 0.25rem;
}

#TOC a {
    color: var(--muted);
    text-decoration: none;
    transition: color 0.15s ease;
}

#TOC a:hover,
#TOC a.toc-active {
    color: var(--accent);
}

@media (min-width: 1260px) {
    #TOC {
        position: fixed;
        top: 7rem;
        left: calc(50% + 380px);
        width: 180px;
        max-height: calc(100vh - 7rem);
        overflow-y: auto;
        padding: 0 0 0 1rem;
        margin-bottom: 0;
        border: none;
        border-left: 1px solid var(--border);
        border-radius: 0;
        background: none;
    }
}

/* Tables */
.post-content table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
    margin: 1.75rem 0;
}

.post-content th,
.post-content td {
    padding: 0.6rem 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.post-content th {
    font-family: var(--mono);
    font-size: 0.72rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted);
}

/* ── Share bar ─────────────────────────────────── */

.share-bar {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    align-items: center;
    padding: 1rem 0;
    border-top: 1px solid var(--border);
}

.share-btn {
    font-family: var(--mono);
    font-size: 0.68rem;
    color: var(--muted);
    background: none;
    border: 1px solid var(--border);
    border-radius: 2px;
    padding: 0.2rem 0.55rem;
    cursor: pointer;
    text-decoration: none;
    transition: color 0.15s ease, border-color 0.15s ease;
    line-height: 1.5;
    display: inline-block;
}

.share-btn:hover {
    color: var(--accent);
    border-color: var(--accent);
}

/* ── HN comments ───────────────────────────────── */

.hn-comments {
    margin-top: 3rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
}

.hn-comments-heading {
    font-family: var(--mono);
    font-size: 0.65rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 1.5rem;
}

.hn-cta {
    display: block;
    width: fit-content;
    margin: 0 auto 1.75rem;
    font-family: var(--mono);
    font-size: 0.7rem;
    color: var(--accent);
    text-decoration: none;
    border: 1px solid var(--accent);
    border-radius: 2px;
    padding: 0.3rem 0.65rem;
    transition: opacity 0.15s ease;
}

.hn-cta:hover {
    opacity: 0.75;
}

.hn-reply {
    color: var(--muted);
    text-decoration: none;
    transition: color 0.15s ease;
}

.hn-reply:hover {
    color: var(--accent);
}

.hn-comment {
    padding: 1rem 0;
    border-top: 1px solid var(--border);
}

.hn-comment:first-child {
    border-top: none;
    padding-top: 0;
}

.hn-comment-meta {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    font-family: var(--mono);
    font-size: 0.65rem;
    color: var(--muted);
    margin-bottom: 0.5rem;
}

.hn-author,
.hn-time {
    color: var(--muted);
    text-decoration: none;
    transition: color 0.15s ease;
}

.hn-author:hover,
.hn-time:hover {
    color: var(--accent);
}

.hn-comment-text {
    font-size: 0.875rem;
    line-height: 1.65;
    color: var(--text);
}

.hn-comment-text a {
    color: var(--accent);
}

.hn-comment-text p {
    margin-bottom: 0.5rem;
}

.hn-comment-text pre {
    font-family: var(--mono);
    font-size: 0.78rem;
    background: var(--border);
    padding: 0.75rem;
    border-radius: 2px;
    overflow-x: auto;
    margin: 0.5rem 0;
}

.hn-loading,
.hn-empty {
    font-family: var(--mono);
    font-size: 0.75rem;
    color: var(--muted);
    padding: 0.5rem 0;
}

.hn-view-all {
    display: inline-block;
    margin-top: 1.25rem;
    font-family: var(--mono);
    font-size: 0.68rem;
    color: var(--muted);
    text-decoration: none;
    transition: color 0.15s ease;
}

.hn-view-all:hover {
    color: var(--accent);
}

/* ── Project timeline ──────────────────────────── */

.project-title a,
.article-title a {
    color: inherit;
    text-decoration: none;
}

.project-title a:hover,
.article-title a:hover {
    color: var(--accent);
}

.timeline-header {
    display: flex;
    justify-content: flex-end;
    margin-top: 2.5rem;
    margin-bottom: 0.75rem;
}

.timeline-order-toggle {
    font-family: var(--mono);
    font-size: 0.78rem;
    color: var(--muted);
    text-decoration: none;
}

.timeline-order-toggle:hover {
    color: var(--accent);
}

.timeline {
    position: relative;
    margin-top: 0;
    padding-left: 1.5rem;
    border-left: 2px solid var(--border);
}

.timeline-entry {
    position: relative;
    padding-bottom: 2.5rem;
}

.timeline-entry:last-child {
    padding-bottom: 0;
}

.timeline-dot {
    position: absolute;
    left: -1.625rem;
    top: 0.35rem;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--border);
    border: 2px solid var(--bg);
    box-sizing: border-box;
}

.timeline-date {
    display: block;
    font-family: var(--mono);
    font-size: 0.78rem;
    color: var(--muted);
    margin-bottom: 0.6rem;
}

.timeline-content {
    margin-top: 0;
}

/* Blog post preview card inside a timeline entry */
.timeline-post-card {
    display: block;
    text-decoration: none;
    color: inherit;
    border: 1px solid var(--border);
    padding: 1rem 1.25rem;
    border-radius: 2px;
    transition: border-color 0.15s;
}

.timeline-post-card:hover {
    border-color: var(--accent);
}

.timeline-post-title {
    font-family: var(--serif);
    font-size: 1.05rem;
    font-weight: 400;
    margin-bottom: 0.3rem;
    color: var(--text);
}

.timeline-post-subtitle {
    font-size: 0.9rem;
    color: var(--muted);
    margin-bottom: 0.5rem;
}

.timeline-post-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.4rem;
    font-family: var(--mono);
    font-size: 0.78rem;
    color: var(--muted);
}

/* ── Analytics dashboard ────────────────────────── */

.stat-page-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-range-links {
    display: flex;
    gap: 0.5rem;
}

.stat-cards {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin-bottom: 2.5rem;
}

.stat-card {
    border: 1px solid var(--border);
    padding: 1rem 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.stat-card-value {
    font-family: var(--serif);
    font-size: 1.6rem;
    font-weight: 700;
    line-height: 1;
}

.stat-card-label {
    font-family: var(--mono);
    font-size: 0.72rem;
    color: var(--muted);
}

.stat-section {
    margin-bottom: 2.5rem;
}

.stat-section-title {
    font-family: var(--mono);
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
    margin-bottom: 1rem;
}

.stat-two-col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2.5rem;
}

.stat-row {
    margin-bottom: 0.85rem;
}

.stat-row-top {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 0.5rem;
    margin-bottom: 0.25rem;
}

.stat-row-label {
    font-family: var(--mono);
    font-size: 0.78rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 75%;
}

.stat-row-count {
    font-family: var(--mono);
    font-size: 0.78rem;
    color: var(--muted);
    white-space: nowrap;
}

.stat-row-meta {
    display: flex;
    gap: 1rem;
    font-family: var(--mono);
    font-size: 0.7rem;
    color: var(--muted);
    margin-top: 0.2rem;
}

.stat-bar-track {
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    overflow: hidden;
}

.stat-bar-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 2px;
}

.stat-bar-fill--muted {
    background: var(--muted);
    opacity: 0.5;
}

.stat-cards--server {
    margin-top: 0.75rem;
    opacity: 0.8;
}

.stat-cards--server .stat-card {
    border-style: dashed;
}

.stat-cards--server .stat-card-value {
    font-size: 1.2rem;
}

.stat-server-note {
    font-family: var(--mono);
    font-size: 0.7rem;
    color: var(--muted);
    margin-bottom: 2.5rem;
    margin-top: 0.5rem;
}

.stat-server-tag {
    color: var(--muted);
}

/* Views-per-day sparkline */
.stat-sparkline {
    display: flex;
    align-items: flex-end;
    gap: 2px;
    height: 80px;
    margin-bottom: 0.4rem;
}

.stat-spark-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    height: 80px;
    cursor: default;
}

.stat-spark-bar {
    width: 100%;
    background: var(--accent);
    opacity: 0.7;
    border-radius: 1px 1px 0 0;
    transition: opacity 0.1s;
}

.stat-spark-col:hover .stat-spark-bar {
    opacity: 1;
}

.stat-sparkline-labels {
    display: flex;
    justify-content: space-between;
    font-family: var(--mono);
    font-size: 0.7rem;
    color: var(--muted);
}

#spark-tip {
    font-weight: 400;
    text-transform: none;
    letter-spacing: 0;
    color: var(--muted);
    margin-left: .75rem;
}

.stat-cards--three {
    grid-template-columns: repeat(3, 1fr);
}

.stat-section-title--mt {
    margin-top: 2rem;
}

.stat-dim {
    opacity: .45;
}

.stat-no-data {
    margin-top: 3rem;
}

/* Analytics login page */
.stat-login-wrap {
    max-width: 360px;
    margin-top: 6rem;
}

.stat-login-title {
    margin-bottom: 1.5rem;
}

.stat-login-error {
    color: var(--accent);
    font-family: var(--mono);
    font-size: .85rem;
    margin-bottom: 1rem;
}

.stat-login-input {
    width: 100%;
    padding: .6rem .75rem;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
    font-family: var(--mono);
    font-size: .9rem;
    margin-bottom: .75rem;
    outline: none;
}

.stat-login-btn {
    width: 100%;
    padding: .6rem;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
    font-family: var(--mono);
    font-size: .9rem;
    cursor: pointer;
}

/* ── Responsive ────────────────────────────────── */

@media (max-width: 560px) {

    /* Global */
    body {
        padding: 0 1.1rem;
    }

    button, a {
        touch-action: manipulation;
    }

    /* Nav — hamburger */
    #nav-toggle {
        display: flex;
    }

    .nav-right {
        gap: 1.25rem;
    }

    .nav-links {
        display: none;
        position: absolute;
        top: 100%;
        left: -1.1rem;
        right: -1.1rem;
        background: var(--bg);
        border-bottom: 1px solid var(--border);
        flex-direction: column;
        gap: 0;
        z-index: 50;
        padding: 0.25rem 0;
    }

    nav {
        position: relative;
    }

    nav.nav-open .nav-links {
        display: flex;
    }

    .nav-links li {
        border-top: 1px solid var(--border);
    }

    .nav-links a {
        display: block;
        padding: 0.85rem 1.1rem;
        font-size: 0.9rem;
    }

    /* Keyboard hints — irrelevant on touch */
    #kb-hint,
    #kb-toast,
    .footer-kb {
        display: none;
    }

    /* Layout */
    .section-header {
        flex-direction: column;
        gap: 0.4rem;
    }

    .footer-inner {
        flex-direction: column;
        gap: 0.5rem;
        text-align: center;
    }

    /* Post */
    .post-header {
        padding-bottom: 1.25rem;
    }

    .post-meta {
        flex-wrap: wrap;
    }

    .post-content table {
        display: block;
        overflow-x: auto;
    }

    /* Share bar */
    .share-bar {
        gap: 0.4rem;
    }

    .share-btn {
        padding: 0.35rem 0.65rem;
        font-size: 0.72rem;
    }

    /* Tags */
    .tag-filter {
        gap: 0.4rem;
    }

    /* Timeline (project page) */
    .timeline {
        padding-left: 1rem;
    }

    .timeline-dot {
        left: -1.35rem;
    }

    /* HN comments */
    .hn-comment-meta {
        flex-wrap: wrap;
        gap: 0.3rem;
    }

    /* Analytics dashboard */
    .stat-page-header {
        flex-direction: column;
        gap: 0.75rem;
    }

    .stat-cards {
        grid-template-columns: repeat(2, 1fr);
    }

    .stat-two-col {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 380px) {
    .stat-cards {
        grid-template-columns: 1fr;
    }
}

/* ── Section dots ───────────────────────────────────────── */

#section-dots {
    position: fixed;
    top: 50%;
    right: 1.75rem;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 50;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

#section-dots.dots-visible {
    opacity: 1;
    pointer-events: auto;
}

.sdot {
    display: block;
    border-radius: 50%;
    background: var(--border);
    transition: background 0.15s ease, transform 0.15s ease;
    text-decoration: none;
}

.sdot--h2 {
    width: 8px;
    height: 8px;
}

.sdot--h3 {
    width: 6px;
    height: 6px;
    align-self: flex-end;
    margin-right: 1px;
}

.sdot--active {
    background: var(--accent);
    transform: scale(1.35);
}

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

/* ── Back to top ────────────────────────────────────────── */

#back-to-top {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    width: 2.25rem;
    height: 2.25rem;
    background: var(--text);
    color: var(--bg);
    border: none;
    border-radius: 50%;
    font-size: 1rem;
    line-height: 1;
    cursor: pointer;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, background 0.15s ease;
    z-index: 90;
    display: flex;
    align-items: center;
    justify-content: center;
}

#back-to-top.visible {
    opacity: 1;
    pointer-events: auto;
}

#back-to-top:hover {
    background: var(--accent);
}

/* ── Reduced motion ─────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
    }

    html {
        scroll-behavior: auto;
    }
}

/* ── Post visualizations: callout ───────────────────────── */

.post-content .callout {
    border-left: 3px solid var(--accent);
    background: rgba(255, 93, 13, 0.08);
    background: color-mix(in srgb, var(--accent) 8%, transparent);
    padding: 0.85rem 1.1rem;
    margin: 1.75rem 0;
    font-size: 0.95rem;
    border-radius: 0 4px 4px 0;
}

/* ── Post visualizations: base64 playground ─────────────── */

.post-content .b64-playground {
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 1.25rem;
    margin: 1.75rem 0;
    background: rgba(30, 26, 20, 0.03);
    background: color-mix(in srgb, var(--text) 3%, transparent);
}

.b64-label {
    display: block;
    font-family: var(--mono);
    font-size: 0.7rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 0.4rem;
}

.post-content #b64-input {
    width: 100%;
    font-family: var(--mono);
    font-size: 1rem;
    padding: 0.55rem 0.75rem;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text);
    border-radius: 3px;
    margin-bottom: 1rem;
}

.post-content #b64-input:focus {
    outline: 2px solid var(--accent);
    outline-offset: -1px;
    border-color: transparent;
}

.b64-row {
    display: grid;
    grid-template-columns: 100px 1fr;
    gap: 0.75rem;
    align-items: center;
    margin-bottom: 0.6rem;
    min-height: 1.8rem;
}

.b64-tag {
    font-family: var(--mono);
    font-size: 0.65rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
}

.b64-bits, .b64-output {
    font-family: var(--mono);
    font-size: 0.78rem;
    display: flex;
    flex-wrap: wrap;
    gap: 2px;
    word-break: break-all;
}

.b64-chunk {
    color: #fff;
    padding: 2px 4px;
    border-radius: 2px;
    letter-spacing: 0.02em;
}

.b64-char {
    color: #fff;
    padding: 4px 7px;
    border-radius: 2px;
    font-size: 0.95rem;
    font-weight: 600;
    min-width: 1.2rem;
    text-align: center;
}

.b64-char--pad {
    background: var(--border) !important;
    color: var(--muted);
}

/* ── Post visualizations: SIMD lanes ────────────────────── */

.post-content .simd-lanes,
.post-content .bitpack,
.post-content .bench {
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 1.1rem;
    margin: 1.75rem 0;
    background: rgba(30, 26, 20, 0.03);
    background: color-mix(in srgb, var(--text) 3%, transparent);
}

.simd-controls, .bitpack-controls {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    margin-bottom: 0.75rem;
}

.simd-controls button,
.bitpack-controls button,
#bench-run {
    font-family: var(--mono);
    font-size: 0.75rem;
    letter-spacing: 0.04em;
    background: var(--text);
    color: var(--bg);
    border: none;
    padding: 0.4rem 0.85rem;
    border-radius: 3px;
    cursor: pointer;
    transition: background 0.15s ease;
}

.simd-controls button:hover,
.bitpack-controls button:hover,
#bench-run:hover {
    background: var(--accent);
}

#bench-run:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.simd-status, .bitpack-step {
    font-family: var(--mono);
    font-size: 0.7rem;
    color: var(--muted);
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

#simd-canvas, #bitpack-canvas, #bench-canvas {
    display: block;
    max-width: 100%;
    height: auto;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}

.bench-results {
    margin-top: 0.85rem;
    font-size: 0.9rem;
    color: var(--muted);
    font-style: italic;
}

.bench-results strong {
    color: var(--accent);
    font-style: normal;
    font-family: var(--mono);
}

/* ── Post visualizations: tighten tables in posts ───────── */

.post-content table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.92rem;
    margin: 1.5rem 0;
}

.post-content th, .post-content td {
    text-align: left;
    padding: 0.45rem 0.75rem;
    border-bottom: 1px solid var(--border);
    font-family: var(--mono);
    font-size: 0.82rem;
}

.post-content th {
    color: var(--muted);
    font-weight: 500;
    font-size: 0.7rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}
