/* ===========================================================
   Chenyang Lei — minimal modern homepage
   typography-first, light/dark, single column
   =========================================================== */

:root {
  --maxw: 960px;
  --bg: #ffffff;
  --surface: #ffffff;
  --text: #1a1a1a;
  --muted: #6b7280;
  --faint: #9ca3af;
  --border: #ececec;
  --accent: #2563eb;
  --accent-hover: #f09228;
  --tag-bg: #f3f4f6;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 8px 24px rgba(0,0,0,.05);
  --radius: 14px;
  color-scheme: light;
}

html[data-theme="dark"] {
  --bg: #0d1117;
  --surface: #161b22;
  --text: #e6edf3;
  --muted: #9198a1;
  --faint: #6e7681;
  --border: #21262d;
  --accent: #58a6ff;
  --accent-hover: #f0a85c;
  --tag-bg: #1c2128;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.35);
  color-scheme: dark;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

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

.wrap {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 32px 140px;
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color .15s ease;
}
a:hover { color: var(--accent-hover); }
a:focus-visible,
button:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent);
  outline-offset: 3px;
  border-radius: 4px;
}

/* ---------- top nav ---------- */
.topnav {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  gap: 26px;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 20px 0;
  margin-bottom: 0;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(180%) blur(10px);
  -webkit-backdrop-filter: saturate(180%) blur(10px);
  border-bottom: 1px solid var(--border);
}
.topnav::-webkit-scrollbar { display: none; }
.topnav a { white-space: nowrap; }
.topnav a {
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  letter-spacing: -0.01em;
}
.topnav a:hover,
.topnav a.active { color: var(--text); }

/* ---------- theme toggle ---------- */
.theme-toggle {
  position: fixed;
  top: 18px;
  right: 18px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow);
  z-index: 50;
  transition: transform .2s ease, background .3s ease;
}
.theme-toggle:hover { transform: scale(1.08); }

/* ---------- hero ---------- */
.hero {
  display: flex;
  align-items: center;
  gap: 56px;
  padding: 68px 0 32px;
}
.hero-text { flex: 1 1 auto; min-width: 0; }
.hero h1 {
  font-size: clamp(44px, 5vw, 58px);
  line-height: 1.02;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 0 0 4px;
}
.hero .zh {
  font-size: 18px;
  font-weight: 500;
  color: var(--muted);
  margin: 0 0 14px;
}
.hero .role { margin: 0; color: var(--muted); font-size: 16px; }
.hero .role strong { color: var(--text); font-weight: 600; }
.hero-proof {
  max-width: 700px;
  margin: 28px 0 0;
  padding: 0;
  color: var(--text);
  font-size: clamp(18px, 2vw, 22px);
  line-height: 1.55;
  letter-spacing: -0.018em;
}
.hero-proof strong { color: var(--accent); }

.current-role {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 15px;
}
.current-role strong {
  color: var(--text);
  font-weight: 600;
}

.avatar {
  flex: 0 0 auto;
  width: 140px;
  height: 140px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

/* ---------- contact links ---------- */
.links-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  margin: 0 0 30px;
}
.links-row a {
  font-size: 13px;
  font-weight: 600;
  padding: 0;
  color: var(--accent);
  transition: color .15s ease;
}
.links-row a + a::before {
  content: "·";
  display: inline-block;
  margin: 0 10px;
  color: var(--faint);
}
.links-row a:hover {
  color: var(--accent-hover);
}

/* ---------- bio ---------- */
.bio {
  max-width: 760px;
  color: var(--text);
  font-size: 16px;
  line-height: 1.75;
}
.bio a { font-weight: 500; }

/* ---------- sections ---------- */
section { margin-top: 92px; scroll-margin-top: 88px; }
h2.section-title {
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--faint);
  margin: 0 0 22px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

