:root {
  --mit-red: #A31F34;
  --dark-red: #8A1A2C;
  --light-gray: #f5f5f5;
  --text: #222;
  --muted: #555;
  --link: #A31F34;
  --link-hover: #8A1A2C;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", sans-serif;
  color: var(--text);
  background: white;
  line-height: 1.6;
}
a { color: var(--link); text-decoration: none; }
a:hover { color: var(--link-hover); text-decoration: underline; text-underline-offset: 2px; }

/* ===== Header: white bar with red bottom line ===== */
.site-header {
  background: #fff;
  color: var(--text);
  padding: 10px 20px;
  position: sticky;
  top: 0;
  z-index: 10;
  border-bottom: 3px solid var(--mit-red);
}
.site-header .bar {
  display: flex;
  align-items: center;
  max-width: 1100px;
  margin: 0 auto;
}
.brand { display: flex; align-items: center; gap: 12px; }

/* The MIT logo PNG is 3840x2160 with a transparent background; the artwork
   itself occupies only the middle 41.6% of the height (measured bbox
   y 630-1528, x 19-3820, aspect 4.23:1) and is vertically centered.
   The mask clips those empty bands so the mark renders at ~144x34px. */
.brand .logo-mask {
  height: 34px;
  width: 144px;
  overflow: hidden;
  position: relative;
  flex-shrink: 0;
  display: block;
}
.brand .logo-mask img {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 145px;                 /* -> artwork renders 144px wide, 34px tall */
  height: auto;
  transform: translate(-50%, -50%);
  display: block;
}


/* ===== Wrapper ===== */
.wrapper {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 20px;
}
main.wrapper { padding-bottom: 20px; }

/* ===== Hero ===== */
.wrapper .hero {
  display: flex !important;
  justify-content: center;
  align-items: center;
  gap: 24px;
  text-align: center;
  width: 100%;
  flex-wrap: nowrap;
  margin: 28px 0 8px;
}
.avatar {
  width: 210px;
  height: 250px;
  border-radius: 10%;
  object-fit: cover;
  border: 3px solid var(--light-gray);
  background: var(--light-gray);
  flex-shrink: 0;
}
.hero-content { flex: 1; min-width: 0; }

@media (max-width: 720px) {
  .wrapper .hero {
    flex-direction: column-reverse;
    align-items: center;
    gap: 16px;
  }
  .avatar { justify-self: center; }
}

h1, h2, h3 { margin: 0.2em 0 0.4em; }
h1 { font-size: 3.1rem; line-height: 1.4; }
h2 { font-size: 1.5rem; border-bottom: 2px solid var(--light-gray); padding-bottom: 6px; }

.kicker {
  color: var(--muted);
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  font-size: 1.0rem;
}

