:root {
    --bg: #fdfdfc;
    --text: #1a1a1a;
    --muted: #6b6b6b;
    --faint: #9a9a9a;
    --rule: #ececec;
    --link-underline: #d6d6d6;
    --link-underline-hover: #1a1a1a;
    --award-bg: #fef6e1;
    --award-text: #8a5a00;
    --image-bg: #f5f5f3;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg: #131313;
        --text: #e6e4e0;
        --muted: #9d9a95;
        --faint: #6e6b66;
        --rule: #272727;
        --link-underline: #454545;
        --link-underline-hover: #e6e4e0;
        --award-bg: #33290f;
        --award-text: #d8a743;
        --image-bg: #1e1e1e;
    }
}

:root[data-theme="dark"] {
    --bg: #131313;
    --text: #e6e4e0;
    --muted: #9d9a95;
    --faint: #6e6b66;
    --rule: #272727;
    --link-underline: #454545;
    --link-underline-hover: #e6e4e0;
    --award-bg: #33290f;
    --award-text: #d8a743;
    --image-bg: #1e1e1e;
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Helvetica, Arial, sans-serif;
    background-color: var(--bg);
    color: var(--text);
    line-height: 1.65;
    font-size: 16px;
    transition: background-color 0.2s ease, color 0.2s ease;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

.container {
    max-width: 680px;
    margin: 0 auto;
    padding: 80px 28px 60px;
}

/* Header */
header {
    margin-bottom: 72px;
}

.header-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 28px;
}

.header-right {
    display: flex;
    align-items: flex-start;
    gap: 14px;
}

/* Portrait: personal photo that reveals the reflection on hover */
.portrait {
    position: relative;
    width: 112px;
    height: 112px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
}

.portrait img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    filter: grayscale(100%);
}

.portrait .portrait-main {
    object-position: 52% 18%;
}

.portrait .portrait-main {
    transition: opacity 0.35s ease;
}

.portrait:hover .portrait-main {
    opacity: 0;
}

#theme-toggle {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--muted);
    font-size: 1.05rem;
    line-height: 1;
    padding: 4px;
    transition: color 0.15s ease;
}

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

h1 {
    font-size: 1.5rem;
    font-weight: 500;
    letter-spacing: -0.005em;
    margin-bottom: 4px;
}

.location {
    color: var(--muted);
    font-size: 0.95rem;
}

nav {
    display: flex;
    flex-wrap: wrap;
    gap: 22px;
}

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

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

/* Sections */
.section {
    margin-bottom: 64px;
}

h2 {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--muted);
    text-transform: lowercase;
    margin-bottom: 24px;
    letter-spacing: 0.02em;
}

h3 {
    font-size: 1rem;
    font-weight: 500;
    line-height: 1.4;
    margin: 0;
}

p {
    margin-bottom: 14px;
}

p:last-child {
    margin-bottom: 0;
}

.muted {
    color: var(--muted);
}

.section-intro {
    color: var(--muted);
    font-size: 0.95rem;
    margin-bottom: 36px;
}

/* Links */
a {
    color: var(--text);
    text-decoration: underline;
    text-decoration-color: var(--link-underline);
    text-underline-offset: 3px;
    text-decoration-thickness: 1px;
    transition: text-decoration-color 0.15s ease;
}

a:hover {
    text-decoration-color: var(--link-underline-hover);
}

.arrow {
    display: inline-block;
    font-size: 0.85em;
    color: var(--faint);
    margin-left: 1px;
    text-decoration: none;
}

/* Entry (building, work) */
.entry {
    margin-bottom: 28px;
}

.entry:last-child {
    margin-bottom: 0;
}

/* Collapsible entries and papers */
details.entry > summary,
details.paper > summary {
    cursor: pointer;
    list-style: none;
}

details.entry > summary::-webkit-details-marker,
details.paper > summary::-webkit-details-marker {
    display: none;
}

details.entry > summary::after {
    content: "+";
    color: var(--faint);
    margin-left: 8px;
    font-size: 0.9em;
}

details.entry[open] > summary::after {
    content: "\2212";
}

details.paper > summary {
    position: relative;
    padding-right: 24px;
}

details.paper > summary::after {
    content: "+";
    color: var(--faint);
    font-size: 0.9em;
    position: absolute;
    right: 2px;
    top: 2px;
}

details.paper[open] > summary::after {
    content: "\2212";
}

details.entry > summary {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 8px 12px;
}

details.entry > p {
    margin-top: 8px;
}

.logo {
    width: 18px;
    height: 18px;
    object-fit: contain;
    border-radius: 3px;
    align-self: center;
    filter: grayscale(100%);
    opacity: 0.85;
}

.entry-header {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 8px 12px;
    margin-bottom: 6px;
}

.entry-header h3 {
    font-size: 1rem;
    font-weight: 500;
}

.entry-header h3 a {
    text-decoration: none;
}

.entry-header h3 a:hover {
    text-decoration: underline;
    text-decoration-color: var(--link-underline-hover);
    text-underline-offset: 3px;
}

.meta {
    color: var(--muted);
    font-size: 0.9rem;
}

.status {
    color: var(--muted);
    font-size: 0.85rem;
    font-style: italic;
}

.entry p {
    color: var(--text);
    font-size: 0.95rem;
}

/* Research papers */
.paper {
    padding: 20px 0;
    border-top: 1px solid var(--rule);
}

