:root {
    --bg-color: #121212;
    --bg-secondary: #1e1e1e;
    --text-main: #e0e0e0;
    --text-muted: #a0a0a0;
    /* Adjusted accent to a softer, more professional blue */
    --accent-primary: #3b82f6; 
    --accent-hover: #60a5fa;
    --accent-secondary: #4094ed;
    --border-color: #333;
    --font-main: 'JetBrains Mono', monospace;
    --container-width: 1400px;
    --sidebar-width: 280px;
    --header-height: 60px;
    --spacing-unit: 20px;
    --radius: 8px;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

@font-face {
    font-family: 'JetBrains Mono';
    src: url('/static/webfonts/JetBrainsMono-Regular.woff2') format('woff2');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'JetBrains Mono';
    src: url('/static/webfonts/JetBrainsMono-Bold.woff2') format('woff2');
    font-weight: bold;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'JetBrains Mono';
    src: url('/static/webfonts/JetBrainsMono-Italic.woff2') format('woff2');
    font-weight: normal;
    font-style: italic;
    font-display: swap;
}

* {
    box-sizing: border-box;
}

body, html {
    margin: 0;
    padding: 0;
    font-family: var(--font-main);
    background-color: var(--bg-color);
    color: var(--text-main);
    line-height: 1.7;
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

/* Layout */
.container {
    max-width: var(--container-width);
    margin: 0 auto;
    display: flex;
    min-height: 100vh;
    position: relative;
}

/* Sidebars */
.sidebar {
    width: var(--sidebar-width);
    padding: 40px 20px;
    background-color: var(--bg-color);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    height: 100vh;
    position: sticky;
    top: 0;
    overflow-y: auto;
    border-right: 1px solid var(--border-color);
    scrollbar-width: thin;
    scrollbar-color: var(--border-color) transparent;
}

.right-sidebar {
    width: var(--sidebar-width);
    padding: 40px 20px;
    background-color: var(--bg-color);
    flex-shrink: 0;
    height: 100vh;
    position: sticky;
    top: 0;
    overflow-y: auto;
    border-left: 1px solid var(--border-color);
}

/* Main Content */
.main-content {
    flex-grow: 1;
    padding: 60px 80px 40px 80px; /* Balanced bottom padding */
    background-color: var(--bg-color);
    max-width: calc(100% - 2 * var(--sidebar-width));
    width: 100%;
}

/* Typography & Elements */
h1, h2, h3, h4, h5, h6 {
    color: #fff;
    line-height: 1.3;
}

h1 {
    font-size: 2.5rem;
    margin-top: 0;
    margin-bottom: 0.5em; /* Reduced from 1.5em */
    position: relative;
    display: inline-block;
}

h1::after {
    content: '';
    display: block;
    width: 60px;
    height: 4px;
    background: var(--accent-primary);
    margin-top: 10px;
    border-radius: 2px;
}

h2 {
    font-size: 1.8rem;
    margin-top: 2.5rem; /* Reduced from 4rem */
    margin-bottom: 1rem; /* Reduced from 1.5rem */
    padding-top: 1rem; /* Reduced from 1.5rem */
    position: relative;
    color: #fff;
}

/* Section separator that isn't a full horizontal line */
h2::before {
    content: '';
    display: block;
    width: 40px;
    height: 4px;
    background-color: var(--bg-secondary);
    border-radius: 2px;
    position: absolute;
    top: 0;
    left: 0;
    border-left: 40px solid var(--accent-primary); /* Two-tone effect */
}

h3 {
    font-size: 1.4rem;
    color: var(--text-muted);
    margin-top: 2.5em;
    margin-bottom: 1em;
}

p {
    margin-bottom: 1.5em;
}

a {
    color: var(--accent-primary);
    text-decoration: none;
    transition: color 0.2s ease, border-bottom-color 0.2s ease;
    border-bottom: 1px solid transparent;
}

a:hover {
    color: var(--accent-hover);
    border-bottom-color: var(--accent-hover);
}

/* Sidebar Navigation */
.sidebar nav {
    margin-top: 20px;
}

.sidebar h2 {
    /* Reset specific H2 styling for sidebar */
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    margin: 30px 0 10px 0;
    padding-top: 0;
    border-bottom: none;
}

.sidebar h2::before {
    display: none;
}

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

.sidebar li {
    margin-bottom: 8px;
}

.sidebar a {
    color: var(--text-main);
    font-size: 0.95rem;
    display: block;
    padding: 6px 10px;
    border-radius: var(--radius);
    border-bottom: none;
    transition: all 0.2s ease;
}

.sidebar a:hover, .sidebar li.active a {
    background-color: var(--bg-secondary);
    color: var(--accent-primary);
    transform: translateX(4px);
}

.home-link {
    display: block;
    text-align: center;
    margin-bottom: 40px;
    border-bottom: none !important;
    /* Fix for mobile touch highlight */
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

.avatar-logo {
    width: 140px;
    height: 140px;
    border-radius: 50%;
    object-fit: cover;
    border: 4px solid var(--bg-secondary);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.home-link:hover .avatar-logo {
    transform: scale(1.05) rotate(3deg);
    box-shadow: 0 0 20px rgba(59, 130, 246, 0.3);
    border-color: var(--accent-primary);
}

/* Right Sidebar / TOC */
.toc {
    font-size: 0.9rem;
}

.toc h3 {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-top: 0;
    color: var(--text-muted);
}

.toc li a {
    color: var(--text-muted);
    display: block;
    padding: 4px 0;
    border-bottom: none;
}

.toc li a:hover {
    color: var(--accent-primary);
    padding-left: 4px;
}

/* Content Elements */
hr {
    border: 0;
    height: 1px;
    background: linear-gradient(to right, var(--bg-secondary), var(--border-color), var(--bg-secondary));
    margin: 60px 0;
    opacity: 0.5;
}

blockquote {
    margin: 2em 0;
    padding: 1.5em 2em;
    background-color: var(--bg-secondary);
    border-left: 4px solid var(--accent-primary);
    border-radius: 0 var(--radius) var(--radius) 0;
    color: var(--text-main);
    font-style: italic;
}

code {
    font-family: var(--font-main);
    background-color: rgba(255, 255, 255, 0.1);
    padding: 0.2em 0.4em;
    border-radius: 4px;
    font-size: 0.9em;
    color: #ffbd2e; /* Yellowish for inline code */
}

pre {
    background-color: var(--bg-secondary);
    padding: 20px;
    border-radius: var(--radius);
    overflow-x: auto;
    border: 1px solid var(--border-color);
    margin: 2em 0;
}

pre code {
    background-color: transparent;
    padding: 0;
    color: inherit;
    font-size: 0.9em;
}

/* Enhanced Image Styling */
img {
    max-width: 100%;
    height: auto;
    border-radius: var(--radius);
    display: block;
    margin: 1.5em auto 2.5em auto; /* Tighter top margin, larger bottom margin for better grouping with preceding text if any, or distinct separation */
    box-shadow: var(--shadow);
    border: 1px solid #2a2a2a;
}

.info-box {
    margin: 2em 0;
    padding: 20px;
    background-color: rgba(59, 130, 246, 0.1);
    border-left: 4px solid var(--accent-primary);
    border-radius: var(--radius);
}

.info-box p:last-child {
    margin-bottom: 0;
}

/* Lists */
.main-content ul, .main-content ol {
    padding-left: 20px;
}

.main-content li {
    margin-bottom: 0.5em;
}

/* Posts List on Index */
.posts-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.posts-list li {
    margin-bottom: 30px;
}

.posts-list a {
    font-size: 1.4rem;
    font-weight: bold;
    display: block;
    margin-bottom: 5px;
    border-bottom: none;
}

.post-description {
    color: var(--text-muted);
    font-size: 1rem;
    margin: 0;
}

/* Footer */
footer {
    margin-top: 60px;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* Mobile Menu & Responsive */
.mobile-header {
    display: none;
}

.mobile-menu-button {
    background: none;
    border: none;
    color: var(--text-main);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    -webkit-tap-highlight-color: transparent;
}

.mobile-logo {
    text-decoration: none;
    border: none !important;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mobile-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 2px solid var(--accent-primary);
    object-fit: cover;
    display: block;
}

#mob-side-section {
    display: none;
}

@media (max-width: 1200px) {
    .right-sidebar {
        display: none;
    }
    .main-content {
        max-width: calc(100% - var(--sidebar-width));
    }
}

@media (max-width: 768px) {
    .container {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        height: auto;
        position: static;
        padding: 0;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }

    #normal-menu {
        display: none;
    }

    #mob-side-section {
        display: block;
    }

    .mobile-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 8px 20px;
        background-color: var(--bg-secondary);
        border-bottom: 1px solid var(--border-color);
        position: sticky;
        top: 0;
        z-index: 100;
    }

    .mobile-menu {
        display: none;
        padding: 20px;
        background-color: var(--bg-color);
    }

    .mobile-menu.is-active {
        display: block;
        animation: slideDown 0.3s ease;
    }

    .main-content {
        padding: 30px 20px;
        max-width: 100%;
    }

    h1 {
        font-size: 2rem;
    }

    .avatar-logo {
        width: 80px;
        height: 80px;
        margin-top: 10px;
    }

    .home-link {
        margin-bottom: 20px;
    }
}

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

/* Delight Details */
::selection {
    background: var(--accent-primary);
    color: #fff;
}

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-color);
}

