/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    overflow-x: hidden;
    width: 100%;
}

/* Light Mode (Default) — warm paper ground, indigo/amber brand duotone */
:root {
    --primary-color: #4f46e5;
    --primary-color-strong: #4338ca;
    --accent-color: #ea8600;
    --text-color: #1b1b23;
    --text-secondary: #625f72;
    --bg-color: #fcfbf8;
    --bg-secondary: #f3f1ec;
    --bg-raised: #ffffff;
    --border-color: #e6e2d8;
    --code-bg: #1c1a2e;
    --max-width: 1200px;
    --selection-bg: #fbbf24;
    --selection-text: #1b1b23;
    --table-header-bg: #4f46e5;
    --table-header-text: #ffffff;
    --table-row-even: #f3f1ec;
    --table-row-hover: #ece9ff;
    --gradient-brand: linear-gradient(135deg, #4f46e5 0%, #7c3aed 55%, #ea8600 100%);
    --gradient-brand-soft: linear-gradient(135deg, rgba(79, 70, 229, 0.10), rgba(234, 134, 0, 0.08));
    --grid-line: rgba(27, 27, 35, 0.055);
}

/* Dark Mode — deep indigo-black ground, luminous accent duotone */
[data-theme="dark"] {
    --primary-color: #a5b4fc;
    --primary-color-strong: #c7d2fe;
    --accent-color: #fbbf24;
    --text-color: #f1f0f7;
    --text-secondary: #a29fb5;
    --bg-color: #0a0a14;
    --bg-secondary: #14131f;
    --bg-raised: #191828;
    --border-color: #29273d;
    --code-bg: #0a0918;
    --selection-bg: #fbbf24;
    --selection-text: #0a0a14;
    --table-header-bg: #4338ca;
    --table-header-text: #f1f0f7;
    --table-row-even: #14131f;
    --table-row-hover: #211f36;
    --gradient-brand: linear-gradient(135deg, #818cf8 0%, #a78bfa 55%, #fbbf24 100%);
    --gradient-brand-soft: linear-gradient(135deg, rgba(129, 140, 248, 0.16), rgba(251, 191, 36, 0.10));
    --grid-line: rgba(241, 240, 247, 0.06);
}

/* Custom Text Selection - Fun gradient effect! */
::selection {
    background: var(--selection-bg);
    color: var(--selection-text);
    text-shadow: none;
}

::-moz-selection {
    background: var(--selection-bg);
    color: var(--selection-text);
    text-shadow: none;
}

body {
    font-family: 'Space Grotesk', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
    color: var(--text-color);
    background-color: var(--bg-color);
    transition: background-color 0.3s ease, color 0.3s ease;
    max-width: 100vw;
    /* Keep content clear of the notch/rounded corners on edge-to-edge
       phones in landscape (viewport-fit=cover is set in baseof.html). */
    padding-left: env(safe-area-inset-left, 0px);
    padding-right: env(safe-area-inset-right, 0px);
}

code, pre {
    font-family: 'Fira Code', 'Courier New', monospace;
}

a, button {
    -webkit-tap-highlight-color: rgba(79, 70, 229, 0.15);
}

/* Container */
.container {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 2rem;
    width: 100%;
}

/* Header */
.site-header {
    background-color: color-mix(in srgb, var(--bg-color) 88%, transparent);
    backdrop-filter: blur(10px) saturate(1.4);
    -webkit-backdrop-filter: blur(10px) saturate(1.4);
    border-bottom: 1px solid var(--border-color);
    padding: 1.5rem 0;
    position: sticky;
    top: 0;
    z-index: 100;
}

.site-header::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: -1px;
    height: 2px;
    background: var(--gradient-brand);
    opacity: 0.55;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Theme Toggle Button - Static sun/moon icon */
.theme-toggle-button {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
    border: none;
    background-color: transparent;
    color: var(--text-color);
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.3s ease;
}

.theme-toggle-button:hover {
    background-color: var(--bg-secondary);
    transform: scale(1.1);
}

.theme-toggle-button:active {
    transform: scale(0.95);
}

/* Show sun icon in light mode, hide moon icon */
.theme-toggle-button .sun-icon {
    display: block;
}

.theme-toggle-button .moon-icon {
    display: none;
}

/* Show moon icon in dark mode, hide sun icon */
[data-theme="dark"] .theme-toggle-button .sun-icon {
    display: none;
}

[data-theme="dark"] .theme-toggle-button .moon-icon {
    display: block;
}

.site-title {
    font-size: 1.5rem;
    font-weight: 700;
}

.site-title a {
    color: var(--text-color);
    text-decoration: none;
}

.main-nav {
    display: flex;
    gap: 2rem;
    align-items: center;
    flex-wrap: wrap;
    position: relative;
}

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

.nav-actions {
    display: flex;
    gap: 0.25rem;
    align-items: center;
}

.main-nav a {
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s;
    display: flex;
    align-items: center;
    white-space: nowrap;
    position: relative;
}

.main-nav .nav-links a::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: -4px;
    height: 2px;
    border-radius: 2px;
    background: var(--gradient-brand);
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 0.22s ease;
}

.main-nav a:hover {
    color: var(--primary-color);
}

.main-nav .nav-links a:hover::after {
    transform: scaleX(1);
}

/* Hamburger toggle - hidden on desktop, shown once JS proves the menu
   collapses (see .main-nav.has-js below). Without JS, the links stay
   inline/stacked and fully usable, so nothing behind a click is lost. */
.nav-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    padding: 0;
    border: none;
    background: transparent;
    color: var(--text-color);
    cursor: pointer;
    border-radius: 8px;
    position: relative;
}

.nav-toggle:hover {
    background-color: var(--bg-secondary);
}

