/* ---------- Fonts (self-hosted, no external requests) ---------- */
@font-face {
  font-family: "Inter";
  src: url("../fonts/inter-latin.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Inter";
  src: url("../fonts/inter-latin-ext.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* ---------- Tokens ---------- */
:root {
  color-scheme: light;
  --bg: #ffffff;
  --text: #16181d;
  --text-2: #3d434f;
  --muted: #6b7280;
  --line: #e7e9ee;
  --surface: #f7f8fa;
  --accent: #0f5ea8;
  --accent-soft: #eaf2fb;
  --radius: 10px;
  --sidebar-w: 280px;
  --content-w: 720px;
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "PingFang SC", "Microsoft YaHei", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  overflow-wrap: break-word;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.65;
  font-feature-settings: "cv11", "ss01";
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
h1, h2, h3 { margin: 0; line-height: 1.3; letter-spacing: -0.011em; }
p { margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }
::selection { background: var(--accent-soft); }

/* ---------- Layout ---------- */
.layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, var(--content-w));
  gap: 72px;
  max-width: calc(var(--sidebar-w) + var(--content-w) + 72px);
  margin: 0 auto;
  padding: 0 32px;
}

/* ---------- Sidebar ---------- */
.sidebar-inner {
  position: sticky;
  top: 0;
  padding: 40px 0 20px;
  max-height: 100vh;
  overflow-y: auto;
  scrollbar-width: none;          /* hide inner scrollbar (Firefox) */
}
.sidebar-inner::-webkit-scrollbar { display: none; }  /* Chrome, Edge, Safari */
.avatar {
  display: block;
  width: 128px;
  height: 128px;
  border-radius: 50%;
  object-fit: cover;
  margin-bottom: 20px;
}
.avatar-placeholder {
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--accent-soft), #dbe7f6);
  color: var(--accent);
  font-size: 44px;
  font-weight: 600;
  letter-spacing: -0.02em;
}
.name { font-size: 26px; font-weight: 700; letter-spacing: -0.022em; }
.role { margin-top: 6px; font-weight: 500; color: var(--text-2); }
.affiliation { margin-top: 2px; color: var(--muted); font-size: 14.5px; line-height: 1.5; }
.location { margin-top: 2px; color: var(--muted); font-size: 14.5px; }

.links { margin-top: 20px; display: grid; gap: 0; }
.links a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 0;
  color: var(--text-2);
  font-size: 14.5px;
}
.links a:hover { color: var(--accent); text-decoration: none; }

/* Email copy button (looks like the other sidebar links) */
.email-copy {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 4px 0;
  border: 0;
  background: none;
  font: inherit;
  font-size: 13.5px;
  color: var(--text-2);
  text-align: left;
  cursor: pointer;
}
.email-copy:hover, .email-copy:hover .icon { color: var(--accent); }
.email-text { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.copy-icon { margin-left: auto; opacity: 0.7; }
.email-copy:hover .copy-icon { opacity: 1; }
.email-copy.copied, .email-copy.copied .icon { color: #1f9d55; }
.link-button {
  border: 0;
  background: none;
  padding: 0;
  font: inherit;
  font-weight: 600;
  color: var(--accent);
  cursor: pointer;
  margin-left: 4px;
  white-space: nowrap;
}
.link-button:hover { text-decoration: underline; text-underline-offset: 3px; }
.link-button.copied { color: #1f9d55; }

.name-zh {
  margin-left: 4px;
  font-size: 17px;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--muted);
}
.icon { flex: none; color: var(--muted); }
.links a:hover .icon { color: var(--accent); }

.toc {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  display: grid;
  gap: 0;
}
.toc a {
  color: var(--muted);
  font-size: 14px;
  padding: 2px 0 2px 12px;
  border-left: 2px solid transparent;
  margin-left: -14px;
}
.toc a:hover { color: var(--text); text-decoration: none; }
.toc a.active { color: var(--accent); border-left-color: var(--accent); font-weight: 500; }

/* ---------- Content ---------- */
.content { padding: 64px 0 48px; min-width: 0; }
.section { padding-bottom: 56px; scroll-margin-top: 24px; }
.section + .section { padding-top: 8px; }
.section-title {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  padding-bottom: 12px;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--line);
}

.prose p { color: var(--text-2); font-size: 17px; line-height: 1.7; }
.prose p + p { margin-top: 16px; }
.prose strong { color: var(--text); font-weight: 600; }

.callout {
  margin-top: 24px;
  padding: 12px 16px;
  background: var(--accent-soft);
  border-radius: var(--radius);
  font-size: 15px;
  font-weight: 500;
  color: #0b3f71;
}
.callout a { font-weight: 600; white-space: nowrap; margin-left: 4px; }
.dot {
  display: inline-block; vertical-align: middle; margin: -2px 10px 0 2px;
  width: 8px; height: 8px; border-radius: 50%;
  background: #1f9d55;
  box-shadow: 0 0 0 3px rgba(31, 157, 85, 0.18);
}

.interests { margin-top: 28px; }
.interests .label, .languages .label { display: block; margin-bottom: 10px; }
.label { font-size: 13px; font-weight: 600; color: var(--muted); }
.chips, .tags { display: flex; flex-wrap: wrap; gap: 6px; }
.chips li {
  font-size: 13.5px;
  padding: 3px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text-2);
}