::-webkit-scrollbar-thumb {
    background: #333;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Smooth transitions for everything */
* {
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

/* Exclude transition for transform to avoid jitter in some cases, or keep it specific */
.sidebar a, .home-link .avatar-logo {
    transition: transform 0.2s ease, color 0.2s ease, background-color 0.2s ease, box-shadow 0.2s ease;
}

/* --- New Enhancements --- */

/* 1. Copy Code Button */
.copy-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: var(--text-muted);
    border-radius: 4px;
    padding: 5px 10px;
    cursor: pointer;
    transition: all 0.2s;
    opacity: 0; /* Hidden by default until hover */
}

pre:hover .copy-btn {
    opacity: 1;
}

.copy-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    color: var(--text-main);
}

.copy-btn.copied {
    color: var(--accent-primary); /* Green or Accent color for success */
    border-color: var(--accent-primary);
}

/* 2. Image Lightbox */
.lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    backdrop-filter: blur(5px);
}

.lightbox.active {
    opacity: 1;
    pointer-events: all;
}

.lightbox img {
    max-width: 90%;
    max-height: 80vh;
    box-shadow: 0 0 50px rgba(0,0,0,0.5);
    border: 2px solid var(--border-color);
    margin: 0; /* Reset default img margin */
    object-fit: contain;
}

