html, body {
    overflow-x: hidden;
}
*, *::before, *::after {
    box-sizing: border-box;
}
body {
    max-width: 860px;
    width: 100%;
    margin: 0 auto;
    font-family: "Open Sans", sans-serif;
    font-optical-sizing: auto;
    font-weight: 400;
    font-style: normal;
    font-variation-settings: "wdth" 100;
    font-size: 16px;
    color: #282b2c;
}

/* ── Header ── */
.header-bar {
    background-color: #282b2c;
    color: white;
    margin: 0 auto;
    box-shadow: 0 2px 8px rgba(0,0,0,0.35);
}
nav {
    display: flex;
    justify-content: space-between;
    align-items: stretch;
}
.nav-left, .nav-right {
    display: flex;
    align-items: stretch;
}
.nav-left .header-a, .nav-right .header-a {
    display: flex;
}
.hbutton {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 120px;
    font-weight: 400;
    padding: 0 8px;
    transition: 0.3s;
    min-height: 3vh;
    white-space: nowrap;
}
.hbutton:hover {
    background-color: white;
    color: #282b2c;
    font-weight: 700;
}
.hbutton.small {
    min-width: 60px;
}
.header-a {
    text-decoration: none;
    color: white;
}
.header-a:hover {
    text-decoration: none;
}

/* ── Dividers & Layout ── */
hr {
    border: none;
    border-top: 1px solid #e0e0e0;
    margin: 0;
}
.content {
    margin: 0 auto;
    padding: 2% 4%;
    scroll-behavior: smooth;
}

/* ── Intro / Profile ── */
#intro {
    background-color: #f9f9f9;
    padding: 3% 4%;
}
.intro-layout {
    display: flex;
    align-items: flex-end;
    gap: 5%;
    margin-top: 1.5em;
}
.photoholder {
    flex: 0 0 30%;
}
.photoholder img {
    width: 100%;
    display: block;
    border-radius: 8px;
}
.introholder {
    flex: 1;
}

/* ── Publications ── */
.pubitemholder {
    display: flex;
    align-items: center;
    gap: 3%;
    padding: 1.5% 1%;
    border-radius: 6px;
    transition: 0.15s;
    margin-top: 1.5vh;
}
.pubitemholder:first-of-type {
    margin-top: 0;
}
.pubitemholder:hover {
    background-color: #f5f8fb;
    box-shadow: 0 2px 10px rgba(0,0,0,0.07);
    border-left: 3px solid #4a7fa5;
    padding-left: calc(1% - 3px);
}
.pubimageholder {
    flex: 0 1 18%;
    min-width: 100px;
    height: 100px;
    overflow: hidden;
    border-radius: 4px;
    position: relative;
    transition: height 0.3s ease;
}
.pubimageholder img {
    width: 100%;
    height: auto;
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    display: block;
    transition: top 0.3s ease, transform 0.3s ease;
}
.pubtextholder {
    flex: 1;
}

/* ── Blog ── */
.blogitemholder {
    border-bottom: 1px solid #e0e0e0;
}
.blogitemholder:first-child {
    border-top: 1px solid #e0e0e0;
}
.blog-title {
    padding: 12px 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 14px;
    font-size: 15px;
    font-weight: 500;
    transition: color 0.2s;
    user-select: none;
}
.blog-title::after {
    content: '▾';
    margin-left: auto;
    font-size: 12px;
    color: #aaa;
    transition: transform 0.25s;
}
.blog-title.open::after {
    transform: rotate(-180deg);
}
.blog-title:hover {
    color: #4a7fa5;
}
.blog-date {
    font-size: 12px;
    color: #aaa;
    font-weight: 400;
    white-space: nowrap;
}
.blog-content {
    display: none;
    padding: 4px 4px 16px;
    font-size: 15px;
    line-height: 1.7em;
    border-top: 1px solid #f0f0f0;
}
.blog-content.active {
    display: block;
}
.blog-content h1 {
    display: none;
}

.pub-placeholder {
    width: 100%;
    height: 100%;
    background-color: #e8e8e8;
    border-radius: 4px;
}