/* ===== Contact chips ===== */
.link-row {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  margin-top: 20px;
  justify-content: center;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border: 1px solid #e6e6e6;
  border-radius: 999px;
  font-size: 0.95rem;
  background: #fff;
  transition: border-color .15s ease;
}
.chip:hover { border-color: #d9d9d9; text-decoration: none; }
.chip svg { width: 18px; height: 18px; flex: 0 0 18px; }

/* ===== Two-column: Research Interests + Education (Wenyueh layout) ===== */
.two-col {
  display: grid;
  grid-template-columns: 5fr 7fr;   /* col-md-5 / col-md-7 */
  gap: 32px;
  margin-top: 26px;
}
@media (max-width: 767px) {
  .two-col { grid-template-columns: 1fr; gap: 24px; }
}
.section-subheading {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 12px;
  border-bottom: 2px solid var(--light-gray);
  padding-bottom: 6px;
}
.ul-interests, .ul-edu {
  list-style: none;
  padding-left: 1.6rem;
  margin: 0;
}
.ul-interests li, .ul-edu li {
  position: relative;
  margin-bottom: 12px;
}
.ul-interests li .fa-li, .ul-edu li .fa-li {
  position: absolute;
  left: -1.6rem;
  top: 0.35em;
  width: 1.1rem;
  color: var(--mit-red);
  text-align: center;
  line-height: 1;
}
.ul-interests li .fa-li svg, .ul-edu li .fa-li svg {
  width: 15px;
  height: 15px;
  vertical-align: baseline;
}
.ul-interests .description, .ul-edu .description { margin: 0; }
.ul-interests .course, .ul-edu .course {
  margin: 0;
  font-weight: 700;
  line-height: 1.4;
}

.ul-interests .institution, .ul-edu .institution {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1.4;
}
.ul-interests .details, .ul-edu .details {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.4;
}
.ul-edu .date {
  font-weight: 400;
  color: var(--muted);
  font-size: 0.95rem;
}

/* ===== Publication list (layout from publications.html) ===== */
.pub-section { margin-top: 8px; }
/* Subtitle inside Publication: smaller than the h2 so the hierarchy reads. */
.pub-subheading {
  font-size: 1.12rem;
  font-weight: 700;
  color: var(--mit-red);
  margin: 22px 0 10px;
}
.pub-subheading:first-of-type { margin-top: 10px; }
.pub-subheading .subheading-note {
  font-weight: 400;
  font-size: 0.86em;
  color: var(--muted);
}
.pub-list { list-style: none; padding-left: 0; }
.pub-item { margin: 0 0 16px; }
.pub-item .status { color: var(--muted); }
.note { color: var(--muted); font-size: .95rem; }
.venue { font-style: italic; }
.year { color: var(--muted); }
.badge {
  display: inline-block;
  padding: 2px 8px;
  background: var(--light-gray);
  border-radius: 999px;
  font-size: .8rem;
  color: var(--muted);
}

/* ===== Footer / misc ===== */
footer {
  border-top: 1px solid #eee;
  padding: 16px 0 40px;
  text-align: center;
  color: var(--muted);
}
.cta {
  display: inline-block;
  background: var(--mit-red);
  color: #fff;
  padding: 10px 14px;
  border-radius: 10px;
  font-weight: 600;
}
.cta:hover { background: var(--dark-red); color: #fff; text-decoration: none; }
ul { padding-left: 1.1rem; }

/* Publication tags used inside Research Interests */
.pub-tag {
  padding: 2px 8px;
  background: #e0e0e0;
  color: var(--mit-red);
  font-size: 0.8em;
  border-radius: 4px;
  text-decoration: none;
}
.pub-tag:hover { background: #d4d4d4; text-decoration: none; }
.pub-tag + .pub-tag { margin-left: 4px; }

/* ===== Blog post page ===== */
.post {
  max-width: 760px;
  padding-bottom: 32px;
}
.post-back {
  display: inline-block;
  margin: 24px 0 4px;
  font-size: 0.9rem;
}
.post-title {
  font-size: 2.1rem;
  line-height: 1.25;
  margin: 10px 0 10px;
}
.post-meta {
  color: var(--muted);
  font-size: 0.92rem;
  margin: 0 0 26px;
  padding-bottom: 14px;
  border-bottom: 2px solid var(--light-gray);
}
.post-lede {
  font-size: 1.08rem;
  color: #333;
}
.post h2 {
  font-size: 1.32rem;
  margin-top: 34px;
  border-bottom: none;
  padding-bottom: 0;
}
.post h3 {
  font-size: 1.05rem;
  color: var(--mit-red);
  margin-top: 22px;
}
.post p { margin: 0 0 14px; }
.post ul { margin: 0 0 14px; padding-left: 1.3rem; }
.post li { margin-bottom: 8px; }
.post-footnote {
  margin-top: 34px;
  padding-top: 14px;
  border-top: 2px solid var(--light-gray);
  color: var(--muted);
  font-size: 0.92rem;
}

.coursework {
  margin-top: 9px;
}

.coursework-title {
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1.4;
  margin-bottom: 5px;
}

.coursework-grid {
  display: grid;
  grid-template-columns: 0.88fr 1.12fr;
  column-gap: 14px;
  row-gap: 3px;
  color: var(--muted);
  font-size: 0.90rem;
  line-height: 1.4;
}
@media (max-width: 700px) {
  .coursework-grid {
    grid-template-columns: 1fr;
  }
}
.course-item {
  display: grid;
  grid-template-columns: 3.8em 1fr;
  column-gap: 4px;
  align-items: start;
}

.course-code {
  white-space: nowrap;
}

.course-name {
  min-width: 0;
}

/* ===== Blog post: language toggle ===== */
.lang-switch {
  display: inline-flex;
  border: 1px solid #e0e0e0;
  border-radius: 999px;
  overflow: hidden;
  margin: 0 0 18px;
  font-size: 0.88rem;
}
.lang-switch a {
  padding: 5px 14px;
  color: var(--muted);
  background: #fff;
  transition: background .15s ease, color .15s ease;
  white-space: nowrap;
}
.lang-switch a + a { border-left: 1px solid #e0e0e0; }
.lang-switch a:hover { background: var(--light-gray); text-decoration: none; }
.lang-switch a[aria-current="page"] {
  background: var(--mit-red);
  color: #fff;
  font-weight: 600;
}

/* ===== Blog post: figures ===== */
.post-figure {
  margin: 26px 0 28px;
  text-align: center;
}
.post-figure img {
  max-width: 100%;
  height: auto;
  border: 1px solid #ececec;
  border-radius: 4px;
  background: #fff;
}
.post-figure figcaption {
  margin-top: 10px;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.5;
  text-align: left;
}
.post-figure figcaption strong { color: var(--text); }
.post-figure.figure-wide img { border: none; }

/* ===== Blog post: tables ===== */
.table-wrap {
  margin: 26px 0 28px;
  overflow-x: auto;
}
.post-table {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.87rem;
  line-height: 1.45;
}
.post-table caption {
  caption-side: bottom;
  margin-top: 10px;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.5;
  text-align: left;
}
.post-table caption strong { color: var(--text); }
.post-table th,
.post-table td {
  padding: 7px 10px;
  text-align: right;
  white-space: nowrap;
}
.post-table th:first-child,
.post-table td:first-child,
.post-table th:nth-child(2),
.post-table td:nth-child(2) {
  text-align: left;
}
.post-table thead th {
  border-bottom: 2px solid var(--mit-red);
  font-weight: 700;
}
.post-table tbody td { border-bottom: 1px solid #eee; }
/* Highlight the FSOL rows. Bolding marks the best value per column
   (via <strong> on the winning cells), so it must not come from the row. */
.post-table tbody tr.row-ours td,
.post-table tbody tr.row-ours th {
  background: #fdf5f6;
}
.post-table tbody tr.group-start td { border-top: 1px solid #ddd; }

/* ===== Blog post: equations ===== */
.post-eq {
  margin: 18px 0;
  text-align: center;
  font-size: 1.02rem;
  overflow-x: auto;
}

/* ===== Blog post: citation block ===== */
.cite-block { margin: 20px 0 0; }
.cite-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--light-gray);
  border: 1px solid #e4e4e4;
  border-bottom: none;
  border-radius: 6px 6px 0 0;
  padding: 7px 12px;
  font-size: 0.85rem;
  color: var(--muted);
}
.cite-copy {
  border: 1px solid #d8d8d8;
  background: #fff;
  color: var(--mit-red);
  border-radius: 5px;
  padding: 4px 11px;
  font-size: 0.82rem;
  font-family: inherit;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease;
}
.cite-copy:hover { background: var(--light-gray); border-color: var(--mit-red); }
.cite-block pre {
  margin: 0;
  padding: 14px 12px;
  background: #fcfcfc;
  border: 1px solid #e4e4e4;
  border-radius: 0 0 6px 6px;
  overflow-x: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.82rem;
  line-height: 1.55;
  tab-size: 2;
}
.cite-block code { font-family: inherit; }

/* Narrower figure for single-panel plots (≈2/3 page width) */
.post-figure.figure-two-thirds img {
  width: 66%;
  min-width: 320px;
}
@media (max-width: 640px) {
  .post-figure.figure-two-thirds img { width: 100%; min-width: 0; }
}

/* KaTeX display equations */
.post-eq .katex-display { margin: 0; }
.post-eq .katex { font-size: 1.12em; }

/* Merged category column (rowspan) in post tables */
.post-table .cat-cell {
  vertical-align: middle;
  text-align: left;
  font-weight: 700;
  white-space: nowrap;
  border-right: 1px solid #e8e8e8;
}
/* Group separators span the full row, including the merged category cell */
.post-table tbody tr.group-start > th,
.post-table tbody tr.group-start > td {
  border-top: 1px solid #ddd;
}
/* A merged cell spans its whole group, so it must not draw the per-row
   bottom rule that .post-table tbody td uses -- that line would cut across
   the group. Group edges come from tr.group-start instead. */
.post-table tbody th.cat-cell { border-bottom: none; }


/* ===== Blog post: author list and affiliations ===== */
.post-authors {
  margin: 0 0 10px;
  font-size: 0.97rem;
  line-height: 1.6;
  color: var(--text);
}
.post-authors .author-me { font-weight: 700; }
.post-authors sup {
  font-size: 0.72em;
  color: var(--mit-red);
  padding-left: 1px;
}
.post-affil {
  margin: 0 0 6px;
  font-size: 0.86rem;
  line-height: 1.65;
  color: var(--muted);
}
.post-affil li { list-style: none; }
.post-affil ol { margin: 0; padding: 0; }
.post-affil sup {
  font-size: 0.78em;
  color: var(--mit-red);
  margin-right: 3px;
}
.post-venue {
  color: var(--muted);
  font-size: 0.92rem;
  margin: 0 0 26px;
  padding-bottom: 14px;
  border-bottom: 2px solid var(--light-gray);
}
