:root {
    --background: #ffffff;
    --text: #111111;
    --text-light: #828282;
    --theme: #7538c7;
    --divider: rgba(0, 0, 0, 0.11);
    --footer-bg: #1c1c1d;
    --footer-text: #e8e8e8;
    --button-bg: #ffffff;
    --nav-height: 56px;
}

html[data-theme="dark"] {
    --background: #1c1c1d;
    --text: #e8e8e8;
    --text-light: #c6c6c6;
    --theme: #ba91ff;
    --divider: #424246;
    --footer-bg: #e8e8e8;
    --footer-text: #1c1c1d;
    --button-bg: #1c1c1d;
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    min-height: 100vh;
    margin: 0;
    padding-top: var(--nav-height);
    padding-bottom: 64px;
    background: var(--background);
    color: var(--text);
    font-family: "Roboto", "Helvetica Neue", Arial, sans-serif;
    font-size: 16px;
    font-weight: 400;
    line-height: 1.5;
}

a {
    color: var(--theme);
    text-decoration: none;
}

a:hover,
a:focus-visible {
    color: var(--theme);
    text-decoration: underline;
}

a:focus-visible,
button:focus-visible,
summary:focus-visible {
    outline: 2px solid var(--theme);
    outline-offset: 3px;
}

h1,
h2,
h3,
h4,
p,
li,
div,
span,
strong,
em,
th,
td {
    color: var(--text);
}

h1,
h2,
h3,
h4 {
    line-height: 1.2;
}

h1 {
    margin: 0 0 1.5rem;
    font-size: 2.35rem !important;
    font-weight: 300;
    letter-spacing: -0.02em;
}

h1 strong {
    font-weight: 700;
}

h2 {
    margin: 2.4rem 0 1rem;
    font-size: 1.7rem !important;
    font-weight: 400;
}

h3 {
    margin: 1.8rem 0 0.75rem;
    font-size: 1.25rem !important;
    font-weight: 500;
}

h4 {
    font-size: 1.05rem;
}

p {
    margin: 0 0 1rem;
}

ul,
ol {
    margin: 0 0 1.25rem;
    padding-left: 1.4rem;
}

li {
    margin: 0.35rem 0;
}

/* Fixed navigation */
#sidebar {
    position: fixed;
    z-index: 100;
    top: 0;
    left: 0;
    width: 100%;
    height: var(--nav-height);
    border-bottom: 1px solid var(--divider);
    background: color-mix(in srgb, var(--background) 95%, transparent);
    backdrop-filter: blur(9px);
}

.sidebar-container {
    width: min(800px, calc(100% - 2rem));
    height: 100%;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.1rem;
}

.sidebar-container h3 {
    margin: 0 !important;
    font-size: 0.9rem !important;
    font-weight: 400;
    line-height: 1;
}

.sidebar-container h3 a {
    display: block;
    padding: 1rem 0.65rem;
    color: var(--text);
    text-decoration: none;
    white-space: nowrap;
}

.sidebar-container h3 a:hover,
.sidebar-container h3 a:focus-visible,
.sidebar-container h3 a[aria-current="page"] {
    color: var(--theme);
    text-decoration: none;
}

.sidebar-container h3 a[aria-current="page"] {
    font-weight: 700;
}

.nav-toggle {
    display: none;
    width: 2.75rem;
    height: 2.75rem;
    padding: 0.7rem;
    border: 0;
    background: transparent;
    cursor: pointer;
}

.nav-toggle span {
    display: block;
    width: 22px;
    height: 2px;
    margin-bottom: 4px;
    border-radius: 1px;
    background: var(--text);
    transition: transform 0.18s ease, opacity 0.18s ease;
}

.theme-toggle {
    width: 2.35rem;
    height: 2.35rem;
    margin-left: 0.25rem;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--text);
    cursor: pointer;
    font-size: 1rem;
}

.theme-toggle:hover {
    color: var(--theme);
    background: var(--divider);
}

