* { box-sizing: border-box; }
.project-full { margin-bottom: 40px; scroll-margin-top: 24px; }
.project-full figure { margin: 20px 0; }
.project-full img { width: 100%; height: auto; }
.project-gallery { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.project-gallery figure:first-child { grid-column: 1 / -1; }
figcaption, .meta { font-size: 13px; color: var(--text-color); opacity: .8; }
.resource-links { display: flex; flex-wrap: wrap; gap: 8px 16px; margin: 16px 0; }
.pdf-preview { width: 100%; height: 650px; border: 1px solid var(--border-color); }
.pdf-preview.slides { height: auto; aspect-ratio: 16 / 9; }
pre { overflow-x: auto; white-space: pre-wrap; overflow-wrap: anywhere; }
.paper-links { overflow-wrap: anywhere; }
[hidden] { display: none !important; }
.blog-body { line-height: 1.8; overflow-wrap: anywhere; }
.blog-body img { max-width: 100%; }
.blog-body mjx-container[display="true"] { overflow-x: auto; overflow-y: hidden; padding: 8px 0; max-width: 100%; }
@media (max-width: 600px) { .project-gallery { grid-template-columns: 1fr; } .pdf-preview { height: 480px; } }
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; transition: none !important; } }
/* Long inline equations can scroll without widening the page. */
.blog-body mjx-container:not([display="true"]) { display: inline-block; max-width: 100%; overflow-x: auto; overflow-y: hidden; vertical-align: middle; }


/* ---------- Shared header, type and footer ---------- */
.page-title, h1, h2, .project-full h2 { font-family: var(--serif); font-weight: 500; color: var(--text-color); letter-spacing: -0.005em; }
.page-title { font-size: 34px; line-height: 1.15; margin: 0 0 28px; }
.papertitle { font-family: var(--serif); font-size: 19px; font-weight: 600; line-height: 1.35; color: var(--text-color); }
.paper_rest { color: var(--text-muted); }