.nav-toggle-icon {
    position: absolute;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.nav-toggle .icon-close {
    opacity: 0;
    transform: rotate(-90deg);
}

.nav-toggle[aria-expanded="true"] .icon-menu {
    opacity: 0;
    transform: rotate(90deg);
}

.nav-toggle[aria-expanded="true"] .icon-close {
    opacity: 1;
    transform: rotate(0);
}

/* Main Content */
.main-content {
    min-height: calc(100vh - 200px);
    padding: 3rem 0;
    max-width: 100%;
    overflow-x: hidden;
}

/* Hero Section */
.hero {
    position: relative;
    text-align: center;
    padding: 4.5rem 1.5rem 4rem;
    margin: 0.5rem 0 3.5rem;
    border-radius: 28px;
    overflow: hidden;
    max-width: 100%;
    isolation: isolate;
}

.hero::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -2;
    background-color: var(--bg-secondary);
    background-image:
        linear-gradient(var(--grid-line) 1px, transparent 1px),
        linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
    background-size: 40px 40px;
    -webkit-mask-image: radial-gradient(ellipse 80% 65% at 50% 30%, #000 45%, transparent 100%);
    mask-image: radial-gradient(ellipse 80% 65% at 50% 30%, #000 45%, transparent 100%);
}

.hero::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    background: var(--gradient-brand-soft);
}

.hero-kicker {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--primary-color);
    margin-bottom: 1.25rem;
}

.hero-kicker::before,
.hero-kicker::after {
    content: "";
    width: 1.5rem;
    height: 1px;
    background: currentColor;
    opacity: 0.5;
}

.hero h2 {
    font-size: 3.1rem;
    font-weight: 700;
    line-height: 1.12;
    letter-spacing: -0.02em;
    margin-bottom: 1.1rem;
    color: var(--text-color);
    text-wrap: balance;
}

.hero h2 .hero-accent {
    background: var(--gradient-brand);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.hero-subtitle {
    font-size: 1.25rem;
    color: var(--text-secondary);
    max-width: 42rem;
    margin: 0 auto;
}

/* Section Titles */
.section-title {
    position: relative;
    font-size: 1.875rem;
    font-weight: 700;
    margin-bottom: 2rem;
    padding-left: 1.1rem;
    color: var(--text-color);
    max-width: 100%;
}

.section-title::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0.15em;
    bottom: 0.15em;
    width: 5px;
    border-radius: 3px;
    background: var(--gradient-brand);
}

/* Posts Grid */
.posts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(350px, 100%), 1fr));
    gap: 2rem;
    margin-bottom: 3rem;
}

.post-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1.5rem;
    transition: transform 0.2s, box-shadow 0.2s;
    max-width: 100%;
    box-sizing: border-box;
}

.post-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.post-card-image-link {
    display: block;
    margin: -1.5rem -1.5rem 1rem -1.5rem;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    border-radius: 8px 8px 0 0;
    background: var(--border-color);
}

.post-card-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.3s ease;
}

.post-card-has-image:hover .post-card-image {
    transform: scale(1.05);
}

.post-meta {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
}

.post-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
}

.post-title a {
    color: var(--text-color);
    text-decoration: none;
}

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

.post-summary {
    color: var(--text-secondary);
    margin-bottom: 1rem;
    line-height: 1.6;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 5;
    -webkit-box-orient: vertical;
}

.post-summary code,
.post-summary pre {
    display: none;
}


.read-more {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
    display: inline-block;
}

.read-more:hover {
    text-decoration: underline;
}

/* Single Post */
.post-single {
    max-width: 800px;
    margin: 0 auto;
    width: 100%;
}

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

.post-single .post-title {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 1rem;
    line-height: 1.2;
}

.post-single .post-meta {
    font-size: 1rem;
}

.post-author {
    font-weight: 500;
    color: var(--text-color);
}

.meta-separator {
    margin: 0 0.5rem;
    color: var(--text-secondary);
}

.article-feedback {
    margin-top: 3rem;
    padding: 1.5rem;
    background-color: var(--bg-secondary);
    border-left: 4px solid var(--primary-color);
    border-radius: 4px;
}

.article-feedback p {
    margin: 0;
    font-size: 1rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

.article-feedback a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
}

.article-feedback a:hover {
    text-decoration: underline;
}

.post-content {
    font-size: 1.125rem;
    line-height: 1.8;
    overflow-wrap: break-word;
    word-wrap: break-word;
}

.post-content h2 {
    font-size: 1.875rem;
    font-weight: 700;
    margin-top: 2.5rem;
    margin-bottom: 1rem;
}

.post-content h3 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-top: 2rem;
    margin-bottom: 0.75rem;
}

.post-content p {
    margin-bottom: 1.25rem;
}

.post-content ul, .post-content ol {
    margin-bottom: 1.25rem;
    margin-left: 2rem;
}

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

.post-content code {
    background-color: var(--bg-secondary);
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    font-size: 0.9em;
}

.post-content pre {
    background-color: var(--code-bg);
    color: #e2e8f0;
    padding: 1.5rem;
    border-radius: 8px;
    overflow-x: auto;
    margin-bottom: 1.25rem;
    max-width: 100%;
}

.post-content pre code {
    background: none;
    padding: 0;
}

.post-content blockquote {
    border-left: 4px solid var(--primary-color);
    padding-left: 1.5rem;
    margin: 1.5rem 0;
    font-style: italic;
    color: var(--text-secondary);
}

