html,
body {
    margin: 0;
    padding: 0;
    min-height: 100%;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
}

/* Header */

header {
    height: 56px;
    flex-shrink: 0;
    background-color: rgb(230, 235, 223);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
}

.header-inner {
    display: flex;
    align-items: center;
    height: 100%;
    padding: 0 16px;
    gap: 4px;
}

.site-title {
    font-weight: bold;
    text-decoration: none;
    color: inherit;
    margin-right: auto;
    font-size: 1rem;
}

/* Desktop nav */

#nav {
    display: flex;
    gap: 2px;
}

#nav a {
    text-decoration: none;
    color: inherit;
    padding: 6px 10px;
    border-radius: 4px;
    white-space: nowrap;
}

#nav a:hover {
    background-color: rgb(210, 218, 200);
}

#nav a.active {
    background-color: rgb(180, 195, 160);
    font-weight: bold;
}

/* Hamburger button */

#menu-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 22px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    line-height: 1;
}

#menu-toggle:hover {
    background-color: rgb(210, 218, 200);
}

/* Drawer */

#drawer {
    position: fixed;
    top: 56px;
    left: -280px;
    width: 260px;
    height: calc(100vh - 56px);
    background-color: rgb(230, 235, 223);
    transition: left 0.25s ease;
    z-index: 200;
    padding: 12px;
    box-sizing: border-box;
    overflow-y: auto;
    box-shadow: 2px 0 8px rgba(0, 0, 0, 0.15);
}

#drawer.open {
    left: 0;
}

#drawer-nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

#drawer-nav a {
    display: block;
    text-decoration: none;
    color: inherit;
    padding: 8px 10px;
    border-radius: 4px;
}

#drawer-nav a:hover {
    background-color: rgb(210, 218, 200);
}

#drawer-nav a.active {
    background-color: rgb(180, 195, 160);
    font-weight: bold;
}

#drawer-blog-section {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
}

#drawer-blog-section[hidden] {
    display: none;
}

#drawer-blog-section .blog-nav-label {
    padding: 0 10px;
}

#drawer-blog-nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

#drawer-blog-nav a {
    display: flex;
    flex-direction: column;
    text-decoration: none;
    color: inherit;
    padding: 8px 10px;
    border-radius: 4px;
}

#drawer-blog-nav a:hover {
    background-color: rgb(210, 218, 200);
}

#drawer-blog-nav a.active {
    background-color: rgb(180, 195, 160);
    font-weight: bold;
}

#drawer-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.3);
    z-index: 150;
}

#drawer-overlay.visible {
    display: block;
}

/* Main content */

main {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    gap: 24px;
}

section {
    width: 100%;
    max-width: 860px;
    min-width: 0;
    padding: 20px 16px;
    box-sizing: border-box;
}

/* Blog aside */

#blog-aside {
    width: 200px;
    flex-shrink: 0;
    box-sizing: border-box;
    position: sticky;
    top: 72px;
    margin: 20px 0;
}

#blog-aside[hidden] {
    display: none;
}

.blog-nav-label {
    font-size: 0.72rem;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #888;
    margin-bottom: 8px;
}

#blog-aside-nav {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

#blog-aside-nav a {
    display: flex;
    flex-direction: column;
    text-decoration: none;
    color: inherit;
    padding: 5px 8px;
    border-radius: 4px;
    font-size: 0.88rem;
}

#blog-aside-nav a:hover {
    background-color: rgb(210, 218, 200);
}

#blog-aside-nav a.active {
    background-color: rgb(210, 218, 200);
    font-weight: bold;
}

.blog-aside-date {
    font-size: 0.72rem;
    color: #888;
    font-weight: normal;
}

/* Post prev/next nav */

.post-nav {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    margin: 24px 0 8px;
    padding-top: 12px;
    border-top: 1px solid #ddd;
}

.post-nav:empty {
    display: none;
}

.post-nav a {
    display: flex;
    flex-direction: column;
    text-decoration: none;
    color: inherit;
    padding: 4px 8px;
    border-radius: 4px;
    max-width: 48%;
    box-sizing: border-box;
}

.post-nav a:hover {
    background-color: rgb(210, 218, 200);
}

.post-nav .post-nav-next {
    margin-left: auto;
    align-items: flex-end;
    text-align: right;
}

.post-nav-label {
    font-size: 0.72rem;
    color: #888;
}

.post-nav-title {
    font-size: 0.9rem;
}

#content {
    overflow: hidden;
}

/* KaTeX matrices default to 0.5em column padding on each side; tighten it. */
#content .katex .arraycolsep {
    width: 0.2em !important;
}

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

#content pre,
#content table {
    overflow-x: auto;
    display: block;
}

footer {
    flex-shrink: 0;
    padding: 12px 16px;
    text-align: center;
    font-size: 0.85rem;
    color: #555;
    border-top: 1px solid #ddd;
}

/* Mobile */

@media (max-width: 768px) {
    #nav {
        display: none;
    }

    #menu-toggle {
        display: block;
    }

    #blog-aside {
        display: none;
    }
}
