:root {
    --blog-padding: 2rem;
    --text-main: #333333;
    --text-muted: #666666;
    --bg-card: #ffffff;
    --bg-page: #f9f9f9;
    --accent: #25D366;
    --border-color: #eeeeee;
    --font-base: 'Inter', system-ui, -apple-system, sans-serif;
    --article-max-width: 75ch;
    /* Optimal readability width */
}

@media (prefers-color-scheme: dark) {
    :root {
        --text-main: #e0e0e0;
        --text-muted: #a0a0a0;
        --bg-card: #1e1e1e;
        --bg-page: #121212;
        --border-color: #333333;
    }
}

/* Base Styles */
.blog-listing-container,
.blog-post-container {
    font-family: var(--font-base);
    color: var(--text-main);
    line-height: 1.6;
    background: var(--bg-page);
}

/* --- Listing Page --- */
.blog-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1.5rem;
    /* Reduced from 2rem */
    margin-bottom: 3rem;
}

.blog-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    overflow: hidden;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.blog-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.05);
}

.blog-card img {
    width: 100%;
    height: 200px;
    object-fit: cover;
}

.blog-card-content {
    padding: 1.5rem;
}

.blog-card-meta {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    display: flex;
    gap: 1rem;
}

.blog-card-title {
    font-size: 1.15rem;
    margin-bottom: 0.75rem;
    line-height: 1.4;
    font-weight: 700;
}

.blog-card-title a {
    color: var(--text-main);
    text-decoration: none;
}

.blog-card-title a:hover {
    color: var(--accent);
}

/* --- Single Post Page --- */
.blog-article-layout {
    display: grid;
    grid-template-columns: 1fr;
    gap: 4rem;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
}

@media (min-width: 1024px) {
    .blog-article-layout {
        grid-template-columns: minmax(0, 1fr) 300px;
    }
}

/* Article Measure & Typography */
article.blog-single-post {
    max-width: var(--article-max-width);
    margin: 0 auto;
}

.post-header {
    margin-bottom: 2rem;
    text-align: left;
}

.post-title {
    font-size: clamp(2rem, 5vw, 3rem);
    font-weight: 800;
    line-height: 1.1;
    margin-bottom: 1.5rem;
}

.post-meta-top {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    color: var(--text-muted);
    font-size: 0.95rem;
    margin-bottom: 2rem;
}

.post-meta-top span {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.post-featured-image {
    width: 100%;
    max-height: 380px;
    /* More cinematic height */
    object-fit: cover;
    /* Maintain aspect ratio */
    border-radius: 12px;
    margin-bottom: 2.5rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}

@media (max-width: 768px) {
    .post-featured-image {
        max-height: 250px;
    }
}

/* Content Body Readability */
.post-content {
    font-size: 1.125rem;
    line-height: 1.85;
    text-align: left;
    text-rendering: optimizeLegibility;
    color: var(--text-main);
    letter-spacing: -0.011em;
    /* Subltle modern adjustment */
}

.post-content h2 {
    margin: 3.5rem 0 1.5rem;
    font-size: 2rem;
    font-weight: 800;
    line-height: 1.25;
    letter-spacing: -0.02em;
}

.post-content h3 {
    margin: 2.5rem 0 1rem;
    font-size: 1.6rem;
    font-weight: 700;
    line-height: 1.3;
    letter-spacing: -0.01em;
}

.post-content p {
    margin-bottom: 2rem;
}

.post-content blockquote {
    border-left: 4px solid var(--accent);
    padding: 1.5rem 2rem;
    margin: 3.5rem 0;
    font-style: italic;
    font-size: 1.5rem;
    color: var(--text-muted);
    background: rgba(37, 211, 102, 0.05);
    border-radius: 0 12px 12px 0;
}

.post-content img {
    max-width: 100%;
    border-radius: 16px;
    /* slightly more rounded */
    margin: 3rem 0;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

.post-content ul,
.post-content ol {
    margin-bottom: 2.5rem;
    padding-left: 1.5rem;
}

.post-content li {
    margin-bottom: 1rem;
    position: relative;
}

.post-content pre,
.post-content code-block {
    background: #1a1a1a;
    color: #e0e0e0;
    padding: 2rem;
    border-radius: 12px;
    display: block;
    overflow-x: auto;
    font-family: 'Fira Code', 'Consolas', monospace;
    font-size: 0.95rem;
    line-height: 1.6;
    margin: 3rem 0;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.3);
}

.post-content code {
    background: rgba(37, 211, 102, 0.1);
    color: var(--accent);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.9em;
    font-family: monospace;
}

.post-content pre code {
    background: transparent;
    color: inherit;
    padding: 0;
    border-radius: 0;
    font-size: inherit;
}

/* Sticky Tables of Content */
.sticky-sidebar {
    position: sticky;
    top: 100px;
    height: fit-content;
}

.toc-widget {
    background: var(--bg-card);
    padding: 2rem;
    border-radius: 16px;
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.03);
    transition: box-shadow 0.3s ease;
}