.post-content a {
    color: var(--primary-color);
    text-decoration: none;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.post-content a:hover {
    text-decoration: underline;
}

.post-content img {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 1rem auto;
    /* Prevent layout shift for images without explicit dimensions */
    aspect-ratio: attr(width) / attr(height);
}

/* Article images with captions (Unsplash attribution) */
.post-content figure.article-image {
    margin: 2rem auto;
    max-width: 100%;
}

.post-content figure.article-image img {
    margin: 0 auto;
    border-radius: 8px;
    /* Ensure proper aspect ratio handling */
    width: 100%;
    height: auto;
}

.post-content figure.article-image figcaption {
    text-align: center;
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-top: 0.75rem;
    line-height: 1.5;
}

.post-content figure.article-image figcaption a {
    color: var(--text-secondary);
    text-decoration: none;
    border-bottom: 1px dotted var(--text-secondary);
}

.post-content figure.article-image figcaption a:hover {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

/* Posts List */
.posts-list {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.post-item {
    padding: 1.5rem 0;
    border-bottom: 1px solid var(--border-color);
}

.post-item:last-child {
    border-bottom: none;
}

.archive-title {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 2rem;
}

/* Tags */
.post-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.tag {
    display: inline-block;
    padding: 0.35rem 0.85rem;
    background: var(--accent-soft);
    color: var(--primary-color-strong);
    border: 1px solid var(--accent-border);
    border-radius: 20px;
    font-size: 0.875rem;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.2s ease;
}

.tag:hover {
    background: var(--gradient-brand);
    border-color: transparent;
    transform: translateY(-1px);
    color: #ffffff;
}

.tag-active {
    background: var(--gradient-brand);
    border-color: transparent;
    color: #ffffff;
}

[data-theme="dark"] .tag {
    color: var(--primary-color-strong);
}

.tag-description {
    color: var(--text-secondary);
    margin-bottom: 2rem;
    font-size: 1rem;
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 3rem;
}

.page-link {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    text-decoration: none;
    color: var(--text-color);
    background-color: var(--bg-color);
    transition: all 0.2s;
}

.page-link:hover:not(.disabled):not(.active) {
    background-color: var(--bg-secondary);
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.page-link.active {
    background-color: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    font-weight: 600;
}

.page-link.disabled {
    background-color: var(--bg-secondary);
    color: var(--text-secondary);
    cursor: not-allowed;
    opacity: 0.5;
}

.page-link.ellipsis {
    border: none;
    background: none;
    cursor: default;
    padding: 0.5rem 0.5rem;
}

.page-link.ellipsis:hover {
    background: none;
    border: none;
    color: var(--text-color);
}

/* Legacy pagination support */
.pagination a, .pagination span {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    text-decoration: none;
    color: var(--text-color);
}

.pagination a:hover {
    background-color: var(--bg-secondary);
}

.pagination .active {
    background-color: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

/* Footer */
.site-footer {
    background-color: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    padding: 2rem 0 calc(2rem + env(safe-area-inset-bottom, 0px));
    text-align: center;
    margin-top: 4rem;
}

.site-footer p {
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.footer-note {
    font-size: 0.875rem;
    font-style: italic;
}

.footer-links {
    margin-top: 1rem;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
}

.footer-text-link {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.875rem;
    transition: color 0.2s ease;
}

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

.rss-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--text-color);
    text-decoration: none;
    padding: 0.5rem;
    border-radius: 0.375rem;
    transition: all 0.2s ease;
    border: 1px solid var(--border-color);
    background-color: var(--bg-secondary);
}

.rss-link:hover {
    color: var(--primary-color);
    border-color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.rss-link svg {
    width: 20px;
    height: 20px;
    stroke: currentColor;
}

/* Footer links with labels */
.footer-link-with-label {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-color);
    text-decoration: none;
    padding: 0.5rem 0.75rem;
    border-radius: 0.375rem;
    transition: all 0.2s ease;
    border: 1px solid var(--border-color);
    background-color: var(--bg-secondary);
    font-size: 0.875rem;
}

.footer-link-with-label:hover {
    color: var(--primary-color);
    border-color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.footer-link-with-label svg {
    width: 18px;
    height: 18px;
    stroke: currentColor;
    flex-shrink: 0;
}

.footer-link-text {
    font-weight: 500;
}


/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 0 1rem;
        max-width: 100%;
    }

    /* The header used to drop sticky positioning on mobile because the
       stacked, multi-row nav ate too much screen. With the nav collapsed
       behind a hamburger it's back to a single compact row, so keeping it
       sticky is worth it - it's how users get back to search/menu without
       scrolling to the top of a long article. */
    .site-header {
        position: sticky;
        padding-top: calc(1rem + env(safe-area-inset-top, 0px));
        padding-bottom: 1rem;
    }

    .header-content {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        gap: 0.5rem;
    }

    .main-nav {
        gap: 0.25rem;
        justify-content: flex-end;
        width: auto;
    }

    .main-nav a {
        font-size: 0.9rem;
    }

    .theme-toggle-button {
        width: 44px;
        height: 44px;
    }

    /* No-JS fallback: keep every link inline/wrapping and centered, same
       as the menu always behaved before the hamburger was added. */
    .main-nav:not(.has-js) {
        flex-wrap: wrap;
        justify-content: center;
    }

    .main-nav:not(.has-js) .nav-links {
        order: 2;
        width: 100%;
        justify-content: center;
    }

    .main-nav:not(.has-js) .nav-actions {
        order: 1;
        width: 100%;
        justify-content: center;
    }

    /* With JS: the hamburger shows and the link list becomes a dropdown
       anchored to the (positioned, sticky) site-header. */
    .main-nav.has-js .nav-toggle {
        display: flex;
    }

    .main-nav.has-js .nav-links {
        position: absolute;
        left: 0;
        right: 0;
        top: calc(100% + 1rem);
        flex-direction: column;
        align-items: stretch;
        gap: 0;
        background-color: var(--bg-color);
        border-bottom: 1px solid var(--border-color);
        box-shadow: 0 12px 24px -8px rgba(0, 0, 0, 0.15);
        max-height: 0;
        overflow: hidden;
        opacity: 0;
        visibility: hidden;
        transition: max-height 0.25s ease, opacity 0.2s ease, visibility 0.25s;
    }

    .main-nav.has-js .nav-links.is-open {
        max-height: 320px;
        opacity: 1;
        visibility: visible;
        padding-bottom: env(safe-area-inset-bottom, 0px);
    }

    .main-nav.has-js .nav-links a {
        padding: 0.9rem 1.5rem;
        border-top: 1px solid var(--border-color);
        width: 100%;
        font-size: 1rem;
    }

    .hero {
        padding: 2.75rem 1.25rem 2.5rem;
        border-radius: 20px;
    }

    .hero h2 {
        font-size: 2rem;
        word-wrap: break-word;
    }

    .hero-kicker {
        font-size: 0.7rem;
    }

    .posts-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
        max-width: 100%;
    }

    .post-card {
        max-width: 100%;
        box-sizing: border-box;
    }

    .post-single {
        max-width: 100%;
    }

    .post-single .post-title {
        font-size: 2rem;
        word-wrap: break-word;
        overflow-wrap: break-word;
    }

    .post-content {
        font-size: 1rem;
    }

    .post-content pre {
        padding: 1rem;
        border-radius: 6px;
        font-size: 0.875rem;
    }

    /* Mobile-friendly pagination */
    .pagination {
        gap: 0.25rem;
        flex-wrap: wrap;
    }

    .page-link {
        padding: 0.4rem 0.7rem;
        font-size: 0.9rem;
    }

    .page-link.ellipsis {
        padding: 0.4rem 0.4rem;
    }
}

/* Extra small mobile devices */
@media (max-width: 400px) {
    .container {
        padding: 0 0.75rem;
    }

    .main-nav {
        gap: 0.75rem;
    }

    .main-nav a {
        font-size: 0.85rem;
    }

    .hero h2 {
        font-size: 1.75rem;
    }

    .hero-subtitle {
        font-size: 1rem;
    }

    .post-card {
        padding: 1rem;
    }

    .post-single .post-title {
        font-size: 1.75rem;
    }

    .post-content {
        font-size: 0.95rem;
    }

    .post-content h2 {
        font-size: 1.5rem;
    }

    .post-content h3 {
        font-size: 1.25rem;
    }
}

/* Enhanced Table Styling */
.post-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 2rem 0;
    background-color: var(--bg-color);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    border-radius: 8px;
    /* Allow horizontal scrolling when table is too wide */
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
}

/* Restore proper table display for all child elements */
.post-content table > thead,
.post-content table > tbody,
.post-content table > tfoot {
    display: table-row-group;
}

.post-content table > thead {
    display: table-header-group;
}

.post-content table > tfoot {
    display: table-footer-group;
}

.post-content table > thead > tr,
.post-content table > tbody > tr,
.post-content table > tfoot > tr {
    display: table-row;
}

.post-content table > thead > tr > th,
.post-content table > thead > tr > td,
.post-content table > tbody > tr > th,
.post-content table > tbody > tr > td,
.post-content table > tfoot > tr > th,
.post-content table > tfoot > tr > td {
    display: table-cell;
}

.post-content table thead {
    background: linear-gradient(135deg, var(--table-header-bg), var(--primary-color-strong));
    color: var(--table-header-text);
}

.post-content table th {
    padding: 1rem;
    text-align: left;
    font-weight: 600;
    font-size: 0.95rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 3px solid var(--primary-color);
}

.post-content table td {
    padding: 0.875rem 1rem;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-color);
    font-size: 0.95rem;
}

