:root {
  --bg: #fdfdfc;
  --surface: #ffffff;
  --surface-soft: #fafafa;
  --text: #2f3137;
  --muted: #646b76;
  --subtle: #e7e2d9;
  --accent: #244f8f;
  --accent-dark: #173b70;
  --accent-soft: #e9f0fa;
  --divider: rgba(220, 216, 208, 0.58);
  --shadow: 0 12px 32px rgba(35, 38, 45, 0.06);
  --radius: 8px;
  --radius-lg: 14px;
  --max-width: 865px;
  --nav-height: 70px;
  --space-section: 2.35rem;
}

@font-face {
  font-family: "Zhi Mang Xing Name";
  src: url("assets/fonts/ZhiMangXing-name.woff") format("woff");
  font-display: swap;
  font-style: normal;
  font-weight: 400;
  unicode-range: U+0028-0029, U+5B87, U+6E1D, U+8BB8;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(255, 255, 255, 0) 22rem),
    var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 15.5px;
  line-height: 1.55;
  text-rendering: optimizeLegibility;
}

a {
  color: var(--accent);
  text-underline-offset: 0.18em;
  transition: color 160ms ease, border-color 160ms ease, background-color 160ms ease;
}

a:hover {
  color: var(--accent-dark);
}

a:focus-visible,
button:focus-visible {
  outline: 3px solid rgba(36, 79, 143, 0.28);
  outline-offset: 3px;
  border-radius: 6px;
}

img {
  max-width: 100%;
}

.js-hide-on-error[hidden] {
  display: none !important;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255, 255, 255, 0.78);
  backdrop-filter: saturate(160%) blur(14px);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
}

.site-header::after {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 1px;
  background: var(--divider);
  content: "";
}

.nav {
  width: min(100% - 2rem, var(--max-width));
  min-height: var(--nav-height);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  padding: 0.5rem 0;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  color: var(--text);
  text-decoration: none;
  font-weight: 650;
  letter-spacing: 0;
}

.brand-logo {
  width: auto;
  height: 28px;
  max-width: 108px;
  object-fit: contain;
  display: block;
}

.brand-name {
  white-space: nowrap;
}

.chinese-name {
  font-family: "Zhi Mang Xing Name", "LingWai SC", "PingFang SC", "Noto Sans SC", "Microsoft YaHei", sans-serif;
  font-weight: 400;
}

.hero-chinese-name {
  color: var(--muted);
  font-size: 0.72em;
}

.nav-links {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 1.35rem;
  flex-wrap: wrap;
}

.nav-links a {
  color: var(--text);
  font-size: 0.94rem;
  font-weight: 520;
  text-decoration: none;
}

.nav-links a:hover,
.nav-links a:focus-visible {
  color: var(--accent);
}

main,
.site-footer {
  width: min(100% - 2rem, var(--max-width));
  margin: 0 auto;
}

.section {
  padding: var(--space-section) 0;
  scroll-margin-top: calc(var(--nav-height) + 1.5rem);
}

.research-section::before,
.paper-group + .paper-group::before,
#teaching::before,
#references::before {
  display: block;
  width: 100%;
  height: 1px;
  margin-bottom: 1.3rem;
  background: var(--divider);
  content: "";
}

.hero {
  min-height: 0;
  display: flex;
  align-items: center;
  padding-top: 1.85rem;
  padding-bottom: 1.05rem;
}

.hero-grid {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(220px, 260px) minmax(0, 1fr);
  gap: 2.2rem;
  align-items: stretch;
}

.profile-panel {
  display: grid;
  gap: 1.15rem;
  align-self: stretch;
}

.portrait-frame {
  position: relative;
  aspect-ratio: 30 / 31;
  width: 100%;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  border: 1px solid rgba(231, 226, 217, 0.82);
  border-radius: var(--radius-lg);
  background:
    linear-gradient(135deg, rgba(248, 251, 255, 0.88), rgba(250, 250, 250, 0.96)),
    var(--surface-soft);
  box-shadow: var(--shadow);
  display: grid;
  place-items: center;
}

.portrait {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  -webkit-user-drag: none;
  user-select: none;
}

.portrait-fallback {
  color: rgba(36, 79, 143, 0.62);
  font-size: 4.25rem;
  font-weight: 700;
  line-height: 1;
}

.portrait-frame.is-missing {
  min-height: 0;
}

.paper-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.hero-copy {
  max-width: 680px;
}

