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

html {
    scroll-behavior: smooth;
    overflow-x: hidden;
    width: 100%;
    max-width: 100%;
    background-color: #0a0a0a;
}

body {
    overflow-x: hidden;
    width: 100%;
    max-width: 100%;
    background-color: #0a0a0a;
    position: relative;
}

html[data-theme="light"],
html[data-theme="light"] body {
    background-color: #f5f0e6;
}

@media (prefers-color-scheme: light) {
    html:not([data-theme="dark"]),
    html:not([data-theme="dark"]) body {
        background-color: #f5f0e6;
    }
}


img {
    max-width: 100%;
    height: auto;
    display: block;
}

.page-wrapper {
    --bg: #0a0a0a;
    --bg-elevated: #111111;
    --text: #f5f5f5;
    --text-muted: #a3a3a3;
    --text-faint: #525252;
    --accent: #facc15;
    --accent-hover: #fde047;
    --border: #262626;
    --border-hover: #404040;
    --font-display: "Space Grotesk", system-ui, sans-serif;
    --font-mono: "JetBrains Mono", monospace;

    min-height: 100vh;
    min-height: 100dvh;
    width: 100%;
    max-width: 100%;
    display: flex;
    flex-direction: column;
    background-color: var(--bg);
    color: var(--text);
    font-family: var(--font-display);
    -webkit-font-smoothing: antialiased;
    transition: background-color 0.3s ease, color 0.3s ease;
    overflow-x: hidden;
    position: relative;
}


html[data-theme="dark"] .page-wrapper {
    --bg: #0a0a0a;
    --bg-elevated: #111111;
    --text: #f5f5f5;
    --text-muted: #a3a3a3;
    --text-faint: #525252;
    --accent: #facc15;
    --accent-hover: #fde047;
    --border: #262626;
    --border-hover: #404040;
}

@media (prefers-color-scheme: light) {
    .page-wrapper {
        --bg: #f5f0e6;
        --bg-elevated: #faf6f0;
        --text: #171717;
        --text-muted: #525252;
        --text-faint: #a3a3a3;
        --accent: #dc2626;
        --accent-hover: #b91c1c;
        --border: #e5e5e5;
        --border-hover: #d4d4d4;
    }
}

html[data-theme="light"] .page-wrapper {
    --bg: #f5f0e6;
    --bg-elevated: #faf6f0;
    --text: #171717;
    --text-muted: #525252;
    --text-faint: #a3a3a3;
    --accent: #dc2626;
    --accent-hover: #b91c1c;
    --border: #e5e5e5;
    --border-hover: #d4d4d4;
}

/* ─── THEME TOGGLE ─── */
.theme-toggle {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 200;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--bg-elevated);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.25s ease;
    color: var(--text-muted);
    font-size: 0.95rem;
}

.theme-toggle:hover {
    color: var(--accent);
    transform: scale(1.05);
}

.theme-toggle svg {
    position: absolute;
    transition: opacity 0.25s ease, transform 0.25s ease;
    pointer-events: none;
}

html[data-theme="dark"] .theme-icon-moon,
html[data-theme="light"] .theme-icon-sun {
    opacity: 0;
    transform: scale(0.8);
}

html[data-theme="dark"] .theme-icon-sun,
html[data-theme="light"] .theme-icon-moon {
    opacity: 1;
    transform: scale(1);
}

/* ─── CONTAINER ─── */
.container {
    flex: 1;
    width: 100%;
    max-width: min(900px, 100%);
    margin: 0 auto;
    padding: 2.5rem 2rem 4rem;
    display: flex;
    flex-direction: column;
    min-width: 0;
    overflow-x: hidden;
}



/* ─── HEADER ─── */
.site-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
    gap: 1rem;
    min-width: 0;
}

.logo-link {
    text-decoration: none;
    display: inline-flex;
    align-items: center;
}

.logo {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    font-weight: 500;
    letter-spacing: 0.1em;
    color: var(--accent);
    border: 1px solid var(--accent);
    padding: 0.4rem 0.7rem;
    display: inline-block;
    transition: all 0.25s ease;
    line-height: 1;
}

.logo-link:hover .logo {
    background: var(--accent);
    color: var(--bg);
}

.header-nav {
    display: flex;
    align-items: center;
    gap: 1.75rem;
    flex-wrap: wrap;
}

.header-nav a {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    letter-spacing: 0.02em;
    color: var(--text-muted);
    text-decoration: none;
    transition: color 0.25s ease;
    line-height: 1;
}

.header-nav a:hover,
.header-nav a.active {
    color: var(--accent);
}

/* ─── POST PAGE: tighten header gap ─── */
.post-page .site-header {
    margin-bottom: 1rem;
}

.back-link {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--text-muted);
    text-decoration: none;
    display: inline-block;
    margin-bottom: 1.5rem;
    transition: color 0.25s ease;
}

.back-link:hover {
    color: var(--accent);
}

/* ─── PAGE HERO ─── */
.page-hero {
    margin-bottom: 3.5rem;
}

.post-hero {
    margin-bottom: 2.5rem;
}

.section-num {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--accent);
    letter-spacing: 0.05em;
    display: block;
    margin-bottom: 0.75rem;
}