.toc-widget:hover {
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.06);
}

.toc-widget h4 {
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 1rem;
    color: var(--accent);
}

.toc-list {
    list-style: none;
    padding: 0;
    margin: 0;
    font-size: 0.9rem;
}

.toc-list li {
    margin-bottom: 0.8rem;
}

.toc-list a {
    color: var(--text-muted);
    text-decoration: none;
    transition: color 0.2s;
}

.toc-list a:hover,
.toc-list a.active {
    color: var(--accent);
}

/* Author Block */
.author-box {
    display: flex;
    align-items: center;
    gap: 2rem;
    padding: 3rem;
    background: var(--bg-card);
    border-radius: 20px;
    margin-top: 6rem;
    border: 1px solid var(--border-color);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.04);
}

.author-img {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--accent);
    padding: 3px;
}

/* Share Buttons */
.share-floating {
    display: flex;
    gap: 1rem;
    margin-top: 3rem;
}

.share-btn {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    transition: 0.3s;
}

.share-btn:hover {
    background: var(--accent);
    color: white !important;
    border-color: var(--accent);
}

.search-form .search-input,
.search-form .search-input:focus,
.search-form .search-input:active {
    background-color: transparent !important;
    border: none !important;
    box-shadow: none !important;
    outline: none !important;
    color: var(--text-main) !important;
    width: 100%;
}

/* Fix browser autofill turning background white/blue */
.search-form .search-input:-webkit-autofill,
.search-form .search-input:-webkit-autofill:hover,
.search-form .search-input:-webkit-autofill:focus,
.search-form .search-input:-webkit-autofill:active {
    -webkit-box-shadow: 0 0 0 30px var(--bg-card) inset !important;
    -webkit-text-fill-color: var(--text-main) !important;
    transition: background-color 5000s ease-in-out 0s;
}

.search-form .form-control::placeholder {
    color: var(--text-muted);
}

/* Chips/Tags */
.tag-chips {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-top: 2rem;
}

.tag-chip {
    padding: 6px 16px;
    background: rgba(37, 211, 102, 0.08);
    color: var(--accent);
    border-radius: 50px;
    font-size: 0.85rem;
    text-decoration: none;
    font-weight: 600;
    transition: all 0.2s ease;
    border: 1px solid transparent;
}

.tag-chip:hover {
    background: var(--accent);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(37, 211, 102, 0.2);
}

/* Nav Prev/Next */
.post-navigation {
    display: flex;
    justify-content: space-between;
    padding: 2rem 0;
    border-top: 1px solid var(--border-color);
    margin-top: 3rem;
}

.nav-link-box {
    max-width: 45%;
}

.nav-link-box a {
    text-decoration: none;
    transition: color 0.2s;
    font-weight: 700;
    display: block;
    margin-top: 5px;
}

.nav-link-box a:hover {
    color: var(--accent) !important;
}

/* Contextual CTA Box */
.cta-box {
    background: linear-gradient(135deg, #1e1e1e 0%, #2d2d2d 100%);
    border-left: 5px solid var(--accent);
    padding: 2.5rem;
    border-radius: 12px;
    margin: 4rem 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1.5rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}

.cta-content h3 {
    color: #ffffff;
    margin: 0 0 0.5rem;
    font-size: 1.5rem;
}

.cta-content p {
    color: #cccccc;
    margin: 0;
    font-size: 1rem;
}

.cta-btn {
    background: var(--accent);
    color: #ffffff;
    padding: 12px 25px;
    border-radius: 50px;
    font-weight: 700;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    transition: transform 0.2s, box-shadow 0.2s;
}

.cta-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(37, 211, 102, 0.4);
    color: #fff;
}

@media (max-width: 768px) {
    .cta-box {
        flex-direction: column;
        text-align: center;
        padding: 2rem;
    }

    .cta-box .cta-action {
        width: 100%;
    }

    .cta-btn {
        width: 100%;
        justify-content: center;
    }
}