.eyebrow {
  margin: 0 0 0.65rem;
  color: var(--accent);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  line-height: 1.4;
  text-transform: uppercase;
}

h1,
h2,
h3,
h4,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0.45rem;
  color: var(--text);
  font-size: 2.35rem;
  line-height: 1.08;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0.4rem;
  color: #2e2d6d;
  font-size: 1.48rem;
  line-height: 1.2;
  letter-spacing: 0;
}

h3 {
  margin-bottom: 0.7rem;
  font-size: 1.08rem;
  line-height: 1.3;
}

h4 {
  margin-bottom: 0;
  font-size: 1.02rem;
  line-height: 1.35;
}

.subtitle {
  margin-bottom: 0.72rem;
  color: var(--muted);
  font-size: 1.03rem;
  line-height: 1.45;
}

.intro-text {
  color: var(--text);
  font-size: 0.96rem;
}

.intro-text p {
  margin-bottom: 0.45rem;
}

.section-heading {
  max-width: 720px;
  margin-bottom: 0.95rem;
}

.section-heading p:not(.eyebrow) {
  color: var(--muted);
  font-size: 0.98rem;
}

.paper-group + .paper-group {
  margin-top: 1.55rem;
}

.research-section {
  padding-top: 1.35rem;
  padding-bottom: 1rem;
}

#teaching,
#references {
  padding-top: 0.75rem;
}

.paper {
  padding: 0.62rem 0 0.9rem;
  background: transparent;
}

.paper + .paper {
  margin-top: 0.6rem;
}

.paper-featured {
  padding-top: 0.2rem;
}

.paper-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  align-items: center;
  color: var(--muted);
  font-size: 0.88rem;
}

.paper-heading {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.3rem 0.7rem;
  justify-content: flex-start;
  width: 100%;
}

.paper-title {
  color: var(--text);
  font-size: 1.02rem;
  font-weight: 700;
  line-height: 1.35;
  text-decoration: none;
  text-underline-offset: 0.18em;
  text-decoration-thickness: 1px;
}

.paper-title[href]:not([href=""]) {
  text-decoration: underline;
}

.paper-title[href=""] {
  cursor: default;
  pointer-events: none;
}

.paper-title:hover {
  color: var(--accent-dark);
}

.coauthors {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.35;
  text-align: left;
}

.paper-label {
  margin-left: auto;
  font-size: 0.92rem;
  font-weight: 700;
  line-height: 1.35;
  white-space: nowrap;
}

.paper-bar {
  display: flex;
  align-items: flex-start;
  flex-direction: column;
  gap: 0.42rem;
  margin-top: 0.22rem;
}

.paper-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.42rem;
  min-width: 5.15rem;
  border: 1px solid rgba(36, 79, 143, 0.18);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--accent);
  cursor: pointer;
  font: inherit;
  line-height: 1;
  padding: 0.3rem 0.78rem;
  box-shadow: 0 1px 2px rgba(35, 38, 45, 0.04);
  transition: color 160ms ease, border-color 160ms ease, background-color 160ms ease, box-shadow 160ms ease;
}

.paper-toggle::after {
  width: 0.4rem;
  height: 0.4rem;
  border-right: 1.4px solid currentColor;
  border-bottom: 1.4px solid currentColor;
  content: "";
  transform: translateY(-0.08rem) rotate(45deg);
  transition: transform 160ms ease;
}

.paper-toggle[aria-expanded="true"]::after {
  transform: translateY(0.08rem) rotate(-135deg);
}

.paper-toggle-text {
  color: var(--accent);
  font-size: 0.84rem;
  font-weight: 680;
  letter-spacing: 0;
  line-height: 1;
}

.paper-toggle:hover,
.paper-toggle:focus-visible {
  border-color: rgba(36, 79, 143, 0.34);
  background: var(--accent-soft);
  color: var(--accent-dark);
  box-shadow: 0 2px 7px rgba(35, 38, 45, 0.07);
}

.paper-toggle:hover .paper-toggle-text,
.paper-toggle:focus-visible .paper-toggle-text {
  color: var(--accent-dark);
}

.paper-details {
  margin-top: 0.5rem;
}

