/* ===== Base ===== */
:root {
  --text: #2b2b2b;
  --muted: #777;
  --link: #b1442f;        /* warm academic accent */
  --link-hover: #d4654d;
  --rule: #e6e6e6;
  --bg: #ffffff;
  --code-bg: #f6f6f4;
  --maxw: 820px;
}

/* Dark mode — a soft warm grey, not pure black */
:root[data-theme="dark"] {
  --text: #d7d4cd;
  --muted: #908d86;
  --link: #e08a6f;
  --link-hover: #ef9d83;
  --rule: #3b3c3f;
  --bg: #2b2c2e;
  --code-bg: #232427;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

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

.container {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 64px 24px 48px;
}

a {
  color: var(--link);
  text-decoration: none;
  transition: color 0.15s ease;
}
a:hover { color: var(--link-hover); text-decoration: underline; }

p { margin: 0 0 1em; }

/* ===== Intro ===== */
.intro {
  display: flex;
  gap: 40px;
  align-items: flex-start;
  margin-bottom: 16px;
}

.intro-photo {
  flex: 0 0 200px;
  text-align: center;
}

.intro-photo img {
  width: 200px;
  height: auto;            /* keep the photo's full aspect ratio — no cropping */
  border-radius: 6px;
  display: block;
}

.links {
  list-style: none;
  margin: 16px 0 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px 10px;
  font-size: 15px;
}
.links li::after { content: "·"; color: var(--muted); margin-left: 10px; }
.links li:last-child::after { content: ""; margin: 0; }

.intro-bio { flex: 1 1 auto; min-width: 0; }

.intro-bio h1 {
  font-family: "Lora", Georgia, serif;
  font-weight: 600;
  font-size: 32px;
  line-height: 1.2;
  margin: 0 0 6px;
}
.intro-bio h1 .zh {
  font-size: 22px;
  color: var(--muted);
  font-weight: 400;
  margin-left: 6px;
}

.affil {
  color: var(--muted);
  font-size: 16px;
  margin-bottom: 18px;
}

/* ===== Sections ===== */
.section { margin-top: 44px; }

.section h2 {
  font-family: "Lora", Georgia, serif;
  font-weight: 600;
  font-size: 22px;
  margin: 0 0 18px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--rule);
}

.note { color: var(--muted); font-size: 14px; margin-top: -8px; }

/* ===== News / timeline lists ===== */
.news, .timeline {
  list-style: none;
  margin: 0;
  padding: 0;
}
.news li, .timeline li {
  display: flex;
  gap: 16px;
  padding: 6px 0;
  align-items: baseline;
}
.news .date, .timeline .date {
  flex: 0 0 110px;
  color: var(--muted);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}
.news .item, .timeline .item { flex: 1 1 auto; }

/* ===== Publications ===== */
.pub {
  display: flex;
  gap: 22px;
  align-items: flex-start;
  margin-bottom: 28px;
}
.pub-thumb {
  flex: 0 0 220px;
  display: block;
  border: 1px solid var(--rule);
  border-radius: 4px;
  overflow: hidden;
}
.pub-thumb img {
  width: 100%;
  display: block;
  transition: transform 0.25s ease;
}
.pub-thumb:hover img { transform: scale(1.03); }

.pub-info { flex: 1 1 auto; min-width: 0; }
.pub-title { font-weight: 700; margin-bottom: 4px; }
.pub-title a { color: var(--text); }
.pub-title a:hover { color: var(--link); }
.pub-authors { font-size: 15px; margin-bottom: 4px; }
.pub-venue { color: var(--muted); font-style: italic; font-size: 15px; margin-bottom: 4px; }
.pub-links { font-size: 15px; margin-bottom: 0; }

sup { font-size: 0.7em; }

/* ===== Footer ===== */
.footer {
  margin-top: 56px;
  padding-top: 18px;
  border-top: 1px solid var(--rule);
  color: var(--muted);
  font-size: 14px;
  text-align: center;
}