/* ---------- Publications ---------- */
.pubs { display: grid; gap: 28px; }
.pub-meta { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.venue, .status {
  font-size: 12px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 6px;
  letter-spacing: 0.01em;
}
.venue { background: var(--accent-soft); color: var(--accent); }
.status { background: #fdf3e2; color: #92580b; }
.pub-title { font-size: 17px; font-weight: 600; line-height: 1.4; }
.authors { margin-top: 6px; font-size: 15px; color: var(--text-2); }
.authors strong { color: var(--text); font-weight: 600; }
.venue-full { margin-top: 2px; font-size: 14.5px; color: var(--muted); font-style: italic; }
.pub-summary { margin-top: 10px; font-size: 15px; color: var(--text-2); }
.note { margin-top: 6px; font-size: 14px; color: var(--muted); }
.pub-links { margin-top: 12px; display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-start; }
.btn {
  display: inline-block;
  font-size: 13px;
  font-weight: 500;
  padding: 3px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text-2);
  cursor: pointer;
  list-style: none;
}
.btn::-webkit-details-marker { display: none; }
.btn:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }
.bib[open] { flex-basis: 100%; }
.bib[open] .btn { border-color: var(--accent); color: var(--accent); }
.bib pre {
  margin: 10px 0 0;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.55;
}

/* ---------- Projects ---------- */
.cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.card {
  display: flex;
  flex-direction: column;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.card:hover { border-color: #cdd5e0; box-shadow: 0 4px 16px rgba(16, 24, 40, 0.05); }
.card img { width: calc(100% + 40px); margin: -20px -20px 16px; border-radius: var(--radius) var(--radius) 0 0; aspect-ratio: 16 / 9; object-fit: cover; }
.card-meta { font-size: 12.5px; color: var(--muted); }
.card-title { margin-top: 6px; font-size: 16px; font-weight: 600; }
.card-text { margin-top: 8px; font-size: 14.5px; color: var(--text-2); line-height: 1.6; flex: 1; }
.tags { margin-top: 14px; }
.tags li { font-size: 12px; padding: 2px 8px; border-radius: 6px; background: var(--surface); color: var(--muted); }

/* ---------- Timeline rows ---------- */
.rows { display: grid; gap: 22px; }
.row { display: grid; grid-template-columns: 112px minmax(0, 1fr); gap: 20px; }
.dates { font-size: 14px; color: var(--muted); font-variant-numeric: tabular-nums; padding-top: 1px; }
.row-title { font-size: 16px; font-weight: 600; }
.row-org { font-size: 15px; color: var(--text-2); }
.row-details { margin-top: 6px; display: grid; gap: 3px; }
.row-details li { position: relative; padding-left: 14px; font-size: 14.5px; color: var(--muted); line-height: 1.55; }
.row-details li::before { content: ""; position: absolute; left: 1px; top: 0.68em; width: 4px; height: 4px; border-radius: 50%; background: #b4bac4; }
.rows.compact { gap: 10px; }
.rows.compact .row span:last-child { font-size: 15px; color: var(--text-2); }

/* ---------- Skills ---------- */
.skills { margin: 0; display: grid; gap: 12px; }
.skills div { display: grid; grid-template-columns: 112px minmax(0, 1fr); gap: 20px; }
.skills dt { font-size: 14px; color: var(--muted); }
.skills dd { margin: 0; font-size: 15px; color: var(--text-2); }

/* ---------- Personal photos ---------- */
.personal-photos { margin-top: 20px; display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.personal-photos figure { margin: 0; }
.personal-photos img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: var(--radius); display: block; }
.personal-photos figcaption { margin-top: 6px; font-size: 13px; color: var(--muted); }

/* ---------- Languages ---------- */
.languages { margin-top: 28px; }
.lang-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.lang-list li { display: flex; flex-direction: column; padding: 10px 14px; border: 1px solid var(--line); border-radius: var(--radius); }
.lang-name { font-size: 15px; font-weight: 600; }
.lang-level { font-size: 13px; color: var(--muted); }

/* ---------- Footer ---------- */
.footer { padding-top: 24px; border-top: 1px solid var(--line); font-size: 13px; color: var(--muted); }

/* ---------- 404 ---------- */
.notfound { min-height: 100vh; display: grid; place-content: center; text-align: center; gap: 12px; padding: 32px; }
.notfound h1 { font-size: 22px; }

/* ---------- Responsive ---------- */
@media (max-width: 960px) {
  .layout { grid-template-columns: minmax(0, 1fr); gap: 0; padding: 0 20px; max-width: var(--content-w); }
  .sidebar-inner { position: static; max-height: none; overflow: visible; padding: 40px 0 8px; }
  .sidebar-inner { display: grid; grid-template-columns: auto minmax(0, 1fr); column-gap: 20px; align-items: center; }
  .avatar { width: 96px; height: 96px; margin: 0; font-size: 28px; }
  .links { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 4px 18px; margin-top: 20px; }
  .toc { display: none; }
  .content { padding-top: 32px; }
}
@media (max-width: 600px) {
  .name { font-size: 22px; }
  .cards { grid-template-columns: 1fr; }
  .row, .skills div { grid-template-columns: 1fr; gap: 2px; }
  .prose p { font-size: 16px; }
}
@media print {
  .toc, .callout a, .pub-links { display: none; }
  .layout { display: block; }
  .sidebar-inner { position: static; }
}