.paper-links {
  gap: 0.3rem;
  margin-bottom: 0.38rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.paper-links a {
  color: var(--accent);
  font-weight: 560;
  text-decoration-thickness: 1px;
}

.paper-links a:not(:last-child)::after {
  content: "\00b7";
  display: inline-block;
  margin-left: 0.3rem;
  color: var(--muted);
  font-weight: 400;
}

.abstract {
  margin-bottom: 0;
  color: var(--text);
  font-size: 0.96rem;
}

.abstract strong {
  color: var(--text);
}

.teaching-list {
  display: grid;
  gap: 0.6rem;
}

.teaching-item,
.reference-item {
  padding: 0.62rem 0 0.9rem;
}

.teaching-item h3,
.reference-item h3 {
  margin-bottom: 0.25rem;
  font-size: 1.02rem;
  font-weight: 700;
  line-height: 1.35;
}

.teaching-item p,
.reference-item p {
  margin-bottom: 0.15rem;
  color: var(--muted);
}

.references-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1.5rem;
}

.reference-item {
  min-width: 0;
}

.reference-item p {
  font-size: 0.92rem;
  overflow-wrap: anywhere;
}

.reference-role {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 400;
  white-space: nowrap;
}

.site-footer {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 2rem 0 2.5rem;
  color: var(--muted);
  font-size: 0.92rem;
}

.site-footer p {
  margin: 0;
}

/* Preserve laptop sizing, then scale the desktop layout and its contents together. */
@media screen and (min-width: 1600px) {
  :root {
    --max-width: clamp(865px, calc(60vw - 95px), 1280px);
    --nav-height: 4.375rem;
    font-size: clamp(100%, calc(37.5% + 0.625vw), 137.5%);
  }

  body {
    font-size: 0.96875rem;
  }

  .brand-logo {
    height: 1.75rem;
    max-width: 6.75rem;
  }

  .hero-grid {
    grid-template-columns: minmax(13.75rem, 16.25rem) minmax(0, 1fr);
  }

  .hero-copy {
    max-width: none;
  }
}

@media (max-width: 760px) {
  :root {
    --nav-height: 64px;
    --space-section: 1.8rem;
  }

  .nav {
    align-items: center;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 0.45rem 1rem;
    min-height: var(--nav-height);
    padding: 0.5rem 0;
  }

  .nav-links {
    justify-content: flex-start;
    gap: 0.95rem;
  }

  .references-grid {
    grid-template-columns: 1fr;
    gap: 0.6rem;
  }

  .hero {
    min-height: 0;
    padding-top: 1.1rem;
    padding-bottom: 1rem;
  }

  .hero-grid {
    grid-template-columns: 1fr;
    gap: 1.1rem;
    align-items: center;
  }

  .profile-panel {
    justify-self: center;
    width: 50%;
    max-width: 180px;
  }

  .portrait-frame,
  .portrait-frame.is-missing {
    aspect-ratio: 30 / 31;
    height: auto;
    min-height: 0;
  }

  h1 {
    font-size: 1.85rem;
  }

  h2 {
    font-size: 1.42rem;
  }

  h3 {
    font-size: 1rem;
  }

  .subtitle {
    margin-bottom: 0.48rem;
    font-size: 0.95rem;
  }

  .intro-text {
    font-size: 0.92rem;
    line-height: 1.42;
  }

  .intro-text p {
    margin-bottom: 0.3rem;
  }

  .paper-heading {
    align-items: baseline;
    flex-direction: row;
    gap: 0.3rem 0.58rem;
  }
}

@media (max-width: 640px) {
  body {
    font-size: 15px;
  }

  main,
  .nav,
  .site-footer {
    width: min(100% - 1.25rem, var(--max-width));
  }

  .brand-logo {
    height: 28px;
    max-width: 100px;
  }

  .nav-links a {
    font-size: 0.94rem;
  }

  .section {
    padding: 1.8rem 0;
  }

  .paper {
    padding: 0.8rem 0 1rem;
  }

  .paper-meta {
    gap: 0.4rem;
  }

  .site-footer {
    display: grid;
    padding-bottom: 2rem;
  }
}

@media print {
  html {
    scroll-behavior: auto;
  }

  body {
    background: #ffffff;
    color: #000000;
    font-size: 12pt;
  }

  .site-header,
  .paper-links {
    display: none;
  }

  main,
  .site-footer {
    width: 100%;
  }

  .section {
    padding: 1.5rem 0;
    border-color: #cccccc;
  }

  .hero {
    min-height: 0;
  }

  .hero-grid {
    grid-template-columns: 1fr;
  }

  .profile-panel {
    display: none;
  }

  .paper {
    break-inside: avoid;
    border-color: #cccccc;
    box-shadow: none;
  }
}
