:root {
  --ink: #182230;
  --muted: #667085;
  --faint: #98a2b3;
  --blue: #2563eb;
  --blue-pale: #eff6ff;
  --line: #e3e8ef;
  --line-strong: #cfd8e5;
  --paper: #ffffff;
  --canvas: #f7f9fc;
  --ease: cubic-bezier(.2, .8, .2, 1);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--canvas);
  font-family: "Helvetica Neue", "SF Pro Display", "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; }
::selection { color: #fff; background: var(--blue); }

.shell { width: min(1020px, calc(100% - 56px)); margin-inline: auto; }
.identity { width: max-content; display: inline-flex; align-items: center; gap: 11px; }
.identity-mark {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  color: #fff;
  background: var(--blue);
  border-radius: 9px;
  font-size: 13px;
  font-weight: 700;
}
.identity > span:last-child { display: grid; gap: 1px; }
.identity strong { font-size: 14px; letter-spacing: -.01em; }
.identity small { color: var(--muted); font-size: 11px; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  height: 64px;
  padding-inline: max(28px, calc((100% - 1020px) / 2));
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  background: rgba(255, 255, 255, .9);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}
.topbar nav { display: flex; align-items: center; gap: 28px; }
.topbar nav a, .contact-link { color: #475467; font-size: 13px; font-weight: 600; }
.topbar nav a:hover, .topbar nav a.active, .contact-link:hover { color: var(--blue); }
.contact-link { justify-self: end; }
.overline { margin: 0 0 16px; color: var(--blue); font-size: 12px; line-height: 1; font-weight: 700; letter-spacing: .14em; }

/* Home */
.home-page { min-height: 100svh; display: flex; flex-direction: column; background: #fff; }
.home-header { min-height: 66px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.home-location { color: var(--muted); font-size: 13px; }
.home-main { flex: 1; padding-block: clamp(24px, 4vh, 38px) 24px; }
.home-thoughts {
  position: relative;
  margin: 0 0 22px;
  padding: 2px 0 2px 20px;
  overflow: hidden;
}
.home-thoughts::before {
  content: "";
  position: absolute;
  left: 0;
  top: 3px;
  width: 3px;
  height: calc(100% - 6px);
  background: var(--blue);
  border-radius: 3px;
  transform-origin: top;
  animation: thoughtLine .7s .12s var(--ease) both;
}
.home-thoughts p {
  margin: 0;
  width: max-content;
  max-width: 100%;
  color: var(--ink);
  font-size: clamp(18px, 2vw, 24px);
  line-height: 1.45;
  font-weight: 650;
  letter-spacing: -.025em;
  opacity: 0;
  animation: thoughtEnter .7s var(--ease) forwards;
}
.home-thoughts p:nth-child(1) { animation-delay: .12s; }
.home-thoughts p:nth-child(2) { animation-delay: .28s; }
.home-thoughts p:nth-child(3) { animation-delay: .44s; color: var(--muted); }
.home-thoughts p::after {
  content: "";
  display: inline-block;
  width: 0;
  height: 1px;
  margin-left: 10px;
  vertical-align: middle;
  background: #b8cdfa;
  animation: thoughtTrail .8s .85s var(--ease) forwards;
}
@keyframes thoughtEnter {
  from { opacity: 0; transform: translateY(14px); filter: blur(3px); }
  to { opacity: 1; transform: translateY(0); filter: blur(0); }
}
@keyframes thoughtLine {
  from { transform: scaleY(0); opacity: 0; }
  to { transform: scaleY(1); opacity: 1; }
}
@keyframes thoughtTrail {
  from { width: 0; opacity: 0; }
  to { width: 34px; opacity: 1; }
}
.portal-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.portal-card {
  min-height: 152px;
  padding: 22px 24px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-rows: auto 1fr;
  column-gap: 20px;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(16, 24, 40, .035);
  transition: border-color .25s ease, background .25s ease, box-shadow .25s ease, transform .25s var(--ease);
}
.portal-index { align-self: start; color: var(--faint); font-size: 12px; font-weight: 700; letter-spacing: .08em; }
.portal-card > div { align-self: end; }
.portal-card h2 { margin: 0 0 6px; font-size: clamp(21px, 2vw, 26px); line-height: 1.15; letter-spacing: -.035em; }
.portal-card p { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.6; }
.portal-card b { grid-column: 2; grid-row: 1 / 3; align-self: end; color: var(--blue); font-size: 24px; font-weight: 400; transition: transform .25s var(--ease); }
.portal-card:hover { background: #fbfdff; border-color: #b8cdfa; box-shadow: 0 14px 34px rgba(37, 99, 235, .08); transform: translateY(-2px); }
.portal-card:hover b { transform: translate(4px, -2px); }

.home-contact {
  position: relative;
  margin-top: 12px;
  padding: 20px 24px;
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 22px;
  align-items: center;
  background: var(--blue-pale);
  border: 1px solid #d8e7ff;
  border-radius: 12px;
}
.home-contact > div > p { margin: 0 0 7px; color: var(--blue); font-size: 12px; font-weight: 700; letter-spacing: .14em; }
.home-contact h2 { margin: 0; font-size: 20px; letter-spacing: -.025em; }
.home-contact dl { margin: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.home-contact dl > div { min-width: 0; padding-left: 20px; border-left: 1px solid #c8daf7; }
.home-contact dt { margin-bottom: 6px; color: var(--muted); font-size: 12px; }
.home-contact dd { margin: 0; font-size: 14px; font-weight: 600; overflow-wrap: anywhere; }
.home-contact a:hover { color: var(--blue); }
.home-footer { min-height: 54px; display: flex; align-items: center; color: #778398; border-top: 1px solid var(--line); font-size: 12px; }
.home-footer a:hover, .footer a:hover { color: var(--blue); }

.wechat-contact { position: relative; }
.wechat-trigger { margin: -5px 0; padding: 5px 6px 5px 0; display: inline-flex; align-items: center; gap: 8px; color: var(--ink); background: transparent; border: 0; border-radius: 7px; font: inherit; font-weight: 600; cursor: pointer; }
.wechat-trigger:hover, .wechat-trigger:focus-visible { color: var(--blue); outline: none; }
.wechat-trigger:focus-visible { box-shadow: 0 0 0 3px rgba(37, 99, 235, .18); }
.qr-icon { width: 21px; height: 21px; padding: 2px; color: var(--blue); background: #fff; border: 1px solid #c8daf7; border-radius: 5px; fill: currentColor; }
.wechat-popover {
  position: absolute;
  right: 0;
  bottom: calc(100% + 15px);
  width: 238px;
  padding: 10px 10px 13px;
  display: grid;
  gap: 8px;
  color: var(--muted);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 20px 50px rgba(16, 24, 40, .16);
  opacity: 0;
  visibility: hidden;
  transform: translateY(8px) scale(.98);
  transform-origin: right bottom;
  transition: opacity .2s ease, visibility .2s ease, transform .25s var(--ease);
  z-index: 40;
  pointer-events: none;
}
.wechat-popover::after { content: ""; position: absolute; right: 21px; bottom: -6px; width: 11px; height: 11px; background: #fff; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); transform: rotate(45deg); }
.wechat-popover img { width: 100%; height: auto; display: block; border-radius: 9px; }
.wechat-popover small { position: relative; z-index: 1; text-align: center; font-size: 12px; font-weight: 600; }
.wechat-contact:hover .wechat-popover, .wechat-contact:focus-within .wechat-popover, .wechat-contact.open .wechat-popover { opacity: 1; visibility: visible; transform: translateY(0) scale(1); }

/* Resume */
.resume-page { background: var(--canvas); }
.intro { padding-block: 44px 36px; }
.intro h1 { margin: 0; font-size: clamp(48px, 5.5vw, 62px); line-height: 1; letter-spacing: -.055em; }
.role { margin: 15px 0 0; font-size: 17px; font-weight: 700; letter-spacing: -.02em; }
.intro-links { margin-top: 18px; display: flex; flex-wrap: wrap; gap: 18px; color: var(--blue); font-size: 13px; font-weight: 700; }
.intro-links a { padding-bottom: 2px; border-bottom: 1px solid transparent; }
.intro-links a:hover { border-color: currentColor; }
.profile-card { margin-top: 28px; display: grid; grid-template-columns: repeat(4, 1fr); border-top: 2px solid var(--ink); border-bottom: 1px solid var(--line-strong); }
.profile-card div { padding: 13px 18px; display: grid; gap: 5px; border-left: 1px solid var(--line); }
.profile-card div:first-child { padding-left: 0; border-left: 0; }
.profile-card span { color: var(--muted); font-size: 12px; }
.profile-card strong { font-size: 14px; }

.section { padding-top: 64px; scroll-margin-top: 76px; }
.section-first { padding-top: 18px; }
.section-title { margin-bottom: 20px; padding-bottom: 14px; display: grid; grid-template-columns: 40px minmax(0, 1fr); align-items: end; border-bottom: 1px solid var(--line-strong); }
.section-title > span { padding-bottom: 2px; color: var(--blue); font-size: 12px; line-height: 1; font-weight: 700; letter-spacing: .06em; }
.section-title > div { display: flex; align-items: baseline; justify-content: space-between; gap: 20px; }
.section-title p { order: 2; margin: 0; color: var(--blue); font-size: 11px; font-weight: 700; letter-spacing: .14em; }
.section-title h2 { order: 1; margin: 0; font-size: clamp(28px, 2.7vw, 34px); line-height: 1; letter-spacing: -.035em; }

.skill-list { border-top: 1px solid var(--line-strong); }
.skill-item { padding: 18px 0; display: grid; grid-template-columns: 190px minmax(0, 1fr); gap: 32px; align-items: baseline; border-bottom: 1px solid var(--line-strong); }
.skill-item h3 { margin: 0; font-size: 18px; letter-spacing: -.02em; }
.skill-item p { margin: 0; color: #475467; font-size: 15px; line-height: 1.65; }

.experience-list { border-top: 1px solid var(--line-strong); }
.experience { padding: 28px 0; border-bottom: 1px solid var(--line-strong); }
.experience-aside { margin-bottom: 20px; display: grid; grid-template-columns: auto auto 1fr; gap: 16px; align-items: center; }
.experience-aside h3 { margin: 0; font-size: 24px; line-height: 1; letter-spacing: -.03em; }
.experience-aside p { margin: 0; color: var(--muted); font-size: 13px; }
.experience-aside span { justify-self: end; display: inline-flex; padding: 5px 8px; color: var(--blue); background: var(--blue-pale); border: 1px solid #d8e7ff; border-radius: 5px; font-size: 11px; font-weight: 700; }
.experience-body { display: grid; gap: 24px; }
.experience-group h4 { margin: 0 0 11px; color: var(--blue); font-size: 14px; }
.experience-group ul { margin: 0; padding: 0; display: grid; gap: 8px; list-style: none; }
.experience-group li { position: relative; padding-left: 17px; color: #475467; font-size: 15px; line-height: 1.65; }
.experience-group li::before { content: ""; position: absolute; left: 0; top: .72em; width: 5px; height: 5px; background: var(--blue); border-radius: 50%; }

.education-card { padding: 20px 22px; display: flex; align-items: center; justify-content: space-between; background: var(--paper); border: 1px solid var(--line-strong); border-left: 3px solid var(--blue); border-radius: 8px; }
.education-card h3 { margin: 0 0 7px; font-size: 20px; letter-spacing: -.025em; }
.education-card p, .education-card > span { margin: 0; color: var(--muted); font-size: 13px; }
.footer { min-height: 76px; margin-top: 60px; padding-block: 22px; display: flex; align-items: center; justify-content: space-between; color: #7a8699; border-top: 1px solid var(--line); font-size: 12px; }

/* Open source */
.simple-topbar { grid-template-columns: 1fr 1fr; }
.source-page { min-height: calc(100svh - 150px); padding-block: 50px 44px; }
.source-intro { max-width: 720px; }
.source-intro h1 { margin: 0; font-size: clamp(50px, 6vw, 70px); line-height: 1; letter-spacing: -.055em; }
.source-intro > p:last-child { max-width: 640px; margin: 21px 0 0; color: var(--muted); font-size: 16px; line-height: 1.75; }
.source-list { margin-top: 40px; border-top: 2px solid var(--ink); }
.source-item { min-height: 124px; padding: 20px 8px; display: grid; grid-template-columns: 56px 1fr auto; align-items: center; gap: 24px; border-bottom: 1px solid var(--line-strong); transition: background .25s ease, border-color .25s ease; }
.source-item > span { align-self: start; color: var(--faint); font-size: 12px; font-weight: 700; }
.source-item div > p { margin: 0 0 7px; color: var(--blue); font-size: 11px; font-weight: 700; letter-spacing: .12em; }
.source-item h2 { margin: 0 0 9px; font-size: 27px; letter-spacing: -.035em; }
.source-item small { color: var(--muted); font-size: 14px; line-height: 1.65; }
.source-item > b { color: var(--blue); font-size: 24px; font-weight: 400; transition: transform .25s var(--ease); }
.source-item:hover { background: var(--blue-pale); border-color: #c8daf7; }
.source-item:hover > b { transform: translate(4px, -2px); }

.reveal { opacity: 0; transform: translateY(14px); transition: opacity .55s var(--ease), transform .55s var(--ease); }
.reveal.visible { opacity: 1; transform: translateY(0); }

@media (max-width: 900px) {
  .shell { width: min(100% - 40px, 760px); }
  .topbar { padding-inline: 20px; grid-template-columns: 1fr auto; }
  .topbar nav { display: none; }
  .portal-card { min-height: 140px; padding: 20px; }
  .home-contact { grid-template-columns: 140px 1fr; gap: 18px; }
}

@media (max-width: 620px) {
  .shell { width: calc(100% - 32px); }
  .topbar { height: 64px; padding-inline: 16px; }
  .identity-mark { width: 34px; height: 34px; }
  .identity small { display: none; }
  .home-header { min-height: 60px; }
  .home-location { font-size: 12px; }
  .home-main { padding-block: 18px; }
  .home-thoughts { margin-bottom: 16px; padding-left: 16px; }
  .home-thoughts p { font-size: 17px; line-height: 1.45; }
  .home-thoughts p::after { display: none; }
  .portal-grid { gap: 10px; }
  .portal-card { min-height: 118px; padding: 16px; border-radius: 10px; column-gap: 10px; }
  .portal-card h2 { font-size: 20px; }
  .portal-card p { font-size: 12px; line-height: 1.5; }
  .portal-card b { font-size: 20px; }
  .home-contact { margin-top: 10px; padding: 16px; grid-template-columns: 1fr; gap: 13px; border-radius: 10px; }
  .home-contact dl { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .home-contact dl > div { padding-left: 13px; }
  .home-contact dt { margin-bottom: 4px; }
  .wechat-popover { left: 0; right: auto; width: min(238px, calc(100vw - 64px)); transform-origin: left bottom; }
  .wechat-popover::after { left: 21px; right: auto; }
  .home-footer { min-height: 50px; }

  .intro { padding-block: 34px 26px; }
  .intro h1 { font-size: 46px; }
  .role { margin-top: 13px; font-size: 16px; }
  .intro-links { margin-top: 15px; gap: 12px; }
  .profile-card { margin-top: 22px; grid-template-columns: 1fr 1fr; }
  .profile-card div { padding: 11px 12px; border-bottom: 1px solid var(--line); }
  .profile-card div:nth-child(odd) { padding-left: 0; border-left: 0; }
  .profile-card div:nth-last-child(-n+2) { border-bottom: 0; }
  .section { padding-top: 48px; }
  .section-first { padding-top: 14px; }
  .section-title { margin-bottom: 14px; padding-bottom: 11px; grid-template-columns: 32px minmax(0, 1fr); }
  .section-title p { display: none; }
  .section-title h2 { font-size: 27px; }
  .skill-item { padding: 16px 0; grid-template-columns: 1fr; gap: 7px; }
  .skill-item h3 { font-size: 18px; }
  .skill-item p { font-size: 14px; }
  .experience { padding: 22px 0; }
  .experience-aside { margin-bottom: 16px; grid-template-columns: auto 1fr; gap: 7px 12px; }
  .experience-aside h3 { font-size: 22px; }
  .experience-aside p { justify-self: end; }
  .experience-aside span { grid-column: 1 / -1; justify-self: start; }
  .experience-body { gap: 20px; }
  .experience-group li { font-size: 14px; }
  .education-card { padding: 18px; align-items: flex-start; flex-direction: column; gap: 10px; }
  .footer { min-height: 74px; margin-top: 48px; align-items: flex-start; flex-direction: column; gap: 9px; }

  .source-page { padding-block: 36px 30px; }
  .source-intro h1 { font-size: 48px; }
  .source-intro > p:last-child { font-size: 15px; }
  .source-list { margin-top: 30px; }
  .source-item { min-height: 116px; padding: 18px 4px; grid-template-columns: 30px 1fr auto; gap: 11px; }
  .source-item h2 { font-size: 21px; }
  .source-item small { font-size: 13px; }
}

@media (max-width: 430px) {
  .portal-grid { grid-template-columns: 1fr; }
  .portal-card { min-height: 108px; }
  .home-contact dl { grid-template-columns: 1fr; gap: 18px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition-duration: .01ms !important; }
  .reveal { opacity: 1; transform: none; }
  .home-thoughts::before, .home-thoughts p, .home-thoughts p::after { animation: none; opacity: 1; transform: none; }
}
