:root {
  --ink: #1b1b1d;
  --body: #2c2c30;
  --sec: #6b6b70;
  --rule: #e8e8ea;
  --link: #1a4fd6;
  --bg: #fff;
  --serif: 'Source Serif 4', Georgia, 'Times New Roman', serif;
  --sans: 'Inter', -apple-system, 'Helvetica Neue', system-ui, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; scroll-padding-top: 70px; }
body { background: var(--bg); color: var(--ink); font-family: var(--sans); -webkit-font-smoothing: antialiased; }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }

/* top bar */
.topbar { position: sticky; top: 0; z-index: 9; background: rgba(255, 255, 255, .94); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-bottom: 1px solid var(--rule); }
.topbar .in { max-width: 880px; margin: 0 auto; padding: 0 28px; height: 54px; display: flex; align-items: center; justify-content: space-between; }
.topbar .name { font-family: var(--serif); font-weight: 600; font-size: 18px; color: var(--ink); letter-spacing: -.005em; }
.topbar .name:hover { text-decoration: none; }
.topbar nav a { color: var(--sec); font-size: 13.5px; font-weight: 500; margin-left: 26px; }
.topbar nav a:hover { color: var(--ink); text-decoration: none; }
.topbar nav a.cv { color: var(--ink); border: 1px solid #d6d6da; border-radius: 980px; width: 56px; text-align: center; padding: 6px 0; }
.topbar nav a.cv:hover { border-color: var(--ink); }
.topbar nav { display: flex; align-items: center; }
/* language switch: sliding thumb, identical size and position on both pages */
.topbar nav a.langsw { position: relative; display: inline-flex; align-items: center; margin-left: 10px; width: 92px; height: 31px; padding: 3px; border-radius: 980px; background: #efeff1; color: var(--sec); }
.topbar nav a.langsw:hover { text-decoration: none; background: #e7e7ea; }
.langsw .thumb { position: absolute; top: 3px; left: 3px; width: 43px; height: 25px; border-radius: 980px; background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .12), 0 1px 6px rgba(0, 0, 0, .06); transition: transform .32s cubic-bezier(.3, .7, .2, 1); }
.langsw .opt { position: relative; z-index: 1; flex: 1; text-align: center; font-size: 12.5px; font-weight: 500; line-height: 25px; transition: color .32s; }
.langsw.is-zh .thumb { transform: translateX(43px); }
.langsw.is-en .opt[lang="en"], .langsw.is-zh .opt[lang="zh-CN"] { color: var(--ink); }
/* arriving from the other language: start the thumb on the old side, site.js releases it so it slides in */
.lang-arriving .langsw .thumb, .lang-arriving .langsw .opt { transition: none; }
.lang-arriving .langsw.is-zh .thumb { transform: none; }
.lang-arriving .langsw.is-en .thumb { transform: translateX(43px); }
.lang-arriving .langsw.is-zh .opt[lang="zh-CN"] { color: var(--sec); }
.lang-arriving .langsw.is-zh .opt[lang="en"] { color: var(--ink); }
.lang-arriving .langsw.is-en .opt[lang="en"] { color: var(--sec); }
.lang-arriving .langsw.is-en .opt[lang="zh-CN"] { color: var(--ink); }
@media (prefers-reduced-motion: reduce) { .langsw .thumb, .langsw .opt { transition: none; } }

/* Chinese page: Noto Serif SC / Noto Sans SC with system fallbacks */
html[lang="zh-CN"] {
  --serif: 'Source Serif 4', 'Noto Serif SC', 'Songti SC', 'PingFang SC', 'Microsoft YaHei', Georgia, serif;
  --sans: 'Inter', 'Noto Sans SC', 'PingFang SC', 'Microsoft YaHei', system-ui, sans-serif;
}
html[lang="zh-CN"] .bio { font-size: 17px; line-height: 1.85; letter-spacing: .01em; }
html[lang="zh-CN"] .entry p:not(.meta):not(.el), html[lang="zh-CN"] .proj p, html[lang="zh-CN"] .mi .desc { line-height: 1.75; }
html[lang="zh-CN"] h2 { letter-spacing: .2em; }

.wrap { max-width: 880px; margin: 0 auto; padding: 64px 28px 72px; }

/* header */
header { display: grid; grid-template-columns: 1fr 208px; gap: 56px; align-items: center; }
h1 { font-family: var(--serif); font-size: 46px; font-weight: 600; letter-spacing: -.012em; line-height: 1.1; }
.role { font-size: 15.5px; color: var(--sec); margin-top: 10px; line-height: 1.55; }
.role a { color: var(--sec); border-bottom: 1px solid #d0d0d4; }
.role a:hover { color: var(--ink); text-decoration: none; border-color: var(--ink); }
.links { margin-top: 16px; display: flex; flex-wrap: wrap; align-items: baseline; gap: 10px 22px; font-size: 13.5px; font-weight: 500; }
.links a { color: var(--ink); }
.links a span { color: var(--sec); font-weight: 400; margin-right: 5px; }
header img { width: 208px; height: 208px; border-radius: 50%; object-fit: cover; box-shadow: 0 1px 0 rgba(0, 0, 0, .04), 0 6px 24px rgba(0, 0, 0, .08); }

/* bio */
.bio { font-family: var(--serif); font-size: 18px; line-height: 1.66; margin-top: 36px; max-width: 720px; color: var(--ink); }
.bio p + p { margin-top: 14px; }
.bio a { color: var(--ink); border-bottom: 1px solid #cfcfd3; }
.bio a:hover { text-decoration: none; border-color: var(--ink); }
.bio .open { color: var(--sec); font-size: 16.5px; }

/* sections */
h2 { font-size: 13px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--sec); margin-top: 64px; padding-bottom: 12px; border-bottom: 1px solid var(--rule); }

/* experience entries */
.entry { display: grid; grid-template-columns: 184px 1fr; gap: 28px; padding: 26px 0; border-bottom: 1px solid var(--rule); }
.thumb { width: 184px; aspect-ratio: 3 / 2; border-radius: 8px; overflow: hidden; background: #f2f2f4; position: relative; display: block; }
.thumb img { width: 100%; height: 100%; object-fit: cover; transition: transform .35s ease; }
.thumb:hover img { transform: scale(1.03); }
.thumb .play { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: 36px; height: 36px; border-radius: 50%; background: rgba(255, 255, 255, .92); box-shadow: 0 2px 10px rgba(0, 0, 0, .25); }
.thumb .play::after { content: ''; position: absolute; left: 14px; top: 11px; border-left: 11px solid var(--ink); border-top: 7px solid transparent; border-bottom: 7px solid transparent; }
.entry h3 { font-family: var(--serif); font-size: 21px; font-weight: 600; letter-spacing: -.008em; line-height: 1.25; }
.meta { font-size: 13px; color: var(--sec); margin-top: 6px; }
.meta b { color: var(--ink); font-weight: 500; }
.entry p:not(.meta):not(.el) { font-size: 15px; line-height: 1.6; margin-top: 10px; color: var(--body); }
.el { margin-top: 10px; font-size: 13.5px; font-weight: 500; display: flex; flex-wrap: wrap; gap: 16px; }

/* earlier experience */
.minor { padding-top: 22px; }
.minor h4 { font-size: 12.5px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--sec); margin-bottom: 4px; }
.mi { padding: 12px 0; }
.mi + .mi { border-top: 1px solid var(--rule); }
.mi .top { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; }
.mi .top p { font-size: 15px; color: var(--body); }
.mi .top b { color: var(--ink); font-weight: 600; }
.mi .d { color: var(--sec); font-size: 13.5px; white-space: nowrap; }
.mi .desc { font-size: 14px; color: #3a3a3f; line-height: 1.55; margin-top: 4px; max-width: 700px; }

/* projects */
.projects { display: grid; grid-template-columns: 1fr 1fr; gap: 0 40px; }
.proj { padding: 18px 0; border-bottom: 1px solid var(--rule); }
.proj h3 { font-size: 15.5px; font-weight: 600; letter-spacing: -.005em; }
.proj h3 a { color: var(--ink); }
.proj h3 span { font-weight: 400; color: var(--sec); font-size: 12.5px; margin-left: 8px; }
.proj p { font-size: 14px; color: #3a3a3f; line-height: 1.55; margin-top: 5px; }
.proj .shot { display: block; margin-bottom: 11px; border-radius: 8px; overflow: hidden; background: #f2f2f4; aspect-ratio: 16 / 9; }
.proj .shot img { width: 100%; height: 100%; object-fit: cover; transition: transform .35s ease; }
.proj .shot:hover img { transform: scale(1.03); }

/* education */
.edu { padding-top: 2px; }
.school { display: grid; grid-template-columns: 52px 1fr; gap: 22px; align-items: center; padding: 20px 0; border-bottom: 1px solid var(--rule); }
.school:last-child { border-bottom: 0; }
.crest { width: 52px; height: 52px; object-fit: contain; }
.crest.block { width: 44px; height: 44px; margin: 4px; border-radius: 7px; }
.school .top { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; }
.school h3 { font-family: var(--serif); font-size: 18.5px; font-weight: 600; letter-spacing: -.005em; line-height: 1.25; }
.school .d { color: var(--sec); font-size: 13.5px; white-space: nowrap; }
.school .deg { font-size: 15px; color: var(--body); margin-top: 3px; line-height: 1.45; }
.school .s { font-size: 13.5px; color: var(--sec); margin-top: 3px; }

footer { margin-top: 64px; padding-top: 18px; border-top: 1px solid var(--rule); font-size: 12.5px; color: var(--sec); display: flex; justify-content: space-between; }
footer a { color: var(--sec); }

/* lightbox */
.lightbox { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; }
.lightbox[hidden] { display: none; }
.lb-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, .78); }
.lb-body { position: relative; width: min(92vw, 1120px); max-height: 90vh; }
.lb-body video { width: 100%; max-height: 90vh; border-radius: 10px; background: #000; display: block; }
.lb-close { position: absolute; right: -6px; top: -44px; width: 36px; height: 36px; border: 0; border-radius: 50%; background: rgba(255, 255, 255, .15); color: #fff; font-size: 22px; line-height: 36px; cursor: pointer; }
.lb-close:hover { background: rgba(255, 255, 255, .3); }
body.lb-open { overflow: hidden; }

/* mobile */
@media (max-width: 640px) {
  .topbar .in { padding: 0 18px; }
  .topbar nav a { margin-left: 14px; font-size: 13px; }
  .topbar nav > a:not(.cv):not(.langsw):nth-child(-n+2) { display: none; }
  .topbar nav a.langsw { margin-left: 8px; }
  .wrap { padding: 40px 18px 56px; }
  header { grid-template-columns: 1fr; gap: 22px; }
  header img { order: -1; width: 128px; height: 128px; }
  h1 { font-size: 36px; }
  .bio { font-size: 17px; }
  .entry { grid-template-columns: 1fr; gap: 14px; }
  .thumb { width: 100%; }
  .projects { grid-template-columns: 1fr; }
  .school { grid-template-columns: 40px 1fr; gap: 16px; align-items: start; }
  .crest { width: 40px; height: 40px; }
  .crest.block { width: 34px; height: 34px; margin: 3px; border-radius: 6px; }
  .school .top, .mi .top { flex-direction: column; gap: 2px; }
  .lb-close { right: 0; top: -42px; }
}

/* very narrow phones: keep only the language toggle and CV in the top bar */
@media (max-width: 440px) {
  .topbar nav > a:not(.cv):not(.langsw) { display: none; }
}