.post-content table tbody tr {
    transition: background-color 0.2s ease;
}

.post-content table tbody tr:nth-child(even) {
    background-color: var(--table-row-even);
}

.post-content table tbody tr:hover {
    background-color: var(--table-row-hover);
    transform: scale(1.01);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.post-content table tbody tr:last-child td {
    border-bottom: none;
}

/* Table cell with strong emphasis */
.post-content table td strong {
    color: var(--primary-color);
    font-weight: 600;
}

/* Search Button in Navigation */
.search-button {
    background: none;
    border: none;
    color: var(--text-color);
    cursor: pointer;
    padding: 0.75rem;
    min-width: 48px;
    min-height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.3s ease, transform 0.2s ease;
    border-radius: 4px;
}

.search-button:hover {
    color: var(--primary-color);
    transform: scale(1.1);
}

.search-button svg {
    width: 20px;
    height: 20px;
}

/* Search Modal */
.search-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    display: none;
    align-items: flex-start;
    justify-content: center;
    z-index: 1000;
    padding-top: 10vh;
    backdrop-filter: blur(4px);
}

.search-modal.active {
    display: flex;
}

.search-modal-content {
    background-color: var(--bg-color);
    border-radius: 12px;
    width: 90%;
    max-width: 700px;
    max-height: 80vh;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Search Input Wrapper */
.search-input-wrapper {
    display: flex;
    align-items: center;
    padding: 1.25rem;
    gap: 0.75rem;
}

.search-icon {
    color: var(--text-secondary);
    flex-shrink: 0;
}

#search-input {
    flex: 1;
    border: none;
    background: none;
    font-size: 1.1rem;
    color: var(--text-color);
    outline: none;
    font-family: inherit;
}

#search-input::placeholder {
    color: var(--text-secondary);
}

