:root {
    --bg-color: #ffffff;
    --text-color: #1a1a1a;
    --secondary-text: #888888;
    --link-color: #1a1a1a;
    --container-width: 680px;
    --font-stack: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* Base Dark Mode (System) */
@media (prefers-color-scheme: dark) {
    :root {
        --bg-color: #0d0d0d;
        --text-color: #f1f1f1;
        --secondary-text: #7a7a7a;
        --link-color: #f1f1f1;
    }
}

/* Manual Dark/Light Overrides */
html.dark {
    --bg-color: #0d0d0d;
    --text-color: #f1f1f1;
    --secondary-text: #7a7a7a;
    --link-color: #f1f1f1;
}

html.light {
    --bg-color: #ffffff;
    --text-color: #1a1a1a;
    --secondary-text: #888888;
    --link-color: #1a1a1a;
}

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

body {
    font-family: var(--font-stack);
    line-height: 1.6;
    background-color: var(--bg-color);
    color: var(--text-color);
    padding: 3rem 1.5rem;
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    
    /* Push footer to bottom */
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

header, main, footer {
    max-width: var(--container-width);
    margin: 0 auto;
    width: 100%;
}

header {
    margin-bottom: 5rem;
}

main {
    flex: 1; /* Pushes the footer down */
}

/* Nav Bar with Left and Right sections */
nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav-left {
    display: flex;
    gap: 1.5rem;
}

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

nav a {
    text-decoration: none;
    color: var(--secondary-text);
    font-size: 0.95rem;
    transition: color 0.15s ease;
}

nav a:hover {
    color: var(--text-color);
}

/* Theme Toggle Button */
#theme-toggle {
    background: none;
    border: none;
    color: var(--secondary-text);
    cursor: pointer;
    padding: 0.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.15s ease;
}

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

/* Icon visibility based on theme */
.sun-icon { display: none; }
.moon-icon { display: block; }

.dark .sun-icon { display: block; }
.dark .moon-icon { display: none; }

/* If system is dark but no class set, show sun icon if prefers dark */
@media (prefers-color-scheme: dark) {
    html:not(.light) .sun-icon { display: block; }
    html:not(.light) .moon-icon { display: none; }
}

h1 {
    font-size: 1.15rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
    letter-spacing: -0.01em;
}

p {
    font-size: 1rem;
    margin-bottom: 2rem;
    color: var(--text-color);
}

/* Post list on Index */
ul {
    list-style: none;
}

main > ul li {
    margin-bottom: 0.75rem;
    display: flex;
    align-items: baseline;
    gap: 0.4rem;
    flex-wrap: wrap;
}

main > ul li a {
    text-decoration: none;
    color: var(--text-color);
    font-weight: 600;
}

main > ul li a:hover {
    text-decoration: underline;
}

main > ul li time {
    color: var(--secondary-text);
    font-size: 0.95rem;
}

main > ul li time::before {
    content: "(";
}

main > ul li time::after {
    content: ")";
}

/* Article Styling */
article h1 {
    font-size: 1.5rem;
    margin-bottom: 1rem;
}

article time {
    display: block;
    color: var(--secondary-text);
    margin-bottom: 2rem;
    font-size: 0.9rem;
}

article div {
    font-size: 1.05rem;
}

article div p {
    margin-bottom: 1.5rem;
}

footer {
    margin-top: 5rem;
    padding: 2rem 0;
    opacity: 0.4;
    text-align: left;
}

footer p {
    font-size: 0.85rem;
    color: var(--secondary-text);
}

@media (max-width: 600px) {
    body {
        padding: 2rem 1.25rem;
    }
    
    header {
        margin-bottom: 3.5rem;
    }
    
    .nav-left {
        gap: 1rem;
    }
}