.paper:first-of-type {
    border-top: none;
    padding-top: 0;
}

.paper > summary h3 {
    display: inline;
}

.venue-inline {
    display: block;
    font-size: 0.85rem;
    color: var(--faint);
    font-style: italic;
    margin-top: 4px;
}

.paper-body {
    display: flex;
    flex-direction: row-reverse;
    gap: 20px;
    align-items: flex-start;
    margin-top: 12px;
}

.paper-text {
    flex: 1;
    min-width: 0;
}

.paper-image {
    flex-shrink: 0;
    width: 220px;
}

.paper-image img {
    width: 100%;
    height: auto;
    display: block;
    border-radius: 2px;
    background-color: var(--image-bg);
}

.paper h3 {
    font-size: 0.98rem;
    font-weight: 500;
    line-height: 1.4;
    margin-bottom: 6px;
}

.paper .authors {
    font-size: 0.85rem;
    color: var(--muted);
    margin-bottom: 2px;
}

.paper .authors strong {
    color: var(--text);
    font-weight: 500;
}

.paper .venue {
    font-size: 0.85rem;
    color: var(--faint);
    font-style: italic;
    margin-bottom: 10px;
}

.paper .venue a {
    font-style: normal;
    color: var(--muted);
}

.paper .award {
    background: var(--award-bg);
    color: var(--award-text);
    padding: 1px 7px;
    border-radius: 3px;
    font-size: 0.72rem;
    font-style: normal;
    margin-left: 4px;
    letter-spacing: 0.02em;
}

.paper .summary {
    font-size: 0.92rem;
    color: var(--muted);
    line-height: 1.55;
}

/* Essays */
.essays-list {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.essay-item time {
    font-size: 0.82rem;
    color: var(--faint);
    display: block;
    margin-bottom: 4px;
}

.essay-item a {
    text-decoration: none;
}

.essay-item h3 {
    font-size: 1rem;
    font-weight: 500;
    margin-bottom: 4px;
    display: inline-block;
}

.essay-item a:hover h3 {
    text-decoration: underline;
    text-decoration-color: var(--link-underline-hover);
    text-underline-offset: 3px;
}

.essay-item p {
    font-size: 0.9rem;
    color: var(--muted);
}

/* Collapsible sections (talks, education) */
.section-fold > summary {
    cursor: pointer;
    list-style: none;
    display: flex;
    align-items: baseline;
}

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

.section-fold > summary h2 {
    margin-bottom: 0;
}

.section-fold > summary::after {
    content: "+";
    color: var(--faint);
    margin-left: 8px;
    font-size: 0.85rem;
}

.section-fold[open] > summary::after {
    content: "\2212";
}

.section-fold[open] > summary {
    margin-bottom: 24px;
}

.redacted {
    display: inline-block;
    width: 76px;
    height: 0.9em;
    background: var(--muted);
    border-radius: 2px;
    vertical-align: -2px;
}

.equal-note {
    color: var(--faint);
    font-size: 0.9em;
}

.edu-list .logo {
    vertical-align: -3px;
    margin-right: 2px;
}

.pin {
    filter: grayscale(100%);
    font-size: 0.85em;
}

/* Nav separator before blog */
.nav-sep {
    width: 1px;
    align-self: stretch;
    background: var(--rule);
}

nav {
    align-items: center;
}

.home-link {
    text-decoration: none;
}

.post time {
    font-size: 0.82rem;
    color: var(--faint);
    display: block;
    margin-bottom: 4px;
}

.post h3 {
    margin-bottom: 8px;
}

.post p {
    font-size: 0.95rem;
}

.post-image {
    width: 100%;
    max-width: 460px;
    height: auto;
    display: block;
    margin-top: 14px;
    border-radius: 3px;
}

/* Talks */
.talks-list li {
    display: flex;
    gap: 8px;
    align-items: baseline;
}

.talks-list .meta {
    flex-shrink: 0;
}

.talk-body {
    font-size: 0.95rem;
}

/* Plain list (education) */
.plain-list {
    list-style: none;
    padding: 0;
}

.plain-list li {
    font-size: 0.95rem;
    padding: 6px 0;
    color: var(--text);
}

.plain-list .meta {
    display: inline-block;
    width: 52px;
    color: var(--faint);
    font-variant-numeric: tabular-nums;
}

/* Footer */
footer {
    margin-top: 56px;
    padding-top: 24px;
    border-top: 1px solid var(--rule);
}

.footer-links {
    display: flex;
    flex-wrap: wrap;
    gap: 18px;
    margin-bottom: 12px;
}

.footer-links a {
    color: var(--muted);
    font-size: 0.9rem;
    text-decoration: none;
}

.footer-links a:hover {
    color: var(--text);
    text-decoration: underline;
    text-decoration-color: var(--link-underline-hover);
    text-underline-offset: 3px;
}

.footer-meta {
    font-size: 0.82rem;
    color: var(--faint);
}

/* Responsive */
@media (max-width: 600px) {
    .container {
        padding: 56px 22px 48px;
    }

    header {
        margin-bottom: 56px;
    }

    .section {
        margin-bottom: 52px;
    }

    nav {
        gap: 18px;
    }

    .paper-body {
        flex-direction: column-reverse;
        gap: 14px;
    }

    .portrait {
        width: 64px;
        height: 64px;
    }

    .paper-image {
        width: 100%;
        max-width: 280px;
    }

    .entry-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 2px;
    }
}