/* ---------- research story ---------- */
.section-kicker {
  margin: 0 0 10px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .13em;
}
.research-summary {
  max-width: 750px;
  margin-bottom: 36px;
}
.research-lede {
  margin: 0 0 14px;
  font-size: 21px;
  line-height: 1.65;
  letter-spacing: -0.01em;
}
.research-summary > p:not(.research-lede) {
  margin: 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.75;
}
.research-summary > p:not(.research-lede) + p { margin-top: 14px; }
.research-story > .section-title {
  margin-bottom: 14px;
  padding: 0;
  border: 0;
  color: var(--text);
  font-size: clamp(30px, 4vw, 40px);
  font-weight: 700;
  line-height: 1.15;
  text-transform: none;
  letter-spacing: -0.035em;
}
.research-pipeline {
  counter-reset: stage;
  display: grid;
  grid-template-columns: 1fr auto 1fr auto 1fr;
  align-items: center;
  gap: 20px;
  padding: 18px 0;
  margin-bottom: 18px;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.pipeline-stage {
  appearance: none;
  counter-increment: stage;
  padding: 8px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: color .15s ease, background .15s ease;
}
.pipeline-stage:hover {
  background: color-mix(in srgb, var(--accent) 7%, transparent);
}
.pipeline-stage.active {
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  color: var(--accent);
}
.pipeline-stage::before {
  content: "0" counter(stage);
  display: block;
  margin-bottom: 7px;
  color: var(--faint);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .12em;
}
.research-pipeline strong {
  display: block;
  font-size: 13px;
  line-height: 1.35;
}
.pipeline-stage > span {
  display: block;
  margin-top: 5px;
  color: var(--accent);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .1em;
}
.pipeline-arrow {
  color: var(--faint);
  font-size: 16px;
}
.pipeline-return {
  position: relative;
  grid-column: 1 / -1;
  height: 40px;
  margin: 0 8% 2px;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  border-left: 1px solid var(--border);
  border-radius: 0 0 10px 10px;
}
.pipeline-return::before {
  content: "↑";
  position: absolute;
  top: -18px;
  left: -6px;
  padding: 0 1px;
  background: var(--bg);
  color: var(--accent);
  font-size: 15px;
  line-height: 1;
}
.pipeline-return button {
  appearance: none;
  position: absolute;
  bottom: -11px;
  left: 50%;
  padding: 0 12px;
  border: 0;
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  font-weight: 650;
  line-height: 20px;
  letter-spacing: .02em;
  white-space: nowrap;
  transform: translateX(-50%);
  cursor: pointer;
  transition: color .15s ease;
}
.pipeline-return .stage-num {
  margin-right: 6px;
  color: var(--faint);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .12em;
}
.pipeline-return button:hover,
.pipeline-return button.active {
  color: var(--accent);
}

.brain-evolve {
  margin: -4px 0 2px;
  color: var(--accent);
  font-size: 22px;
  line-height: 1;
  text-align: center;
}

.photographer-brain {
  margin: 0 0 6px;
  padding: 36px 40px 38px;
  border: 1px solid var(--border);
  border-radius: 12px;
  text-align: center;
}
.photographer-brain h3 {
  margin: 0 0 10px;
  color: var(--text);
  font-size: clamp(32px, 4.6vw, 44px);
  font-weight: 750;
  line-height: 1.15;
  letter-spacing: -0.035em;
}
.brain-sub {
  margin: 0 0 18px;
  color: var(--text);
  font-size: clamp(18px, 2.4vw, 22px);
  font-weight: 650;
  line-height: 1.35;
  letter-spacing: -0.02em;
}
.brain-copy {
  text-align: left;
}
.brain-copy p {
  margin: 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.7;
}
.brain-copy p + p { margin-top: 14px; }

/* ---------- interactive research panels ---------- */
.research-panel[hidden] { display: none; }
.research-panel {
  padding: 28px 0 0;
}
.track-header {
  display: grid;
  grid-template-columns: minmax(250px, .8fr) minmax(0, 1.2fr);
  gap: 32px;
  align-items: start;
  margin-bottom: 22px;
}
.track-header h3 {
  margin: 0;
  font-size: 23px;
  line-height: 1.3;
  letter-spacing: -0.025em;
}
.track-header p {
  max-width: 650px;
  margin: 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.7;
}
.research-work-list {
  border-bottom: 1px solid var(--border);
}
.research-work-row {
  display: grid;
  grid-template-columns: 118px minmax(0, 1fr);
  gap: 20px;
  align-items: start;
  padding: 15px 0;
  border-top: 1px solid var(--border);
  color: var(--text);
}
.research-work-row:hover { color: var(--text); }
.work-source {
  color: var(--faint);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .09em;
}
.work-summary {
  display: grid;
  grid-template-columns: minmax(180px, .7fr) minmax(0, 1.3fr);
  gap: 22px;
  align-items: start;
}
.work-title-media {
  display: block;
  min-width: 0;
  color: var(--text);
}
.work-title-media > strong {
  display: block;
  font-size: 14px;
  font-weight: 650;
  line-height: 1.45;
  transition: color .15s ease;
}
.research-work-row:hover .work-title-media > strong { color: var(--accent); }
.work-role {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
  line-height: 1.4;
}
.work-title-media img {
  display: block;
  width: 100%;
  max-width: 220px;
  height: 124px;
  margin-top: 10px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--tag-bg);
  object-fit: cover;
}
.work-summary > span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}
.community-links {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  margin-top: 10px;
}
.community-links a {
  color: var(--accent);
  font-size: 11px;
  font-weight: 650;
  white-space: nowrap;
}
.community-links a::after {
  content: " ↗";
  color: var(--faint);
}
.community-links a:hover { color: var(--accent-hover); }