.site-header { max-width: 820px; margin: 0 auto; padding: 22px 24px 0; display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.site-name { font-family: var(--serif); font-size: 19px; font-weight: 600; color: var(--text-color); white-space: nowrap; }
.site-name:hover, .site-name:focus { color: var(--text-color); text-decoration: none; }
.site-header .nav-buttons { padding: 0; gap: 4px; justify-content: flex-end; flex-wrap: nowrap; }
.site-header .nav-button { color: var(--text-muted); font-size: 15px; font-weight: 400; padding: 6px 9px; }
.site-header .nav-button:hover, .site-header .nav-button:focus { color: var(--text-color); text-decoration: none; }
.site-header .nav-button[aria-current="page"] { color: var(--text-color); font-weight: 700; }
.site-header .theme-toggle { order: 0; margin-left: 4px; color: var(--text-muted); }
.site-header .theme-toggle:hover { color: var(--text-color); }

.site-footer { margin-top: 80px; padding: 26px 0; border-top: 0; background: var(--tint-bg); text-align: left; }
.site-footer > div { padding: 0 24px; display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 24px; }
.footer-copyright, .footer-social { margin: 0; font-size: 14px; color: var(--text-faint); opacity: 1; display: block; }
.site-footer a { color: var(--text-muted); }

@media (max-width: 768px) {
  .site-header { display: block; padding: 16px 24px 0; }
  .site-header .nav-buttons { margin: 8px -24px 0; padding: 0 24px; overflow-x: auto; scrollbar-width: none; justify-content: flex-start; gap: 2px; }
  .site-header .nav-buttons::-webkit-scrollbar { display: none; }
  .site-header .nav-button { padding: 6px 8px; font-size: 15px; flex-shrink: 0; }
  .site-header .nav-button:first-child { padding-left: 0; }
  .site-header .theme-toggle { order: 0; flex-shrink: 0; transform: none; }
  .page-title { font-size: 28px; }
}

/* ---------- Homepage ---------- */
.profile-section { display: grid; grid-template-columns: minmax(0, 1fr) 190px; gap: 44px; align-items: start; margin: 0; }
.profile-text .name { font-family: var(--serif); font-size: 46px; font-weight: 500; line-height: 1.1; letter-spacing: -0.01em; color: var(--text-color); margin: 0 0 22px; text-align: left; }
.name-zh { font-family: 'Lato', Verdana, Helvetica, sans-serif; font-size: 26px; font-weight: 400; color: var(--text-faint); letter-spacing: 0.02em; margin-left: 6px; }
.profile-text .bio { font-size: 17px; line-height: 1.65; color: var(--text-muted); margin: 0 0 14px; }
.profile-text .bio strong { color: var(--text-color); }
.profile-links { display: flex; flex-wrap: wrap; gap: 6px 22px; margin-top: 20px; text-align: left; }
.profile-links a { font-weight: 700; color: var(--primary-color); }
.profile-photo { width: 190px; height: auto !important; aspect-ratio: 1; object-fit: cover; border: 0; border-radius: 6px; margin: 6px 0 0; }

.homepage-section { margin: 0; padding-top: 64px; }
.homepage-section h2 { font-family: var(--serif); font-size: 25px; font-weight: 500; text-transform: none; letter-spacing: 0; color: var(--text-color); margin: 0 0 20px; padding: 0; border: 0; }
.homepage-section h3 { margin: 0; }

.news-list li { display: grid; grid-template-columns: 92px minmax(0, 1fr); gap: 16px; color: var(--text-muted); margin-bottom: 6px !important; }
.news-date { width: auto; font-weight: 400; font-size: 15px; color: var(--text-faint); font-variant-numeric: tabular-nums; padding-top: 1px; }
.news-list strong { color: var(--text-color); }
.news-list a strong { color: inherit; }
.news-toggle, .view-all { display: inline-block; margin-top: 14px; padding: 0; background: none; border: 0; font: 700 15px 'Lato', Verdana, Helvetica, sans-serif; color: var(--primary-color); cursor: pointer; text-decoration: none; }
.news-toggle:hover, .view-all:hover { color: var(--secondary-color); text-decoration: underline; text-underline-offset: 3px; }

.homepage-section .publication-list { list-style: none !important; padding-left: 0 !important; margin: 0; }
#selected-papers-list > .selected-entry { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 28px; align-items: start; margin: 0 0 40px !important; padding: 0 !important; }
.selected-entry-thumbnail { position: relative; display: block; overflow: hidden; border-radius: 6px; background: var(--tint-bg); aspect-ratio: 4 / 3; }
.selected-entry-thumbnail img, .selected-entry-thumbnail video { position: absolute; inset: 0; width: 100%; height: 100%; max-height: none; object-fit: cover; }
.selected-entry-thumbnail video { opacity: 0; transition: opacity .25s ease; }
.selected-entry-thumbnail.playing video { opacity: 1; }
/* Paper teasers are wide figures: show them whole, centred in one shared 2:1 frame so the three line up. */
#selected-papers-list .selected-entry-thumbnail { aspect-ratio: 2 / 1; background: #fff; border: 1px solid var(--border-color, rgba(0,0,0,.08)); }
#selected-papers-list .selected-entry-thumbnail img { object-fit: contain; }
.selected-entry-body { min-width: 0; }
#selected-papers-list .papertitle { margin: 0 0 6px; }
#selected-papers-list .papertitle a { color: var(--text-color); }
.paper-venue { margin: 0 0 6px; font-size: 15px; color: var(--text-faint); }
.paper-venue strong { color: var(--text-color); }
#selected-papers-list .paper_rest { font-size: 15px; line-height: 1.55; margin: 0 0 10px; color: var(--text-muted); }
#selected-papers-list .paper_rest strong { color: var(--text-color); }
.paper-note { display: block; font-size: 14px; color: var(--text-faint); }
.authors-toggle { padding: 0; background: none; border: 0; font: inherit; color: var(--primary-color); cursor: pointer; }
#selected-papers-list .paper-links { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 18px; font-size: 15px; font-weight: 700; }
#selected-papers-list .paper-links .detail-toggle { padding: 0; background: none; border: 0; font: inherit; color: var(--primary-color); cursor: pointer; }
.paper-more summary { cursor: pointer; color: var(--text-faint); font-weight: 400; list-style: none; }
.paper-more summary::-webkit-details-marker { display: none; }
.paper-more[open] summary { color: var(--text-color); }
.paper-more span { display: inline-flex; flex-wrap: wrap; gap: 4px 14px; margin-left: 12px; }
#selected-papers-list .detail-content { margin-top: 12px; font-size: 15px; color: var(--text-muted); }

.homepage-section #projects-list { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; list-style: none; padding: 0; margin: 0; }
.homepage-section #projects-list > .selected-entry { display: block; margin: 0 !important; }
#projects-list .selected-entry-thumbnail { aspect-ratio: 3 / 2; margin-bottom: 14px; }
#projects-list h3 { font-family: var(--serif); font-size: 19px; font-weight: 600; line-height: 1.3; margin: 0 0 4px; }
#projects-list h3 a { color: var(--text-color); }
#projects-list p { margin: 0; font-size: 15.5px; color: var(--text-muted); }

.experience-item { display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; gap: 18px; align-items: start; margin: 0; padding: 10px 0; }
.experience-logo { display: block; }
.experience-logo img { display: block; width: 44px; height: 44px; object-fit: contain; border-radius: 8px; }
.experience-content h3 { font-family: 'Lato', Verdana, Helvetica, sans-serif; font-size: 16px; font-weight: 700; margin: 0; color: var(--text-color); }
.experience-content p { margin: 0; font-size: 15.5px; color: var(--text-muted); }
.experience-period { margin: 0; font-size: 15px; color: var(--text-faint); font-variant-numeric: tabular-nums; white-space: nowrap; }

@media (max-width: 768px) {
  .profile-section { display: flex; flex-direction: column-reverse; align-items: flex-start; gap: 20px; margin-top: 0; }
  .profile-photo { width: 112px; margin: 0; }
  .profile-text .name { font-size: 36px; text-align: left; }
  .name-zh { display: block; margin: 6px 0 0; font-size: 20px; }
  .profile-links { justify-content: flex-start; }
  .homepage-section { padding-top: 52px; }
}
@media (max-width: 600px) {
  .news-list li { grid-template-columns: 78px minmax(0, 1fr); gap: 10px; }
  #selected-papers-list > .selected-entry { grid-template-columns: minmax(0, 1fr); gap: 14px; }
  .homepage-section #projects-list { grid-template-columns: minmax(0, 1fr); gap: 32px; }
  .experience-item { grid-template-columns: 40px minmax(0, 1fr); gap: 14px; }
  .experience-logo img { width: 40px; height: 40px; }
  .experience-period { grid-column: 2; margin-top: -6px; }
}
/* Links inherit the serif of their heading; the global `a` rule would reset them to Lato. */
.papertitle a, #projects-list h3 a { font-family: inherit; }
#selected-papers-list .paper-links a { font-weight: 700; }
#selected-papers-list > .selected-entry:last-child { margin-bottom: 0 !important; }
#main-content.page-shell { padding-top: 40px; }
@media (max-width: 768px) { #main-content.page-shell { padding-top: 28px; } }