/* ── Mobile ── */
@media (max-width: 768px) {
    .nav-left .nav-hide-mobile {
        display: none !important;
    }
    .hbutton {
        min-width: unset;
        font-size: 13px;
        padding: 0 8px;
    }
    .hbutton.small {
        min-width: unset;
        font-size: 12px;
        padding: 0 6px;
    }
    .intro-layout {
        flex-direction: column;
        align-items: flex-start;
    }
    .photoholder {
        flex: none;
        width: 55%;
    }
    .introholder {
        min-width: unset;
        width: 100%;
    }
    .pubitemholder {
        flex-direction: column;
        gap: 8px;
    }
    .pubimageholder {
        flex: none;
        width: 55%;
        min-width: unset;
    }
    .pubtextholder {
        width: 100%;
    }
}

/* ── Scroll to top ── */
#scroll-top {
    position: fixed;
    bottom: 32px;
    right: 32px;
    width: 40px;
    height: 40px;
    background-color: #282b2c;
    color: white;
    border: none;
    border-radius: 50%;
    font-size: 18px;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
    transition: background-color 0.2s;
    z-index: 999;
}
#scroll-top.visible {
    display: flex;
}
#scroll-top:hover {
    background-color: #4a7fa5;
}

/* ── Blog content (markdown rendered) ── */
.blog-content h1, .blog-content h2, .blog-content h3 {
    border-left: none;
    padding-left: 0;
}
.blog-content h2 { font-size: 18px; margin-top: 1.4em; }
.blog-content h3 { font-size: 16px; margin-top: 1em; }
.blog-content img {
    max-width: 100%;
    border-radius: 6px;
    display: block;
    margin: 0.8em 0;
}
.blog-content code {
    background: #f3f3f3;
    padding: 1px 5px;
    border-radius: 3px;
    font-family: monospace;
    font-size: 13px;
}
.blog-content pre {
    background: #f3f3f3;
    padding: 12px 14px;
    border-radius: 6px;
    overflow-x: auto;
    margin: 0.8em 0;
}
.blog-content pre code {
    background: none;
    padding: 0;
}
.blog-content blockquote {
    border-left: 3px solid #4a7fa5;
    margin: 0.8em 0;
    padding: 0 0 0 12px;
    color: #666;
}
.blog-content .katex-display {
    overflow-x: auto;
    padding: 0.4em 0;
}

/* ── Lightbox ── */
#img-modal {
    display: none;
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.75);
    z-index: 1000;
    cursor: pointer;
    align-items: center;
    justify-content: center;
}
#img-modal.active {
    display: flex;
}
#img-modal img {
    max-width: 85vw;
    max-height: 85vh;
    border-radius: 6px;
    cursor: default;
    box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}

/* ── Footer ── */
.footer-bar {
    color: #888;
    font-size: 14px;
    margin: 0 auto;
    padding: 2% 4% 5%;
}

/* ── Links ── */
a {
    color: #4a7fa5;
    text-decoration: none;
}
a:hover {
    text-decoration: underline;
}

/* ── Badge ── */
.new-badge {
    display: inline-block;
    background-color: #f5c518;
    color: #282b2c;
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
    padding: 3px 6px;
    border-radius: 4px;
    vertical-align: middle;
    margin-right: 2px;
}

/* ── Typography ── */
h1 {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 0;
}
h2 {
    font-weight: 600;
    border-left: 3px solid #4a7fa5;
    padding-left: 10px;
}
h3 {
    font-size: 16px;
    font-weight: 600;
    margin-top: 1em;
    margin-bottom: 0.2em;
}
h4 {
    font-weight: 400;
    font-size: 15px;
    line-height: 1.7em;
    margin: 0.2em 0;
}
p {
    font-weight: 400;
    font-size: 16px;
    line-height: 1.7em;
}
p.pub {
    font-size: 14px;
    line-height: 1.6em;
    margin: 0 0 2px;
}
ul {
    margin-bottom: 0;
}
li {
    font-weight: 400;
    font-size: 16px;
    line-height: 1.5em;
    margin-bottom: 0.5em;
}