.close-search {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.75rem;
    min-width: 48px;
    min-height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.close-search:hover {
    background-color: var(--bg-secondary);
    color: var(--text-color);
}

/* Search Results */
.search-results {
    overflow-y: auto;
    max-height: calc(80vh - 80px);
    padding: 0.5rem;
}

.search-result-item {
    display: block;
    padding: 1rem;
    border-radius: 8px;
    text-decoration: none;
    color: var(--text-color);
    transition: background-color 0.2s ease, transform 0.2s ease;
    margin-bottom: 0.5rem;
}

.search-result-item:hover {
    background-color: var(--bg-secondary);
    transform: translateX(4px);
}

.search-result-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--primary-color);
}

.search-result-summary {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: 0.5rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.search-result-meta {
    display: flex;
    align-items: center;
    gap: 1rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.search-result-date {
    flex-shrink: 0;
}

.search-result-tags {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.search-result-tag {
    background-color: var(--bg-secondary);
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-size: 0.8rem;
}

.no-results {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-secondary);
    font-size: 1.1rem;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .search-modal {
        padding-top: 5vh;
    }
    
    .search-modal-content {
        width: 95%;
        max-height: 85vh;
    }
    
    .search-input-wrapper {
        padding: 1rem;
    }
    
    #search-input {
        font-size: 1rem;
    }
}

/* Highlight mark style for search results */
mark {
    background-color: #fbbf24;
    color: #1f2937;
    padding: 0 2px;
    border-radius: 2px;
}

[data-theme="dark"] mark {
    background-color: #f59e0b;
    color: #111827;
}

/* ========================================
   Diagram Styling - Mermaid & GoAT
   ======================================== */

/* Mermaid Diagram Container */
.post-content .mermaid {
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 2.5rem 0;
    padding: 2rem;
    background: linear-gradient(135deg, var(--bg-secondary) 0%, var(--bg-color) 100%);
    border-radius: 12px;
    border: 2px solid var(--border-color);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1), 0 1px 3px rgba(0, 0, 0, 0.08);
    transition: all 0.3s ease;
    overflow-x: auto;
    min-height: 200px;
    max-width: 100%;
}

.post-content .mermaid:hover {
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.15), 0 3px 6px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

/* Mermaid SVG styling */
.post-content .mermaid svg {
    max-width: 100%;
    height: auto;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}

/* Dark mode adjustments for Mermaid */
[data-theme="dark"] .post-content .mermaid {
    background: linear-gradient(135deg, var(--bg-secondary) 0%, #0f172a 100%);
    border-color: #374151;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3), 0 1px 3px rgba(0, 0, 0, 0.2);
}

[data-theme="dark"] .post-content .mermaid:hover {
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.4), 0 3px 6px rgba(0, 0, 0, 0.3);
}

/* GoAT Diagram Container */
.post-content .goat-svg {
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 2.5rem 0;
    padding: 2rem;
    background: linear-gradient(135deg, #f8fafc 0%, #ffffff 100%);
    border-radius: 12px;
    border: 2px solid #e2e8f0;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1), 0 1px 3px rgba(0, 0, 0, 0.08);
    transition: all 0.3s ease;
    max-width: 100%;
    overflow-x: auto;
}

.post-content .goat-svg:hover {
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.15), 0 3px 6px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

/* GoAT SVG styling */
.post-content .goat-svg svg {
    max-width: 100%;
    height: auto;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}

/* Dark mode adjustments for GoAT */
[data-theme="dark"] .post-content .goat-svg {
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    border-color: #374151;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3), 0 1px 3px rgba(0, 0, 0, 0.2);
}

[data-theme="dark"] .post-content .goat-svg:hover {
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.4), 0 3px 6px rgba(0, 0, 0, 0.3);
}

/* Adjust GoAT colors for dark mode */
[data-theme="dark"] .post-content .goat-svg svg {
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3)) invert(0.9) hue-rotate(180deg);
}

/* Diagram caption/figure styling */
.post-content .mermaid + p em,
.post-content .goat-svg + p em {
    display: block;
    text-align: center;
    margin-top: 1rem;
    font-size: 0.95rem;
    color: var(--text-secondary);
    font-style: italic;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .post-content .mermaid,
    .post-content .goat-svg {
        padding: 1rem;
        margin: 1.5rem 0;
        border-radius: 8px;
    }
    
    .post-content .mermaid svg,
    .post-content .goat-svg svg {
        font-size: 12px;
    }
}