/* Main content */
#main-wrapper {
    width: min(800px, calc(100% - 2rem));
    margin: 0 auto;
    padding: 3.2rem 0 5rem;
}

#header,
.clear {
    display: none;
}

#content {
    min-width: 0;
}

#content > :first-child {
    margin-top: 0;
}

.post-header {
    margin-bottom: 1rem;
}

.profile-copy {
    max-width: 55rem;
}

.address {
    margin: -0.7rem 0 1.5rem;
    color: var(--text-light);
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.8rem;
}

.section-link {
    color: inherit;
}

.section-link:hover {
    color: var(--theme);
}

.current-list {
    margin-bottom: 2.5rem;
}

.updated {
    margin-top: 2.5rem;
    color: var(--text-light);
    font-size: 0.78rem !important;
}

/* Year dividers and archive lists */
.year-heading {
    margin: 2rem 0 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--divider);
    color: var(--theme);
    font-size: 1.05rem !important;
    font-weight: 500;
    text-align: left;
}

.archive-list {
    margin: 0 0 2rem;
    padding: 0;
    list-style: none;
}

.archive-list li {
    margin: 0 0 1rem;
}

.archive-list .title {
    display: block;
    color: var(--text);
    font-weight: 700;
}

.archive-list a.title:hover {
    color: var(--theme);
    text-decoration: none;
}

.archive-list .meta {
    color: var(--text-light);
    font-size: 0.85rem;
}

/* Publication styling modeled on the reference site. */
.publications {
    margin-top: 2rem;
}

.bibliography {
    margin: 0;
    padding: 0;
    list-style: none;
}

.bibliography > li {
    margin: 0 0 1.35rem;
}

.publication-entry {
    display: grid;
    grid-template-columns: 105px minmax(0, 1fr);
    gap: 1.1rem;
    align-items: start;
}

.pub-preview {
    display: grid;
    width: 105px;
    min-height: 72px;
    place-items: center;
    border: 1px solid var(--divider);
    border-radius: 3px;
    background:
        linear-gradient(135deg, color-mix(in srgb, var(--theme) 9%, var(--background)), var(--background));
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.12);
    color: var(--theme);
    font-family: Georgia, "Times New Roman", serif;
    font-size: 1.3rem;
    text-align: center;
}

.pub-preview--formula {
    padding: 0.35rem;
    font-size: 0.9rem;
}

.pub-preview--formula mjx-container {
    margin: 0 !important;
    max-width: 100%;
}

.pub-preview--formula mjx-container svg {
    max-width: 100%;
    height: auto;
}

.pub-title {
    margin-bottom: 0.12rem;
    font-weight: 700;
    line-height: 1.35;
}

.pub-authors,
.pub-periodical {
    font-size: 0.9rem;
}

.pub-authors em {
    border-bottom: 1px solid currentColor;
    font-style: normal;
}

.pub-periodical {
    color: var(--text-light);
}

.pub-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-top: 0.5rem;
}

.pub-button,
details.abstract > summary {
    display: inline-block;
    padding: 0.2rem 0.85rem;
    border: 1px solid var(--text);
    border-radius: 2px;
    background: var(--button-bg);
    color: var(--text);
    cursor: pointer;
    font-size: 0.72rem;
    line-height: 1.4;
    text-decoration: none;
}

.pub-button:hover,
.pub-button:focus-visible,
details.abstract > summary:hover {
    border-color: var(--theme);
    color: var(--theme);
    text-decoration: none;
}

details.abstract {
    display: contents;
}

details.abstract > summary {
    list-style: none;
}

details.abstract > summary::-webkit-details-marker {
    display: none;
}

.abstract-body {
    flex-basis: 100%;
    margin-top: 0.25rem;
    padding: 0.65rem 0.8rem;
    border: 1px dashed var(--text);
    font-size: 0.84rem;
    line-height: 1.45;
    text-align: justify;
}