/* ===== Nav (blog pages) ===== */
.nav {
  display: flex;
  align-items: baseline;
  gap: 16px;
  margin-bottom: 40px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--rule);
}
.nav .home {
  font-family: "Lora", Georgia, serif;
  font-weight: 600;
  font-size: 20px;
  color: var(--text);
}
.nav .home:hover { color: var(--link); text-decoration: none; }
.nav .crumb { color: var(--muted); }

.theme-toggle {
  margin-left: auto;
  background: none;
  border: 1px solid var(--rule);
  color: var(--muted);
  width: 34px;
  height: 34px;
  border-radius: 50%;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease;
}
.theme-toggle:hover { color: var(--link); border-color: var(--link); }

/* ===== Blog index ===== */
.blog-cat { margin-bottom: 40px; }
.blog-cat:last-child { margin-bottom: 0; }
.blog-cat > h2 {
  font-family: "Lora", Georgia, serif;
  font-weight: 600;
  font-size: 22px;
  margin: 0 0 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--rule);
}
.blog-list { list-style: none; margin: 0; padding: 0; }
.blog-list li {
  padding: 18px 0;
  border-bottom: 1px solid var(--rule);
}
.blog-list li:last-child { border-bottom: none; }
.blog-list .post-link {
  font-family: "Lora", Georgia, serif;
  font-weight: 600;
  font-size: 20px;
  color: var(--text);
}
.blog-list .post-link:hover { color: var(--link); text-decoration: none; }
.blog-list .post-date { color: var(--muted); font-size: 14px; margin: 2px 0 0; }
.blog-list .post-summary { margin: 6px 0 0; }
.blog-empty { color: var(--muted); }

/* ===== Single post ===== */
.post header { margin-bottom: 28px; }
.post h1 {
  font-family: "Lora", Georgia, serif;
  font-weight: 600;
  font-size: 30px;
  line-height: 1.25;
  margin: 0 0 6px;
}
.post .post-date { color: var(--muted); font-size: 15px; margin: 0; }
.post-body { font-size: 17px; overflow-wrap: break-word; }
.post-body h2 { font-family: "Lora", Georgia, serif; font-size: 22px; margin: 1.6em 0 0.5em; }
.post-body h3 { font-family: "Lora", Georgia, serif; font-size: 19px; margin: 1.4em 0 0.4em; }
.post-body img { max-width: 100%; height: auto; border-radius: 4px; }

/* keep over-wide content inside the column instead of stretching the page */
.post-body a { overflow-wrap: anywhere; }                 /* long URLs wrap */
.post-body table {                                        /* wide tables scroll locally */
  display: block;
  width: max-content;
  max-width: 100%;
  overflow-x: auto;
  border-collapse: collapse;
}
.post-body th, .post-body td { border: 1px solid var(--rule); padding: 6px 12px; }
.post-body mjx-container { max-width: 100%; }
.post-body mjx-container[display="true"] {                /* long display equations scroll locally */
  overflow-x: auto;
  overflow-y: hidden;
  padding: 4px 0;
}
.post-body pre, .post-body .codehilite {
  background: var(--code-bg);
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 14px 16px;
  overflow-x: auto;
  font-size: 14px;
}
.post-body .codehilite pre {
  background: none;
  border: none;
  padding: 0;
  margin: 0;
}
.post-body code {
  background: var(--code-bg);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 0.92em;
}
.post-body pre code { background: none; padding: 0; }
.post-body blockquote {
  margin: 1em 0;
  padding: 2px 16px;
  border-left: 3px solid var(--rule);
  color: var(--muted);
}
.post-back { margin-top: 48px; padding-top: 18px; border-top: 1px solid var(--rule); }

/* ===== Responsive ===== */
@media (max-width: 600px) {
  .container { padding: 40px 20px; }
  .intro { flex-direction: column; align-items: center; text-align: center; gap: 24px; }
  .intro-bio { text-align: left; }
  .news li, .timeline li { flex-direction: column; gap: 2px; }
  .news .date, .timeline .date { flex-basis: auto; }
  .pub { flex-direction: column; }
  .pub-thumb { flex-basis: auto; width: 100%; max-width: 320px; }
}