/* Table of Contents */
.table-of-contents {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0;
    margin: 2rem 0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.table-of-contents details {
    cursor: pointer;
}

.table-of-contents summary {
    padding: 1rem 1.5rem;
    user-select: none;
    list-style: none;
    display: flex;
    align-items: center;
}

.table-of-contents summary::-webkit-details-marker {
    display: none;
}

.table-of-contents summary::before {
    content: '▼';
    margin-right: 0.75rem;
    font-size: 0.8rem;
    transition: transform 0.2s ease;
}

.table-of-contents details:not([open]) summary::before {
    transform: rotate(-90deg);
}

.table-of-contents summary h2 {
    margin: 0;
    font-size: 1.1rem;
    color: var(--primary-color);
    font-weight: 600;
}

.table-of-contents summary:hover h2 {
    color: var(--text-color);
}

.toc-content {
    padding: 0 1.5rem 1.5rem;
}

.table-of-contents nav {
    padding: 0;
}

.table-of-contents ul {
    list-style: none;
    padding-left: 0;
    margin: 0;
}

.table-of-contents ul ul {
    padding-left: 1.5rem;
    margin-top: 0.5rem;
}

.table-of-contents li {
    margin: 0.5rem 0;
    line-height: 1.6;
}

.table-of-contents a {
    color: var(--text-color);
    text-decoration: none;
    display: block;
    padding: 0.25rem 0;
    transition: color 0.2s ease, padding-left 0.2s ease;
}

.table-of-contents a:hover {
    color: var(--primary-color);
    padding-left: 0.5rem;
}

.table-of-contents a:visited {
    color: var(--text-secondary);
}

.table-of-contents a:hover:visited {
    color: var(--primary-color);
}

/* Heading Anchor Links */
.post-content h2,
.post-content h3,
.post-content h4,
.post-content h5,
.post-content h6 {
    position: relative;
    scroll-margin-top: 80px;
}

.post-content h2[id]:hover::before,
.post-content h3[id]:hover::before,
.post-content h4[id]:hover::before,
.post-content h5[id]:hover::before,
.post-content h6[id]:hover::before {
    content: '#';
    position: absolute;
    left: -1.5rem;
    color: var(--primary-color);
    font-weight: normal;
    opacity: 0.5;
    transition: opacity 0.2s ease;
}

.post-content h2[id]:hover::before:hover,
.post-content h3[id]:hover::before:hover,
.post-content h4[id]:hover::before:hover,
.post-content h5[id]:hover::before:hover,
.post-content h6[id]:hover::before:hover {
    opacity: 1;
}

/* Anchor link styling for direct links */
.post-content h2[id] a.anchor,
.post-content h3[id] a.anchor,
.post-content h4[id] a.anchor,
.post-content h5[id] a.anchor,
.post-content h6[id] a.anchor {
    color: var(--primary-color);
    text-decoration: none;
    margin-left: 0.5rem;
    opacity: 0;
    transition: opacity 0.2s ease;
    font-size: 0.8em;
}

.post-content h2:hover a.anchor,
.post-content h3:hover a.anchor,
.post-content h4:hover a.anchor,
.post-content h5:hover a.anchor,
.post-content h6:hover a.anchor {
    opacity: 0.6;
}

.post-content h2 a.anchor:hover,
.post-content h3 a.anchor:hover,
.post-content h4 a.anchor:hover,
.post-content h5 a.anchor:hover,
.post-content h6 a.anchor:hover {
    opacity: 1;
}

/* Smooth scrolling for anchor links */
html {
    scroll-behavior: smooth;
}

/* Highlight target heading when navigating via anchor */
.post-content :target {
    animation: highlight 2s ease-out;
}

@keyframes highlight {
    0% {
        background-color: rgba(79, 70, 229, 0.2);
    }
    100% {
        background-color: transparent;
    }
}

/* Reading time indicator */
.reading-time {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Responsive TOC */
@media (max-width: 768px) {
    .table-of-contents {
        margin: 1.5rem -1rem;
        border-radius: 0;
        border-left: none;
        border-right: none;
    }
    
    .post-content h2[id]:hover::before,
    .post-content h3[id]:hover::before,
    .post-content h4[id]:hover::before,
    .post-content h5[id]:hover::before,
    .post-content h6[id]:hover::before {
        display: none;
    }
}

/* Breadcrumb Navigation */
.breadcrumb {
    margin: 1.5rem 0;
    padding: 0.875rem 1rem;
    font-size: 0.9rem;
    background-color: var(--bg-secondary);
    border-radius: 6px;
    border: 1px solid var(--border-color);
}

.breadcrumb ol {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.25rem;
}

.breadcrumb li {
    display: flex;
    align-items: center;
}

.breadcrumb li:not(:last-child)::after {
    content: '›';
    margin: 0 0.5rem;
    color: var(--text-secondary);
    font-size: 1rem;
}

.breadcrumb a {
    color: var(--text-secondary);
    text-decoration: none;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
}

.breadcrumb li:last-child > span[itemprop="item"] {
    color: var(--text-color);
    font-weight: 500;
    padding: 0.25rem 0.5rem;
}

@media (max-width: 768px) {
    .breadcrumb {
        font-size: 0.85rem;
        padding: 0.75rem 0.875rem;
        margin: 1rem 0;
        overflow-x: auto;
        white-space: nowrap;
    }
    
    .breadcrumb a {
        padding: 0.2rem 0.4rem;
    }
    
    .breadcrumb li:last-child > span[itemprop="item"] {
        padding: 0.2rem 0.4rem;
    }
}

/* Author Pages */
.author-profile {
    margin: 3rem 0;
}

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

.author-name {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 1rem;
    color: var(--text-color);
}

.author-bio {
    font-size: 1.125rem;
    line-height: 1.7;
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
}

.author-specialties {
    margin-top: 1.5rem;
}

.author-specialties h3 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    color: var(--text-color);
}

.author-specialties ul {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.author-specialties li {
    background-color: var(--bg-secondary);
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    font-size: 0.95rem;
    color: var(--text-secondary);
}

.author-articles {
    margin-top: 3rem;
}

.author-articles h2 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 2rem;
    color: var(--text-color);
}

.articles-list {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.article-preview {
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 1.5rem;
}

.article-preview:last-child {
    border-bottom: none;
}

.article-preview h3 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.article-preview h3 a {
    color: var(--text-color);
    text-decoration: none;
    transition: color 0.2s ease;
}

.article-preview h3 a:hover {
    color: var(--primary-color);
}

.article-meta {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
}

.article-description {
    color: var(--text-secondary);
    line-height: 1.6;
}

/* Authors List Page */
.authors-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 2rem;
    margin-top: 2rem;
}

.author-list-card {
    position: relative;
    background-color: var(--bg-raised);
    padding: 2rem;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    overflow: hidden;
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.author-list-card::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--gradient-brand);
    opacity: 0;
    transition: opacity 0.2s ease;
}

.author-list-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
    border-color: var(--accent-border);
}

.author-list-card:hover::before {
    opacity: 1;
}

.author-list-card h2 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
}

.author-list-card h2 a {
    color: var(--text-color);
    text-decoration: none;
    transition: color 0.2s ease;
}

.author-list-card h2 a:hover {
    color: var(--primary-color);
}

.author-list-card .author-bio {
    font-size: 1rem;
    line-height: 1.6;
    margin-bottom: 1rem;
}