.page-title {
    font-size: clamp(2.5rem, 7vw, 4rem);
    font-weight: 600;
    letter-spacing: -0.03em;
    line-height: 1.1;
    color: var(--text);
    word-break: break-word;
}

/* ─── BLOG LIST ─── */
.blog-list {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.blog-post-item {
    padding: 1.5rem 0;
    border-top: 1px solid var(--border);
    transition: all 0.25s ease;
}

.blog-post-item:last-child {
    border-bottom: 1px solid var(--border);
}

.post-title {
    font-size: clamp(1.1rem, 2.5vw, 1.35rem);
    font-weight: 600;
    color: var(--text);
    text-decoration: none;
    display: block;
    margin-bottom: 0.4rem;
    transition: color 0.25s ease;
    letter-spacing: -0.01em;
    word-break: break-word;
}

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

.post-meta {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--text-faint);
    letter-spacing: 0.05em;
}

.post-excerpt {
    font-size: 1rem;
    line-height: 1.6;
    color: var(--text-muted);
    margin-top: 0.75rem;
    word-break: break-word;
}

/* ─── POST CONTENT (MARKDOWN) ─── */
.post-content {
    max-width: 100%;
    min-width: 0;
    overflow-wrap: break-word;
    word-break: break-word;
}

.post-content h1 {
    font-size: clamp(1.8rem, 5vw, 2.5rem);
    font-weight: 600;
    color: var(--text);
    margin-bottom: 1.5rem;
    letter-spacing: -0.02em;
    line-height: 1.2;
    word-break: break-word;
}

.post-content h2 {
    font-size: clamp(1.3rem, 3vw, 1.6rem);
    font-weight: 600;
    color: var(--text);
    margin-top: 2.5rem;
    margin-bottom: 1rem;
    letter-spacing: -0.01em;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
    line-height: 1.3;
    word-break: break-word;
}

.post-content h3 {
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--text);
    margin-top: 2rem;
    margin-bottom: 0.75rem;
    line-height: 1.3;
    word-break: break-word;
}

.post-content p {
    font-size: 1.05rem;
    line-height: 1.75;
    color: var(--text-muted);
    margin-bottom: 1.25rem;
}

.post-content a {
    color: var(--accent);
    text-decoration: underline;
    text-underline-offset: 3px;
    transition: opacity 0.2s ease;
    word-break: break-word;
}

.post-content a:hover {
    opacity: 0.8;
}

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

.post-content li {
    font-size: 1.05rem;
    line-height: 1.75;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.post-content code {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    background: var(--bg-elevated);
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    color: var(--accent);
    word-break: break-word;
}

.post-content pre {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.25rem;
    overflow-x: auto;
    max-width: 100%;
    margin-bottom: 1.5rem;
    -webkit-overflow-scrolling: touch;
}

.post-content pre code {
    background: transparent;
    padding: 0;
    color: var(--text-muted);
    font-size: 0.8rem;
    line-height: 1.6;
    word-break: normal;
    white-space: pre;
}

.post-content img {
    border-radius: 12px;
    margin: 1.5rem 0;
    border: 1px solid var(--border);
    width: 100%;
    max-width: 100%;
}

.post-content blockquote {
    border-left: 3px solid var(--accent);
    padding-left: 1.25rem;
    margin: 1.5rem 0;
    color: var(--text-muted);
    font-style: italic;
}

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

.post-content table {
    display: block;
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    border-collapse: collapse;
    margin-bottom: 1.5rem;
    font-size: 0.95rem;
    -webkit-overflow-scrolling: touch;
}

.post-content th,
.post-content td {
    padding: 0.75rem;
    border: 1px solid var(--border);
    text-align: left;
    white-space: nowrap;
}

.post-content th {
    background: var(--bg-elevated);
    font-weight: 600;
    color: var(--text);
}

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

/* ─── FOOTER ─── */
.footer {
    text-align: center;
    padding: 2rem;
    border-top: 1px solid var(--border);
    margin-top: auto;
}

.footer p {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--text-faint);
    letter-spacing: 0.05em;
}

/* ─── RESPONSIVE ─── */
@media (max-width: 640px) {
    .container {
        padding: 1.5rem 1.25rem 3rem;
    }

    .site-header {
        margin-bottom: 3rem;
        padding-bottom: 1rem;
    }

    .header-nav {
        gap: 1rem;
    }

    .header-nav a {
        font-size: 0.75rem;
    }

    .page-hero {
        margin-bottom: 2.5rem;
    }

    .post-content p,
    .post-content li {
        font-size: 1rem;
        line-height: 1.7;
    }

    .post-content pre {
        padding: 1rem;
    }

    .post-content pre code {
        font-size: 0.75rem;
    }
}

@media (max-width: 480px) {
    .header-nav {
        gap: 0.75rem;
    }

    .header-nav a {
        font-size: 0.7rem;
    }

    .page-title {
        font-size: 2rem;
    }

    .post-content img {
        border-radius: 8px;
    }

    .theme-toggle {
        bottom: 1rem;
        right: 1rem;
        width: 40px;
        height: 40px;
    }
}