/* ---------- experience table ---------- */
.experience-table-wrap {
  overflow-x: auto;
}
.experience-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14.5px;
  line-height: 1.45;
}
.experience-table th {
  padding: 10px 12px;
  color: var(--faint);
  font-size: 11px;
  font-weight: 700;
  text-align: left;
  text-transform: uppercase;
  letter-spacing: .09em;
  border-bottom: 1px solid var(--border);
}
.experience-table td {
  padding: 14px 12px;
  vertical-align: top;
  border-bottom: 1px solid var(--border);
}
.experience-table th:first-child,
.experience-table td:first-child {
  width: 43%;
  padding-left: 0;
}
.experience-table td:first-child { font-weight: 600; }
.experience-table th:nth-child(2),
.experience-table td:nth-child(2) { width: 37%; }
.experience-table th:last-child,
.experience-table td:last-child {
  width: 20%;
  padding-right: 0;
  color: var(--muted);
  text-align: right;
  white-space: nowrap;
}
.table-detail {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 400;
}
.table-honor {
  margin-top: 10px;
  line-height: 1.55;
}
.table-honor + .table-honor { margin-top: 4px; }

/* ---------- academic service and teaching ---------- */
.service-layout {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.service-column {
  padding: 24px 28px 25px 0;
}
.service-column + .service-column {
  padding-right: 0;
  padding-left: 28px;
  border-left: 1px solid var(--border);
}
.service-label {
  margin: 0 0 7px;
  color: var(--accent);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .11em;
}
.service-column h3 {
  margin: 0 0 18px;
  font-size: 18px;
  line-height: 1.35;
  letter-spacing: -0.015em;
}
.service-details {
  margin: 0;
}
.service-details div {
  display: grid;
  grid-template-columns: 82px minmax(0, 1fr);
  gap: 12px;
  padding: 8px 0;
  border-top: 1px solid var(--border);
}
.service-details dt,
.course-list span {
  color: var(--faint);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
}
.service-details dd {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}
.course-list {
  margin: 0;
  padding: 0;
  list-style: none;
}
.course-list li {
  display: grid;
  grid-template-columns: 82px minmax(0, 1fr);
  gap: 12px;
  padding: 8px 0;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

/* ---------- generic bullet lists ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.list li {
  padding: 7px 0;
  font-size: 15.5px;
  border-bottom: 1px dashed var(--border);
}
.list li:last-child { border-bottom: 0; }
.list .org { font-weight: 600; }
.list .when { color: var(--muted); font-size: 14px; }
.list .role { color: var(--text); }
.list .detail { display: block; color: var(--muted); font-size: 14px; margin-top: 2px; }
.list .learned {
  display: block;
  margin-top: 8px;
  padding: 8px 12px;
  font-size: 14px;
  line-height: 1.55;
  color: var(--text);
  background: var(--tag-bg);
  border-left: 2px solid var(--accent);
  border-radius: 0 8px 8px 0;
}
.list .learned .tag {
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.02em;
  margin-right: 6px;
}

.topics { display: flex; flex-wrap: wrap; gap: 10px; margin: 16px 0 0; }
.topics span {
  font-size: 14px;
  font-weight: 500;
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--tag-bg);
  color: var(--text);
}

.more-link { margin: 18px 0 0; }
.more-link a {
  font-size: 15px;
  font-weight: 600;
  color: var(--accent);
}
.more-link a:hover { color: var(--accent-hover); }

/* ---------- publications ---------- */
.pub-toggle {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  margin-bottom: 26px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
}
.pub-toggle button {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  padding: 6px 18px;
  border-radius: 999px;
  cursor: pointer;
  transition: background .15s ease, color .15s ease;
}
.pub-toggle button:hover { color: var(--text); }
.pub-toggle button.active { background: var(--accent); color: #fff; }

.pubs.show-selected .pub:not(.sel) { display: none; }

.pub {
  display: grid;
  grid-template-columns: 150px 1fr;
  gap: 24px;
  padding: 22px;
  margin-bottom: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  transition: box-shadow .2s ease, transform .2s ease, border-color .2s ease;
}
.pub:hover {
  box-shadow: var(--shadow);
  transform: translateY(-2px);
  border-color: transparent;
}

.thumb {
  position: relative;
  width: 150px;
  height: 112px;
  border-radius: 10px;
  overflow: hidden;
  background: var(--tag-bg);
}
.thumb img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.thumb .after {
  opacity: 0;
  transition: opacity .3s ease-in-out;
}
.pub:hover .thumb .after { opacity: 1; }

.pub-body { min-width: 0; }
.pub-title {
  font-size: 17px;
  font-weight: 700;
  line-height: 1.35;
  margin: 0 0 6px;
  letter-spacing: -0.01em;
}
.pub-title a { color: var(--text); }
.pub-title a:hover { color: var(--accent); }
.authors { margin: 0 0 4px; font-size: 14.5px; color: var(--muted); }
.authors .me { color: var(--text); font-weight: 700; }
.venue { margin: 0 0 8px; font-size: 14px; }
.venue em { color: var(--accent); font-style: italic; font-weight: 600; }
.pub-links { margin: 0 0 8px; font-size: 14px; }
.pub-links a { font-weight: 500; }
.pub-links .sep { color: var(--faint); margin: 0 4px; }
.abstract { margin: 0; font-size: 14px; color: var(--muted); line-height: 1.6; }

/* ---------- footer ---------- */
.footer {
  position: relative;
  margin-top: 72px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
  text-align: center;
  font-size: 13px;
  color: var(--faint);
}
.visit-counter {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
  opacity: 0;
  pointer-events: none;
}

/* ---------- responsive ---------- */
@media (max-width: 600px) {
  .wrap { padding: 0 18px 100px; }
  body { font-size: 16px; }
  .hero {
    flex-direction: column-reverse;
    align-items: flex-start;
    gap: 14px;
    padding: 32px 0 24px;
  }
  .hero h1 { font-size: 38px; }
  .avatar { width: 84px; height: 84px; }
  .hero-proof {
    margin-top: 20px;
    font-size: 17px;
  }
  .research-lede { font-size: 16px; }
  .research-pipeline {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    padding: 14px 0;
    margin-bottom: 8px;
  }
  .pipeline-stage { text-align: center; }
  .pipeline-arrow { display: none; }
  .pipeline-return {
    height: 42px;
    margin-right: 4%;
    margin-left: 4%;
  }
  .pipeline-return button {
    max-width: 92%;
    white-space: normal;
    text-align: center;
  }
  .pipeline-stage { padding: 5px 3px; }
  .pipeline-stage strong { font-size: 10px; }
  .pipeline-stage > span {
    font-size: 8px;
    letter-spacing: .06em;
  }
  .photographer-brain {
    margin: 10px 0 4px;
    padding: 24px 20px 26px;
  }
  .photographer-brain h3 { font-size: 28px; }
  .brain-sub { font-size: 17px; }
  .brain-copy p { font-size: 15px; }
  .research-panel { padding-top: 24px; }
  .track-header {
    grid-template-columns: 1fr;
    gap: 7px;
    margin-bottom: 18px;
  }
  .track-header h3 { font-size: 20px; }
  .research-work-row {
    grid-template-columns: 82px minmax(0, 1fr);
    gap: 12px;
    align-items: start;
    padding: 13px 0;
  }
  .work-summary {
    grid-template-columns: 1fr;
    gap: 4px;
  }
  .service-layout { grid-template-columns: 1fr; }
  .service-column {
    padding: 20px 0 21px;
  }
  .service-column + .service-column {
    padding: 20px 0 21px;
    border-top: 1px solid var(--border);
    border-left: 0;
  }
  .experience-table-wrap {
    overflow: visible;
  }
  .experience-table,
  .experience-table tbody,
  .experience-table tr,
  .experience-table td {
    display: block;
    width: 100%;
  }
  .experience-table thead { display: none; }
  .experience-table tr {
    position: relative;
    padding: 13px 94px 13px 0;
    border-bottom: 1px solid var(--border);
  }
  .experience-table td,
  .experience-table td:first-child,
  .experience-table td:nth-child(2),
  .experience-table td:last-child {
    width: auto;
    padding: 0;
    border: 0;
    text-align: left;
  }
  .experience-table td:nth-child(2) {
    margin-top: 2px;
    color: var(--muted);
  }
  .experience-table td:last-child {
    position: absolute;
    top: 14px;
    right: 0;
    font-size: 12px;
  }
  .pub {
    grid-template-columns: 1fr;
    gap: 14px;
  }
  .thumb { width: 100%; height: 180px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: .01ms !important;
  }
}
