:root {
    /* Color Variables - Easy to swap */
    --bg-page: #f9fafb;
    --bg-card: #ffffff;
    --primary: #2563eb;
    --text-header: #111827;
    --text-body: #374151;
    --text-muted: #6b7280;
    --border: #e5e7eb;
    --code-bg: #1e293b;
}

body {
    background-color: var(--bg-page);
    color: var(--text-body);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
    line-height: 1.7;
    margin: 0;
}

/* --- THE CONTAINER --- */
.container {
    display: grid;
    grid-template-columns: 1fr 300px; /* Sidebar stays on the right */
    gap: 48px;
    max-width: 1200px;
    margin: 0 auto;
    padding: 60px 20px;
}

/* --- MAIN CONTENT (LEFT) --- */
#main-content {
    min-width: 0; /* Prevents code blocks from breaking layout */
}

#markdown-viewer {
    background: var(--bg-card);
    padding: 50px;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

#markdown-viewer img {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 2rem auto;
    border-radius: 5px;
}

/* --- SIDEBAR (RIGHT) --- */
#sidebar {
    position: sticky;
    top: 40px;
    height: fit-content;
}

#sidebar h3 {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    margin-bottom: 16px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 8px;
}

#sidebar-nav a {
    display: block;
    color: var(--text-body);
    text-decoration: none;
    padding: 8px 0;
    font-weight: 500;
    transition: color 0.2s;
}

#sidebar-nav a:hover {
    color: var(--primary);
}

/* --- MARKDOWN ELEMENTS --- */
#markdown-viewer h1 { font-size: 2.5rem; color: var(--text-header); margin-top: 0; }
#markdown-viewer h2 { font-size: 1.8rem; margin-top: 2rem; border-bottom: 1px solid var(--border); padding-bottom: 0.3em; }

/* Blockquotes */
#markdown-viewer blockquote {
    margin: 2rem 0;
    padding: 1rem 1.5rem;
    border-left: 4px solid var(--primary);
    background: #f0f7ff;
    color: #1e40af;
    border-radius: 0 8px 8px 0;
}

/* Tables */
#markdown-viewer table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.5rem 0;
}
#markdown-viewer th, #markdown-viewer td {
    padding: 12px;
    border: 1px solid var(--border);
    text-align: left;
}
#markdown-viewer th { background: #f8fafc; }

/* Code Blocks */
#markdown-viewer pre {
    background: var(--code-bg);
    color: #f8fafc;
    padding: 1.5rem;
    border-radius: 8px;
    overflow-x: auto;
    font-size: 0.9rem;
    margin: 1.5rem 0;
}

/* Inline Code */
#markdown-viewer :not(pre) > code {
    background: #fee2e2;
    color: #991b1b;
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
}

/* --- RESPONSIVE --- */
@media (max-width: 900px) {
    .container { grid-template-columns: 1fr; }
    #sidebar { order: 2; position: static; }
    #markdown-viewer { padding: 30px; }
}

/* Container for the math formulas */
mjx-container[display="true"] {
    margin: 2rem 0 !important;
    padding: 1.5rem;
    background: #f8fafc;
    border-radius: 12px;
    border: 1px solid var(--border);
    overflow-x: auto;
    overflow-y: hidden;
}

/* Sidebar on the very right */
.container {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 40px;
}

#sidebar {
    border-left: 2px solid #f1f5f9;
    padding-left: 20px;
}

.home-button {
    /* Layout */
    display: inline-block;
    margin-left: 15px;
    margin-top: 10px;
    padding: 5px 0; /* No vertical box, just text height */
    
    /* Typography */
    text-decoration: none;
    text-transform: uppercase;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 2px;
    color: #000;
    
    /* The "Underline" effect */
    border-bottom: 2px solid #000;
    
    /* Animation */
    transition: opacity 0.2s ease;
}

.home-button:hover {
    opacity: 0.5;
}

.home-button span {
    margin-right: 8px;
}

.sidebar-footer {
    margin-top: 40px; 
    margin-bottom: 10px;     /* Moves it above the very bottom edge */
    padding-left: 20px;    /* Moves it slightly right from the absolute edge */
    border-top: 1px solid #eee;
    padding-top: 20px;
}

.github-link {
    display: flex;
    align-items: center;
    gap: 12px;             /* Space between icon and text */
    text-decoration: none;
    color: #1a1a1a;        /* High contrast for readability */
    font-family: sans-serif;
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    transition: opacity 0.2s;
}

.github-link svg {
    fill: #1a1a1a;         /* Matches text color */
}

.github-link:hover {
    opacity: 0.6;          /* Visual feedback */
}

#reading-time {
    /* Typography */
    font-family: sans-serif;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    
    /* Colors */
    color: #888; /* Soft grey so it doesn't compete with the black title */
    background: #f4f4f4;
    
    /* Layout */
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 4px;
    margin-top: 10px;
    margin-bottom: 20px;
}

/* Optional: Adding a tiny dot or icon before the text */
#reading-time::before {
    margin-right: 6px;
    font-size: 12px;
}
#reading-time:empty {
    display: none;
}
#progress-bar {
    position: fixed;
    top: 0;
    left: 0;
    height: 5px;
    background: #1fe678;
    width: 0%;
    z-index: 1001;
}

.action-link {
    background: none;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0;
    margin-top: 15px;
    font-family: sans-serif;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #1a1a1a;
    transition: opacity 0.2s;
}

.action-link:hover {
    opacity: 0.6;
}

.action-link svg {
    margin-bottom: 2px; /* Optical alignment */
}