.author-specialties-short {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-top: 1rem;
}

/* Author link in post header */
.post-author .author-link {
    color: var(--text-color);
    text-decoration: none;
    transition: color 0.2s ease;
}

.post-author .author-link:hover {
    color: var(--primary-color);
    text-decoration: underline;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .authors-grid {
        grid-template-columns: 1fr;
    }
    
    .author-name {
        font-size: 2rem;
    }
    
    .author-articles h2 {
        font-size: 1.75rem;
    }
}

/* Custom Theme-Aware Badges */
.badge-container {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-top: 1rem;
}

.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.375rem 0.75rem;
    border-radius: 0.375rem;
    font-size: 0.875rem;
    font-weight: 500;
    border: 1px solid var(--border-color);
    background-color: var(--bg-secondary);
    color: var(--text-color);
    transition: background-color 0.2s ease, border-color 0.2s ease;
}

.badge-success {
    background-color: #dcfce7;
    border-color: #86efac;
    color: #166534;
}

[data-theme="dark"] .badge-success {
    background-color: #14532d;
    border-color: #166534;
    color: #86efac;
}

.badge-icon {
    margin-right: 0.375rem;
    flex-shrink: 0;
}

/* Mobile responsiveness for badges */
@media (max-width: 768px) {
    .badge-container {
        gap: 0.5rem;
    }
    
    .badge {
        font-size: 0.8125rem;
        padding: 0.3125rem 0.625rem;
    }
    
    .badge-icon {
        width: 14px;
        height: 14px;
    }
}

/* ========================================================================
   READING EXPERIENCE ENHANCEMENTS
   Additive refinements layered on top of the existing design language:
   same blue, same Space Grotesk / Fira Code pairing, same rounded cards.
   ======================================================================== */

:root {
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06),
                 0 1px 3px rgba(15, 23, 42, 0.08);
    --shadow-md: 0 4px 6px -1px rgba(15, 23, 42, 0.08),
                 0 2px 4px -2px rgba(15, 23, 42, 0.06);
    --shadow-lg: 0 12px 20px -8px rgba(15, 23, 42, 0.18),
                 0 4px 8px -4px rgba(15, 23, 42, 0.10);
    --accent-soft: rgba(79, 70, 229, 0.08);
    --accent-border: rgba(79, 70, 229, 0.25);
}

[data-theme="dark"] {
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 4px 8px -2px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 14px 24px -10px rgba(0, 0, 0, 0.65);
    --accent-soft: rgba(165, 180, 252, 0.14);
    --accent-border: rgba(165, 180, 252, 0.32);
}

/* ---------- Typography rhythm ---------- */

.post-single .post-title {
    letter-spacing: -0.022em;
    text-wrap: balance;
}

.hero h2,
.section-title,
.post-content h2,
.post-content h3 {
    letter-spacing: -0.015em;
    text-wrap: balance;
}

/* .post-single already caps the column at 800px, which is a comfortable
   measure at this font size. Constraining .post-content further would leave
   body text ending short of the headings, TOC, and author card. */

.post-content > p:first-of-type {
    font-size: 1.2rem;
    line-height: 1.7;
    color: var(--text-color);
}

.post-content h2 {
    padding-bottom: 0.4rem;
    border-bottom: 1px solid var(--border-color);
}

.post-content h4 {
    font-size: 1.15rem;
    font-weight: 600;
    margin-top: 1.75rem;
    margin-bottom: 0.6rem;
}

.post-content li::marker {
    color: var(--text-secondary);
}

.post-content strong {
    font-weight: 600;
    color: var(--text-color);
}

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

/* Blockquotes read as editorial callouts rather than plain indents */
.post-content blockquote {
    background: var(--accent-soft);
    border-left-width: 3px;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    padding: 1rem 1.25rem;
    font-style: normal;
    color: var(--text-color);
}

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

/* The old rule used attr() for aspect-ratio, which no browser supports
   outside content:. Reserve space with a sane default instead. */
.post-content img {
    aspect-ratio: auto;
    border-radius: var(--radius-md);
}

/* ---------- Reading progress ---------- */

.reading-progress-track {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    z-index: 200;
    background: transparent;
    pointer-events: none;
}

.reading-progress-bar {
    height: 100%;
    width: 100%;
    transform: scaleX(0);
    transform-origin: 0 50%;
    background: var(--gradient-brand);
    will-change: transform;
}

@media (prefers-reduced-motion: reduce) {
    .reading-progress-bar { transition: none; }
}

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

.code-block-wrapper {
    position: relative;
    margin: 1.75rem 0;
}

.code-block-wrapper pre {
    margin: 0;
    padding-top: 2.6rem;
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    scrollbar-width: thin;
}

.code-block-bar {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2.4rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 0.6rem 0 1rem;
    border-bottom: 1px solid rgba(148, 163, 184, 0.18);
    pointer-events: none;
}

.code-block-lang {
    font-family: 'Fira Code', monospace;
    font-size: 0.72rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #94a3b8;
}

