:root {
  --ink: #222831;
  --muted: #66717d;
  --line: #e2e7eb;
  --soft: #f5f7f8;
  --accent: #2f668f;
  --accent-dark: #214c6e;
  --accent-soft: #eaf2f7;
  --max-width: 1180px;
  --sidebar-width: 245px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--ink);
  background: #fff;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.7;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-dark); text-decoration: underline; }
img { max-width: 100%; }
code { font-family: "SFMono-Regular", Consolas, monospace; font-size: .9em; background: var(--soft); padding: .1rem .35rem; border-radius: 4px; }

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(255,255,255,.96);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}
.header-inner {
  max-width: var(--max-width);
  min-height: 64px;
  margin: 0 auto;
  padding: 0 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 30px;
}
.site-title { color: var(--ink); font-weight: 700; letter-spacing: -.02em; font-size: 1.02rem; }
.site-title:hover { text-decoration: none; }
.top-nav { display: flex; align-items: center; gap: 26px; }
.top-nav a { color: #4d5760; font-size: .93rem; font-weight: 600; padding: 20px 0 17px; border-bottom: 3px solid transparent; }
.top-nav a:hover { text-decoration: none; color: var(--accent); }
.top-nav a[aria-current="page"] { color: var(--accent); border-color: var(--accent); }
.nav-toggle { display: none; border: 0; background: transparent; width: 42px; height: 42px; padding: 9px; cursor: pointer; color: var(--ink); }
.nav-toggle svg { width: 100%; height: 100%; fill: currentColor; }

.page-shell {
  width: min(var(--max-width), calc(100% - 56px));
  margin: 0 auto;
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  gap: 68px;
  padding: 54px 0 70px;
}

.profile-sidebar { align-self: start; position: sticky; top: 108px; }
.avatar { width: 176px; height: 176px; object-fit: cover; border-radius: 50%; display: block; margin: 0 auto 23px; border: 1px solid #dfe5e8; }
.profile-names h2 { font-size: 1.22rem; margin: 0; letter-spacing: -.02em; }
.name-zh { margin: 0 0 12px; color: var(--muted); font-size: .93rem; }
.profile-title { font-weight: 650; line-height: 1.45; margin: 0 0 10px; }
.profile-bio { color: var(--muted); font-size: .91rem; line-height: 1.6; margin: 0 0 22px; }
.profile-meta { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.profile-meta li { display: grid; grid-template-columns: 18px minmax(0,1fr); align-items: start; gap: 9px; color: #4e5963; font-size: .88rem; line-height: 1.45; }
.profile-meta svg { width: 16px; height: 16px; fill: #68737d; margin-top: 2px; }
.profile-meta a { overflow-wrap: anywhere; }

.main-content { min-width: 0; }
.eyebrow { color: var(--accent); font-size: .77rem; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; margin: 0 0 9px; }
h1, h2, h3 { line-height: 1.25; letter-spacing: -.025em; }
h1 { font-size: clamp(2rem, 4vw, 3rem); margin: 0 0 20px; }
h2 { font-size: 1.55rem; margin: 0 0 18px; }
h3 { font-size: 1.06rem; }
.lead { font-family: Georgia, "Times New Roman", serif; color: #4e5963; font-size: 1.16rem; line-height: 1.75; max-width: 780px; }
.intro-section { padding: 15px 0 56px; border-bottom: 1px solid var(--line); }
.page-header { padding: 12px 0 42px; border-bottom: 1px solid var(--line); margin-bottom: 40px; }
.content-section { padding: 42px 0; border-bottom: 1px solid var(--line); }
.section-heading { display: flex; justify-content: space-between; align-items: baseline; gap: 20px; margin-bottom: 22px; }
.section-heading h2 { margin: 0; }
.section-heading > a { font-size: .88rem; font-weight: 650; }
.button-row { display: flex; gap: 12px; margin-top: 28px; flex-wrap: wrap; }
.button { appearance: none; display: inline-flex; align-items: center; justify-content: center; min-height: 40px; padding: 8px 15px; border: 1px solid #bcc7cf; border-radius: 4px; background: #fff; color: #35424d; font-weight: 700; font-size: .88rem; cursor: pointer; }
.button:hover { text-decoration: none; border-color: var(--accent); color: var(--accent); }
.button.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.button.primary:hover { background: var(--accent-dark); }

.tag-list { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 17px; }
.tag-list span { color: #415564; background: var(--accent-soft); border-radius: 2px; padding: 3px 7px; font-size: .72rem; font-weight: 650; }
.profile-stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; max-width: 460px; margin-top: 30px; }
.profile-stats div { padding: 16px 18px; border-left: 3px solid var(--accent); background: var(--soft); }
.profile-stats strong { display: block; color: var(--accent-dark); font-size: 1.5rem; line-height: 1; }
.profile-stats span { display: block; margin-top: 7px; color: var(--muted); font-size: .76rem; line-height: 1.35; }
.two-column-section { display: grid; grid-template-columns: 1fr 1fr; gap: 55px; }
.news-list, .compact-post-list { display: grid; gap: 18px; }
.news-item { display: grid; grid-template-columns: 72px 1fr; gap: 14px; }
.news-item time, .compact-post-list time { color: var(--muted); font-size: .77rem; font-weight: 700; }
.news-item p { margin: 0; font-size: .9rem; }
.compact-post-list article { padding-bottom: 17px; border-bottom: 1px solid var(--line); }
.compact-post-list article:last-child { border: 0; }
.compact-post-list h3 { margin: 3px 0 0; }

.framework-flow { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
.framework-flow span { border: 1px solid var(--line); padding: 8px 12px; border-radius: 3px; font-size: .86rem; font-weight: 650; }
.framework-flow b { color: #a4afb8; }

.archive-year { margin-bottom: 48px; }
.year-title { font-size: 1.6rem; padding-bottom: 9px; border-bottom: 1px solid var(--line); margin-bottom: 25px; }
.archive-post { margin: 0 0 31px; }
.archive-post h3 { font-size: 1.22rem; margin: 0 0 5px; }
.archive-post > p:last-child { color: #596570; margin: 8px 0 0; max-width: 760px; }
.post-meta { color: #818b94; font-size: .78rem; margin: 0; }
.search-box { display: flex; align-items: center; gap: 9px; max-width: 430px; border: 1px solid #cbd3d9; border-radius: 4px; padding: 8px 11px; margin-top: 24px; }
.search-box:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search-box svg { width: 17px; height: 17px; fill: #7b858e; flex: 0 0 auto; }
.search-box input { border: 0; outline: 0; width: 100%; font: inherit; font-size: .9rem; color: var(--ink); }
.empty-state { background: var(--soft); padding: 20px; border-radius: 4px; color: var(--muted); }

.publication-item { margin: 0 0 29px; padding-left: 16px; border-left: 3px solid var(--accent-soft); }
.publication-item h3 { font-size: 1.13rem; margin: 3px 0 6px; }
.publication-item p { margin: 3px 0; color: var(--muted); }
.pub-type { color: var(--accent); font-size: .73rem; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; }
.authors { font-style: italic; }

.article-header { padding-bottom: 30px; border-bottom: 1px solid var(--line); margin-bottom: 34px; }
.article-header h1 { max-width: 850px; }
.back-link { display: inline-block; margin-bottom: 28px; font-size: .85rem; font-weight: 650; }
.article-body { max-width: 780px; font-family: Georgia, "Times New Roman", serif; font-size: 1.05rem; color: #303840; }
.article-body h2 { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; margin: 2.3rem 0 .8rem; }
.article-body p, .article-body li { line-height: 1.85; }
.article-body .equation { font-family: "Cambria Math", Georgia, serif; text-align: center; padding: 20px; margin: 22px 0; background: var(--soft); border-radius: 4px; font-size: 1.1rem; }
.note { border-left: 3px solid var(--accent); background: var(--accent-soft); padding: 14px 17px; margin: 24px 0; }

.cv-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 24px; }
.cv-section { padding: 26px 0; border-bottom: 1px solid var(--line); }
.cv-section h2 { font-size: 1.2rem; }
.cv-entry { display: grid; grid-template-columns: 1fr 120px; gap: 28px; margin-bottom: 19px; }
.cv-entry strong { font-size: .98rem; }
.cv-entry p { color: var(--muted); margin: 3px 0 0; font-size: .9rem; }
.cv-entry time { color: var(--muted); text-align: right; font-size: .85rem; }
.cv-contact { margin: 20px 0 0; color: var(--muted); font-size: .86rem; }
.cv-skill { display: grid; grid-template-columns: 175px 1fr; gap: 22px; margin-bottom: 16px; }
.cv-skill p { margin: 0; color: var(--muted); font-size: .9rem; }
.cv-publication strong { display: block; margin-top: 4px; }
.award-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 32px; }
.award-item { display: grid; grid-template-columns: 72px 1fr; gap: 12px; align-items: start; }
.award-item time { color: var(--accent); font-size: .82rem; font-weight: 750; }
.award-item strong { font-size: .91rem; }
.award-item p { margin: 2px 0 0; color: var(--muted); font-size: .82rem; }

.gallery-timeline { display: grid; }
.gallery-year { display: grid; grid-template-columns: 78px minmax(0, 1fr); }
.gallery-year-label { position: relative; border-right: 1px solid #cbd5dc; }
.gallery-year-label::after { content: ""; position: absolute; top: 8px; right: -5px; width: 9px; height: 9px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px #fff; }
.gallery-year-label span { position: sticky; top: 88px; display: block; padding-right: 20px; color: var(--accent-dark); font-size: 1.05rem; font-weight: 800; letter-spacing: -.02em; }
.gallery-year-content { min-width: 0; padding: 0 0 52px 30px; }
.gallery-year:last-child .gallery-year-content { padding-bottom: 0; }
.gallery-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(235px, 1fr)); gap: 26px 20px; }
.gallery-card { min-width: 0; }
.gallery-open { display: block; width: 100%; padding: 0; overflow: hidden; border: 0; border-radius: 5px; background: var(--soft); cursor: zoom-in; }
.gallery-open:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
.gallery-open img { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; transition: transform .25s ease; }
.gallery-open:hover img { transform: scale(1.025); }
.gallery-caption { padding: 13px 2px 0; }
.gallery-caption h2 { margin: 0 0 4px; font-size: 1rem; }
.gallery-caption p { margin: 4px 0 0; color: var(--muted); font-size: .86rem; line-height: 1.55; }
.gallery-caption .gallery-meta { color: #7b858e; font-size: .76rem; }
.gallery-empty { padding: 48px; border: 1px dashed #cbd4da; border-radius: 6px; background: var(--soft); text-align: center; }
.gallery-empty h2 { margin-bottom: 10px; }
.gallery-empty > p:last-child { max-width: 520px; margin: 0 auto; color: var(--muted); }
.gallery-lightbox { width: min(960px, calc(100% - 40px)); max-height: calc(100vh - 40px); padding: 16px; border: 0; border-radius: 7px; background: #fff; box-shadow: 0 24px 80px rgba(18, 28, 38, .28); }
.gallery-lightbox::backdrop { background: rgba(17, 25, 33, .78); }
.gallery-lightbox img { display: block; max-width: 100%; max-height: calc(100vh - 125px); margin: 0 auto; object-fit: contain; }
.gallery-close { position: absolute; top: 8px; right: 8px; width: 36px; height: 36px; border: 1px solid var(--line); border-radius: 50%; background: rgba(255,255,255,.94); color: var(--ink); font-size: 1.5rem; line-height: 1; cursor: pointer; }
.gallery-lightbox-caption { padding: 12px 42px 0 4px; color: var(--muted); font-size: .85rem; }

.site-footer { border-top: 1px solid var(--line); padding: 27px 28px 37px; color: #7b858e; text-align: center; font-size: .78rem; }
.site-footer p { margin: 2px 0; }
.footer-small { opacity: .85; }

@media (max-width: 940px) {
  .page-shell { grid-template-columns: 190px minmax(0,1fr); gap: 38px; }
  .avatar { width: 145px; height: 145px; }
}

@media (max-width: 760px) {
  .header-inner { padding: 0 18px; }
  .nav-toggle { display: block; }
  .top-nav { display: none; position: absolute; left: 0; right: 0; top: 64px; background: #fff; border-bottom: 1px solid var(--line); padding: 9px 18px 17px; flex-direction: column; align-items: stretch; gap: 0; }
  .top-nav.is-open { display: flex; }
  .top-nav a { padding: 10px 2px; border: 0; }
  .page-shell { width: min(100% - 36px, 700px); grid-template-columns: 1fr; gap: 35px; padding-top: 35px; }
  .profile-sidebar { position: static; display: grid; grid-template-columns: 100px 1fr; column-gap: 20px; align-items: start; padding-bottom: 30px; border-bottom: 1px solid var(--line); }
  .avatar { width: 100px; height: 100px; grid-row: span 3; margin: 0; }
  .profile-names h2 { margin-top: 2px; }
  .profile-bio { grid-column: 2; }
  .profile-meta { grid-column: 1 / -1; grid-template-columns: 1fr 1fr; margin-top: 10px; }
  .two-column-section { grid-template-columns: 1fr; gap: 45px; }
  .cv-header { display: block; }
  .cv-header .button { margin-top: 15px; }
  .award-grid { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  body { font-size: 15px; }
  .profile-sidebar { grid-template-columns: 78px 1fr; column-gap: 15px; }
  .avatar { width: 78px; height: 78px; }
  .profile-meta { grid-template-columns: 1fr; }
  .gallery-year { grid-template-columns: 52px minmax(0, 1fr); }
  .gallery-year-label span { top: 76px; padding-right: 13px; font-size: .9rem; }
  .gallery-year-content { padding-left: 18px; padding-bottom: 40px; }
  .gallery-grid { grid-template-columns: 1fr; }
  .gallery-empty { padding: 34px 22px; }
  .cv-entry { grid-template-columns: 1fr; gap: 3px; }
  .cv-entry time { text-align: left; }
  .cv-skill { grid-template-columns: 1fr; gap: 3px; }
  .profile-stats { grid-template-columns: 1fr; }
}

@media print {
  .site-header, .profile-sidebar, .site-footer, .cv-header .button { display: none !important; }
  .page-shell { display: block; width: 100%; padding: 0; }
  .main-content { width: 100%; }
  a { color: inherit; }
  .cv-section { break-inside: avoid; }
}

/* Markdown article elements */
.article-body h1,
.article-body h3,
.article-body h4,
.article-body h5,
.article-body h6 {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  margin: 2rem 0 .75rem;
}
.article-body h1 { font-size: 1.9rem; }
.article-body h3 { font-size: 1.2rem; }
.article-body a { overflow-wrap: anywhere; }
.article-body img { display: block; max-width: 100%; height: auto; margin: 1.6rem auto; border-radius: 4px; }
.article-body blockquote { margin: 1.6rem 0; padding: .25rem 1.1rem; border-left: 4px solid var(--accent); background: var(--accent-soft); color: #4d5963; }
.article-body blockquote p { margin: .75rem 0; }
.article-body pre { overflow-x: auto; margin: 1.6rem 0; padding: 17px 19px; border: 1px solid #d9e0e5; border-radius: 5px; background: #f5f7f8; font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace; font-size: .88rem; line-height: 1.65; }
.article-body code { padding: .12rem .34rem; border-radius: 3px; background: #eef2f4; font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace; font-size: .9em; }
.article-body pre code { padding: 0; background: transparent; font-size: inherit; }
.article-body hr { border: 0; border-top: 1px solid var(--line); margin: 2.3rem 0; }
.article-body .table-wrap { overflow-x: auto; margin: 1.6rem 0; }
.article-body table { width: 100%; border-collapse: collapse; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; font-size: .9rem; }
.article-body th,
.article-body td { padding: 10px 12px; border: 1px solid #dbe1e5; text-align: left; vertical-align: top; }
.article-body th { background: #f4f6f7; font-weight: 700; }
.math-display { overflow-x: auto; text-align: center; margin: 1.6rem 0; padding: 12px; }