.lightbox-close {
    position: absolute;
    top: 20px;
    right: 30px;
    color: #fff;
    font-size: 40px;
    cursor: pointer;
    line-height: 1;
    z-index: 1002;
}

.lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    border: none;
    font-size: 2rem;
    padding: 10px 15px;
    cursor: pointer;
    border-radius: 50%;
    transition: all 0.2s;
    z-index: 1001;
}

.lightbox-nav:hover {
    background: var(--accent-primary);
}

.lightbox-prev {
    left: 20px;
}

.lightbox-next {
    right: 20px;
}

.lightbox-close:hover {
    color: var(--accent-primary);
}

/* 3. Back to Top Button */
#back-to-top {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: var(--bg-secondary);
    color: var(--accent-primary);
    border: 1px solid var(--accent-primary);
    font-size: 24px;
    cursor: pointer;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.3s ease;
    z-index: 900;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
}

#back-to-top.visible {
    opacity: 1;
    transform: translateY(0);
}

#back-to-top:hover {
    background: var(--accent-primary);
    color: #fff;
    transform: translateY(-5px);
    box-shadow: 0 0 20px rgba(59, 130, 246, 0.4);
}

@media (max-width: 768px) {
    #back-to-top {
        bottom: calc(20px + env(safe-area-inset-bottom));
        right: 20px;
        width: 45px;
        height: 45px;
        font-size: 22px;
    }
    
    .copy-btn {
        opacity: 1; /* Always visible on mobile */
    }
}

/* Post Meta */
.post-meta {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.post-meta i {
    color: var(--accent-primary);
}

/* Mobile Profile Reimagined */
.mobile-profile-container {
    margin-bottom: 15px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--border-color);
}

.mobile-profile-link {
    display: flex;
    align-items: center;
    gap: 15px;
    text-decoration: none;
    padding: 5px 0;
    border-bottom: none !important; /* Override global a border */
}

.mobile-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--accent-primary);
}

.mobile-info {
    display: flex;
    flex-direction: column;
    justify-content: center;
    line-height: 1.3;
}

.mobile-name {
    font-weight: bold;
    font-size: 1rem;
    color: var(--text-main);
}

.mobile-home-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Revised Mobile Header */