.code-copy-button {
    pointer-events: auto;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    margin-left: auto;
    padding: 0.3rem 0.6rem;
    font-family: inherit;
    font-size: 0.78rem;
    font-weight: 500;
    color: #cbd5e1;
    background: rgba(148, 163, 184, 0.12);
    border: 1px solid rgba(148, 163, 184, 0.22);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.code-copy-button:hover {
    background: rgba(148, 163, 184, 0.24);
    color: #f1f5f9;
}

.code-copy-button.is-copied {
    color: #4ade80;
    border-color: rgba(74, 222, 128, 0.45);
    background: rgba(74, 222, 128, 0.12);
}

/* ---------- Wide tables scroll inside their own box ---------- */

.table-scroll {
    overflow-x: auto;
    max-width: 100%;
    margin: 1.5rem 0;
    border-radius: var(--radius-md);
    -webkit-overflow-scrolling: touch;
}

.table-scroll:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* ---------- Share buttons ---------- */

.share-buttons {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
    margin-top: 2.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
}

.share-label {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.share-links {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.share-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    min-width: 44px;
    min-height: 44px;
    padding: 0 0.9rem;
    border: 1px solid var(--border-color);
    border-radius: 999px;
    background: transparent;
    color: var(--text-color);
    font-family: inherit;
    font-weight: 700;
    font-size: 0.9rem;
    text-decoration: none;
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease, transform 0.15s ease;
}

.share-link:hover {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
    color: #ffffff;
    transform: translateY(-1px);
}

.share-copy {
    font-weight: 500;
    padding: 0 1rem;
}

.share-copy.is-copied {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

@media (max-width: 400px) {
    .share-copy-label {
        display: none;
    }

    .share-copy {
        padding: 0;
        width: 44px;
    }
}

/* ---------- Author card ---------- */

.author-card {
    display: flex;
    gap: 1.25rem;
    align-items: flex-start;
    margin-top: 3.5rem;
    padding: 1.75rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
}

.author-card-avatar {
    flex: 0 0 auto;
    width: 56px;
    height: 56px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: var(--gradient-brand);
    color: #fff;
    font-weight: 700;
    font-size: 1.15rem;
    letter-spacing: 0.02em;
}

.author-card-body { min-width: 0; }

.author-card-eyebrow {
    margin: 0 0 0.15rem;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    color: var(--text-secondary);
}

.author-card-name {
    margin: 0 0 0.6rem;
    font-size: 1.25rem;
    font-weight: 700;
    line-height: 1.3;
}

.author-card-name a {
    color: var(--text-color);
    text-decoration: none;
}

.author-card-name a:hover { color: var(--primary-color); }

.author-card-bio {
    margin: 0 0 0.9rem;
    color: var(--text-secondary);
    font-size: 0.97rem;
    line-height: 1.65;
}

.author-card-specialties {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin: 0 0 1rem;
    padding: 0;
    list-style: none;
}

.author-card-specialties li {
    padding: 0.25rem 0.65rem;
    font-size: 0.78rem;
    color: var(--text-secondary);
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 999px;
}

.author-card-link {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.92rem;
    font-weight: 600;
    color: var(--primary-color);
    text-decoration: none;
}

.author-card-link:hover { text-decoration: underline; }

/* ---------- Related posts ---------- */

.related-posts {
    margin-top: 3rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border-color);
}

.related-heading {
    font-size: 1.4rem;
    font-weight: 700;
    margin-bottom: 1.25rem;
}

.related-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 0.75rem;
}

.related-link {
    display: block;
    padding: 1rem 1.15rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-left: 3px solid transparent;
    border-radius: var(--radius-md);
    text-decoration: none;
    transition: border-color 0.18s ease, transform 0.18s ease,
                box-shadow 0.18s ease;
}

.related-link:hover {
    border-left-color: var(--primary-color);
    transform: translateX(3px);
    box-shadow: var(--shadow-sm);
}

.related-title {
    display: block;
    font-weight: 600;
    color: var(--text-color);
    line-height: 1.4;
    margin-bottom: 0.25rem;
}

.related-link:hover .related-title { color: var(--primary-color); }

.related-meta {
    display: block;
    font-size: 0.83rem;
    color: var(--text-secondary);
}

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

.post-card {
    position: relative;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background-color: var(--bg-raised);
}

.post-card::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--gradient-brand);
    opacity: 0;
    transition: opacity 0.2s ease;
}

.post-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
    border-color: var(--accent-border);
}

.post-card:hover::before {
    opacity: 1;
}

.post-card-image-link {
    margin: -1.5rem -1.5rem 1rem;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.post-card .read-more { margin-top: auto; }

.post-card .read-more::after {
    content: "";
    display: inline-block;
    width: 0;
}

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

.toc-content a.toc-active {
    color: var(--primary-color);
    font-weight: 600;
}

@media (min-width: 1180px) {
    .table-of-contents {
        position: sticky;
        top: 5.5rem;
        z-index: 5;
    }
}

/* ---------- Accessibility ---------- */

a:focus-visible,
button:focus-visible,
input:focus-visible,
summary:focus-visible,
.tag:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
}

.skip-link {
    position: absolute;
    left: -9999px;
    top: 0;
    z-index: 999;
    padding: 0.75rem 1.25rem;
    background: var(--primary-color);
    color: #fff;
    font-weight: 600;
    text-decoration: none;
    border-radius: 0 0 var(--radius-sm) 0;
}

.skip-link:focus {
    left: 0;
}

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

/* ---------- Responsive ---------- */

@media (max-width: 768px) {
    .post-content > p:first-of-type { font-size: 1.1rem; }

    .author-card {
        flex-direction: column;
        gap: 1rem;
        padding: 1.35rem;
    }

    .author-card-avatar { width: 48px; height: 48px; font-size: 1rem; }

    .code-block-wrapper pre { padding-top: 2.5rem; }

    .related-link:hover { transform: none; }
}

/* ---------- Print ---------- */

@media print {
    .site-header,
    .site-footer,
    .reading-progress-track,
    .table-of-contents,
    .related-posts,
    .article-feedback,
    .code-block-bar,
    .share-buttons,
    .search-modal { display: none !important; }

    .post-content { max-width: 100%; font-size: 11pt; }
    .post-content pre { padding-top: 1rem; white-space: pre-wrap; }
    .author-card { border: 1px solid #ccc; }
    a::after { content: " (" attr(href) ")"; font-size: 9pt; color: #555; }
}