.abstract-body p:last-child {
    margin-bottom: 0;
}

/* Long seminar and course pages */
.eyebrow {
    margin: -0.9rem 0 1.5rem;
    color: var(--text-light);
    font-size: 0.85rem;
}

.recent-posts {
    margin-top: 2.5rem;
}

.recent-posts h1 {
    margin: 2.4rem 0 1rem;
    font-size: 1.7rem !important;
    font-weight: 400;
}

table {
    display: block;
    width: 100%;
    margin: 1.5rem 0;
    overflow-x: auto;
    border-collapse: collapse;
    font-size: 0.86rem;
    line-height: 1.45;
}

th,
td {
    min-width: 6.5rem;
    padding: 0.65rem 0.55rem;
    border-bottom: 1px solid var(--divider);
    text-align: left;
    vertical-align: top;
}

th {
    font-weight: 700;
}

td:nth-child(1),
td:nth-child(2) {
    white-space: nowrap;
}

mjx-container {
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
}

/* Footer */
.site-footer {
    position: fixed;
    z-index: 90;
    right: 0;
    bottom: 0;
    left: 0;
    background: var(--footer-bg);
}

.site-footer-inner {
    width: min(800px, calc(100% - 2rem));
    margin: 0 auto;
    padding: 0.55rem 0;
    color: var(--footer-text);
    font-size: 0.75rem;
}

.site-footer-inner span,
.site-footer-inner a {
    color: var(--footer-text);
}

.site-footer-inner a:hover {
    color: var(--theme);
    text-decoration: none;
}

::selection {
    background: color-mix(in srgb, var(--theme) 25%, transparent);
}

@media (max-width: 700px) {
    .sidebar-container {
        width: calc(100% - 1rem);
        justify-content: flex-end;
    }

    .nav-toggle {
        display: block;
        flex: 0 0 auto;
    }

    .sidebar-container h3,
    .sidebar-container .theme-toggle {
        display: none;
    }

    .sidebar-container.is-open {
        position: absolute;
        top: 0;
        right: 0;
        width: min(18rem, 100%);
        height: auto;
        min-height: 100vh;
        padding: 0.4rem 1rem 1.5rem;
        flex-direction: column;
        align-items: stretch;
        justify-content: flex-start;
        border-left: 1px solid var(--divider);
        background: var(--background);
        box-shadow: -8px 0 24px rgba(0, 0, 0, 0.08);
    }

    .sidebar-container.is-open .nav-toggle {
        align-self: flex-end;
    }

    .sidebar-container.is-open .nav-toggle span:first-child {
        transform: translateY(6px) rotate(45deg);
    }

    .sidebar-container.is-open .nav-toggle span:nth-child(2) {
        opacity: 0;
    }

    .sidebar-container.is-open .nav-toggle span:last-child {
        transform: translateY(-6px) rotate(-45deg);
    }

    .sidebar-container.is-open h3,
    .sidebar-container.is-open .theme-toggle {
        display: block;
    }

    .sidebar-container.is-open h3 a {
        padding: 0.75rem 0.5rem;
        text-align: right;
    }

    .sidebar-container.is-open .theme-toggle {
        align-self: flex-end;
        margin-top: 0.4rem;
    }

    #main-wrapper {
        width: min(100% - 1.5rem, 800px);
        padding-top: 2.4rem;
    }

    h1 {
        font-size: 2rem !important;
    }

    .publication-entry {
        grid-template-columns: 82px minmax(0, 1fr);
        gap: 0.8rem;
    }

    .pub-preview {
        width: 82px;
        min-height: 62px;
        font-size: 1.05rem;
    }

    .site-footer {
        position: static;
    }

    body {
        padding-bottom: 0;
    }
}

@media (max-width: 460px) {
    .publication-entry {
        grid-template-columns: 1fr;
    }

    .pub-preview {
        display: none;
    }

    .site-footer-inner {
        width: calc(100% - 1.5rem);
    }
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }
}
