/* ==========================================================================
   Fan Tang — academic homepage
   颜色、字号等都在 :root 里集中定义，想调整配色改这里即可
   ========================================================================== */

:root {
  --bg: #ffffff;
  --bg-soft: #f6f7f9;
  --bg-hover: #eef1f5;
  --text: #1d2127;
  --text-2: #4a535e;
  --muted: #7a838e;
  --border: #e3e6ea;
  --accent: #1f5fbf;
  --accent-hover: #174a96;
  --accent-soft: #e9f0fb;
  --gold: #a1650a;
  --gold-soft: #fdf3e1;
  --green: #217a4c;
  --green-soft: #e6f4ec;
  --star: #d69e18;
  --me: #111418;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 1px 3px rgba(16, 24, 40, .06);
  --radius: 8px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --masthead-h: 60px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111418; --bg-soft: #181c22; --bg-hover: #20252d; --text: #e4e7eb; --text-2: #b3bac3; --muted: #8a939e;
    --border: #2a3039; --accent: #7fb0ff; --accent-hover: #a9c9ff; --accent-soft: #1b2a40; --gold: #e2b25c;
    --gold-soft: #33280f; --green: #6cc896; --green-soft: #15291e; --star: #e8b93c; --me: #ffffff;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #111418; --bg-soft: #181c22; --bg-hover: #20252d; --text: #e4e7eb; --text-2: #b3bac3; --muted: #8a939e;
  --border: #2a3039; --accent: #7fb0ff; --accent-hover: #a9c9ff; --accent-soft: #1b2a40; --gold: #e2b25c;
  --gold-soft: #33280f; --green: #6cc896; --green-soft: #15291e; --star: #e8b93c; --me: #ffffff;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3); color-scheme: dark;
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--masthead-h) + 16px); }
body {
  margin: 0; background: var(--bg); color: var(--text); font-family: var(--font);
  font-size: 16px; line-height: 1.65; -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; text-underline-offset: 2px; }
img { max-width: 100%; height: auto; }
h1, h2, h3 { line-height: 1.3; }
p { margin: 0 0 .9em; }
strong { font-weight: 650; }
sup { font-size: .72em; line-height: 0; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.icon { width: 1em; height: 1em; fill: currentColor; flex: none; vertical-align: -.125em; }
.emoji { margin-right: .35em; font-style: normal; }
.zh { font-weight: 400; }
.skip-link { position: absolute; left: -999px; top: 8px; background: var(--bg); padding: 6px 10px; z-index: 100; }
.skip-link:focus { left: 8px; }
.container { max-width: 1160px; margin: 0 auto; padding-left: 24px; padding-right: 24px; }

/* ---------- masthead ---------- */
.masthead {
  position: sticky; top: 0; z-index: 50; height: var(--masthead-h);
  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);
}
.masthead-inner { display: flex; align-items: center; gap: 28px; height: 100%; }
.site-title { font-weight: 700; font-size: 1.05rem; color: var(--text); white-space: nowrap; letter-spacing: .01em; }
.site-title:hover { color: var(--text); text-decoration: none; }
.nav { display: flex; gap: 4px; margin-left: auto; }
.nav a {
  color: var(--text-2); padding: 6px 12px; border-radius: 6px; font-size: .95rem; font-weight: 500;
}
.nav a:hover { color: var(--text); background: var(--bg-hover); text-decoration: none; }
.nav a.active { color: var(--accent); background: var(--accent-soft); }
.masthead-actions { display: flex; gap: 4px; }
.icon-btn {
  display: inline-grid; place-items: center; width: 36px; height: 36px; border: 0; border-radius: 6px;
  background: transparent; color: var(--text-2); cursor: pointer;
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text); }
.icon-btn .icon { width: 17px; height: 17px; }
.nav-toggle { display: none; }
.show-dark { display: none; }
:root[data-theme="dark"] .show-dark { display: block; }
:root[data-theme="dark"] .show-light { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .show-dark { display: block; }
  :root:not([data-theme="light"]) .show-light { display: none; }
}

/* ---------- layout ---------- */
.layout { display: grid; grid-template-columns: 244px minmax(0, 1fr); gap: 56px; padding-top: 40px; padding-bottom: 64px; }
.sidebar { position: sticky; top: calc(var(--masthead-h) + 32px); align-self: start; }
.content { min-width: 0; max-width: 820px; }

/* ---------- sidebar ---------- */
.avatar-link { display: block; }
.avatar {
  display: block; width: 100%; max-width: 200px; aspect-ratio: 1; object-fit: cover; border-radius: 50%;
  border: 1px solid var(--border); box-shadow: var(--shadow);
}
.profile-name { font-size: 1.3rem; font-weight: 700; margin: 18px 0 2px; line-height: 1.3; }
.profile-name .zh { font-size: 1.05rem; color: var(--text-2); margin-left: 2px; }
.profile-position { color: var(--text-2); margin: 0 0 14px; }
.profile-meta { list-style: none; margin: 0; padding: 14px 0 0; border-top: 1px solid var(--border); font-size: .9rem; }
.profile-meta li { display: flex; align-items: center; gap: 10px; padding: 3px 0; color: var(--text-2); min-width: 0; }
.profile-meta li > span, .profile-meta li > a { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile-meta .icon { width: 15px; height: 15px; color: var(--muted); }
.profile-meta li.wrap { align-items: flex-start; }
.profile-meta li.wrap > span { white-space: normal; line-height: 1.45; }
.profile-meta li.wrap .icon { margin-top: 3px; }
.profile-meta a { color: var(--text-2); }
.profile-meta a:hover { color: var(--accent); }
.profile-stats {
  display: grid; grid-template-columns: repeat(3, 1fr); margin-top: 18px; border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden; color: var(--text); text-align: center;
}
.profile-stats:hover { text-decoration: none; border-color: color-mix(in srgb, var(--accent) 40%, var(--border)); }
.profile-stats span { display: flex; flex-direction: column; padding: 8px 2px; font-size: .72rem; color: var(--muted); letter-spacing: .02em; }
.profile-stats span + span { border-left: 1px solid var(--border); }
.profile-stats strong { font-size: 1.02rem; color: var(--text); font-variant-numeric: tabular-nums; }

/* ---------- content typography ---------- */
.page-title { font-size: 1.9rem; margin: 0 0 20px; letter-spacing: -.01em; }
.tagline { font-size: 1.12rem; font-weight: 650; font-style: italic; margin: 0 0 18px; }
.prose { color: var(--text); }
.prose ul { padding-left: 1.3em; }
.prose li { margin: .35em 0; }
.prose ul.plain { list-style: none; padding-left: 0; }
.prose ul.plain li { padding-left: 0; }
.section { margin-top: 44px; }
.section-title {
  display: flex; align-items: baseline; gap: 2px; font-size: 1.35rem; margin: 0 0 16px; padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.section-title .count { margin-left: 10px; font-size: .8rem; font-weight: 500; color: var(--muted); }
.section-title .section-icon { color: var(--accent); margin-right: 10px; width: .9em; height: .9em; align-self: center; }
.more-link { display: inline-flex; align-items: center; gap: 6px; font-size: .92rem; margin-top: 10px; }
.more-link .icon { width: .85em; }

/* ---------- badges & buttons ---------- */
.badge {
  display: inline-block; font-size: .74rem; font-weight: 650; line-height: 1.5; padding: 1px 7px; border-radius: 4px;
  white-space: nowrap; vertical-align: .12em; letter-spacing: .01em; font-style: normal;
}
.badge.venue { background: var(--accent-soft); color: var(--accent); }
.badge.venue.is-preprint { background: var(--bg-hover); color: var(--text-2); }
.badge.rank { background: var(--bg-hover); color: var(--text-2); }
.badge.rank-ccf-a { background: var(--gold-soft); color: var(--gold); }
.badge.note { background: var(--green-soft); color: var(--green); }
.badge.role { background: var(--bg-hover); color: var(--text-2); margin-right: 8px; }
.badge.money { background: var(--gold-soft); color: var(--gold); display: inline-flex; align-items: center; gap: 4px; }
.btn {
  display: inline-flex; align-items: center; gap: 5px; height: 26px; padding: 0 9px; font-size: .8rem; font-weight: 500;
  color: var(--text-2); background: var(--bg); border: 1px solid var(--border); border-radius: 5px; cursor: pointer;
  white-space: nowrap; line-height: 1;
}
.btn:hover { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); background: var(--accent-soft); text-decoration: none; }
.btn .icon { width: 13px; height: 13px; }
.btn[aria-expanded="true"] { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); }
.stars { display: inline-flex; align-items: center; gap: 3px; margin-left: 3px; padding-left: 7px; border-left: 1px solid var(--border); color: var(--text-2); font-variant-numeric: tabular-nums; }
.stars .icon { color: var(--star); }

/* ---------- news ---------- */
.news-list { list-style: none; margin: 0; padding: 0; }
.news-item { display: grid; grid-template-columns: 5.6em minmax(0, 1fr); gap: 14px; padding: 6px 0; line-height: 1.55; }
.news-item + .news-item { border-top: 1px dashed var(--border); }
.news-item time { color: var(--muted); font-size: .86rem; font-variant-numeric: tabular-nums; padding-top: .12em; white-space: nowrap; }
.news-item.is-pinned time::after { content: " 📌"; }

/* ---------- representative works ---------- */
.rep + .rep { margin-top: 32px; }
.rep-title { font-size: 1.08rem; margin: 0 0 12px; }
.rep-figure { margin: 0 0 12px; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: #fff; }
.rep-figure img { display: block; width: 100%; }
.rep-papers { list-style: none; margin: 0; padding: 0; font-size: .92rem; }
.rep-papers li { padding: 3px 0; }
.rep-papers .badge { margin-right: 8px; }
.rep-papers .mini-stat { margin-left: 8px; }
.rep-papers a { color: var(--text); }
.rep-papers a:hover { color: var(--accent); }
.mini-stat { display: inline-flex; align-items: center; gap: 3px; font-size: .78rem; color: var(--muted); white-space: nowrap; }
.mini-stat .icon { color: var(--star); }

/* ---------- publications ---------- */
.stat-row { display: flex; flex-wrap: wrap; gap: 10px; margin: 0 0 22px; }
.stat {
  display: flex; flex-direction: column; min-width: 96px; padding: 10px 14px; border: 1px solid var(--border);
  border-radius: var(--radius); background: var(--bg-soft);
}
.stat strong { font-size: 1.3rem; line-height: 1.2; font-variant-numeric: tabular-nums; }
.stat span { font-size: .78rem; color: var(--muted); }
.pub-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; margin-bottom: 8px; }
.search {
  display: flex; align-items: center; gap: 8px; flex: 1 1 280px; height: 38px; padding: 0 12px;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg); color: var(--muted);
}
.search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--text); font: inherit; font-size: .93rem; }
.year-jump { display: flex; flex-wrap: wrap; gap: 2px; font-size: .85rem; }
.year-jump a { padding: 2px 7px; border-radius: 4px; color: var(--text-2); }
.year-jump a:hover { background: var(--bg-hover); color: var(--accent); text-decoration: none; }
.pub-legend { font-size: .8rem; color: var(--muted); margin: 6px 0 4px; }
.search-count { color: var(--accent); }
.pub-group { margin-top: 34px; }
.pub { display: flex; gap: 18px; padding: 14px 12px; margin: 0 -12px; border-radius: var(--radius); transition: background .15s; }
.pub:hover { background: var(--bg-soft); }
.pub:target { background: var(--accent-soft); }
.pub-thumb { flex: 0 0 180px; }
.pub-thumb img { display: block; width: 180px; aspect-ratio: 4/3; object-fit: cover; border-radius: 6px; border: 1px solid var(--border); background: var(--bg-soft); }
.pub-body { min-width: 0; flex: 1; }
.pub-title { font-size: 1rem; font-weight: 650; margin: 0 0 4px; line-height: 1.45; }
.pub-title .badge { margin-right: 6px; }
.pub-title a { color: var(--text); }
.pub-title a:hover { color: var(--accent); }
.pub-authors { font-size: .9rem; color: var(--text-2); margin: 0 0 2px; }
.author.me { color: var(--me); font-weight: 700; }
sup.corr { font-size: .7em; margin-left: 1px; color: var(--muted); }
.author.me sup.corr { color: inherit; }
.pub-venue { font-size: .88rem; color: var(--text-2); margin: 0 0 8px; }
.pub-venue .badge { margin-right: 6px; }
.pub-links { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.cite { display: inline-flex; align-items: center; gap: 5px; font-size: .8rem; color: var(--muted); margin-left: 4px; }
.cite .icon { width: 13px; height: 13px; }
.cite:hover { color: var(--accent); text-decoration: none; }
.bibtex { position: relative; margin-top: 10px; }
.bibtex pre {
  margin: 0; padding: 12px 14px; font: .78rem/1.55 var(--mono); color: var(--text-2); background: var(--bg-soft);
  border: 1px solid var(--border); border-radius: 6px; overflow-x: auto; white-space: pre-wrap; word-break: break-word;
}
.copy-bib { position: absolute; top: 8px; right: 8px; }
.pub-empty { color: var(--muted); padding: 24px 0; }
.data-note { font-size: .8rem; color: var(--muted); margin-top: 40px; }
.data-note a { color: inherit; text-decoration: underline; }
.is-hidden { display: none !important; }

/* ---------- team ---------- */
.member-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 16px; }
.member-grid.is-wide { grid-template-columns: 1fr; }
.member {
  display: flex; gap: 16px; padding: 16px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg);
  transition: border-color .15s, box-shadow .15s;
}
.member:hover { border-color: color-mix(in srgb, var(--accent) 30%, var(--border)); box-shadow: var(--shadow); }
.member-photo { flex: 0 0 96px; width: 96px; height: 96px; border-radius: 10px; overflow: hidden; background: var(--bg-soft); }
.is-wide .member-photo { flex-basis: 120px; width: 120px; height: 120px; }
.member-photo img { display: block; width: 100%; height: 100%; object-fit: cover; }
.initials { display: grid; place-items: center; width: 100%; height: 100%; font-size: 1.6rem; font-weight: 700; color: var(--accent); background: var(--accent-soft); }
.member-info { min-width: 0; flex: 1; }
.member-name { font-size: 1.02rem; margin: 0; }
.member-name a { color: var(--text); }
.member-name .zh { color: var(--text-2); font-size: .95rem; margin-left: 2px; }
.member-title { font-size: .86rem; color: var(--accent); margin: 1px 0 6px; font-weight: 500; }
.member-research { font-size: .84rem; color: var(--text-2); margin: 0 0 6px; }
.member-exp { list-style: none; margin: 0 0 8px; padding: 0; font-size: .82rem; color: var(--text-2); }
.member-exp li { display: flex; gap: 10px; padding: 1px 0; }
.exp-date { flex: 0 0 auto; min-width: 5.8em; color: var(--muted); font-variant-numeric: tabular-nums; }
.member-bio { font-size: .86rem; color: var(--text-2); margin: 0 0 8px; }
.member-links { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; font-size: .84rem; }
.member-links a { color: var(--muted); display: inline-flex; align-items: center; gap: 5px; }
.member-links a:hover { color: var(--accent); text-decoration: none; }
.member-links .icon { width: 15px; height: 15px; }
.alumni-list { list-style: none; margin: 0; padding: 0; }
.alumni-list li { display: flex; flex-wrap: wrap; gap: 4px 14px; padding: 6px 0; border-bottom: 1px dashed var(--border); font-size: .93rem; }
.alumni-name { font-weight: 600; }
.alumni-meta { color: var(--muted); }
.alumni-dest { display: inline-flex; align-items: center; gap: 6px; color: var(--text-2); }
.alumni-dest .icon { width: .8em; color: var(--muted); }

/* ---------- CV ---------- */
.cv-item { padding: 10px 0 12px; }
.cv-item + .cv-item { border-top: 1px dashed var(--border); }
.cv-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 4px 16px; }
.cv-title { font-size: .98rem; }
.cv-meta { display: flex; align-items: center; gap: 10px; font-size: .86rem; }
.cv-date { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.cv-org { color: var(--text-2); font-size: .92rem; margin-top: 2px; }
.cv-details { margin: 6px 0 0; padding-left: 1.2em; font-size: .92rem; color: var(--text-2); }
.cv-details li { margin: 2px 0; }

/* ---------- footer ---------- */
.site-footer { border-top: 1px solid var(--border); padding: 22px 0 28px; font-size: .82rem; color: var(--muted); }
.site-footer .sep { margin: 0 8px; }

/* ---------- responsive ---------- */
@media (max-width: 960px) {
  .layout { grid-template-columns: 1fr; gap: 0; padding-top: 24px; }
  .sidebar { position: static; margin-bottom: 28px; padding-bottom: 20px; border-bottom: 1px solid var(--border); }
  .profile { display: flex; align-items: center; gap: 16px; }
  .avatar-link { flex: 0 0 76px; }
  .avatar { width: 76px; }
  .profile-name { margin-top: 0; font-size: 1.2rem; }
  .profile-position { margin: 0; }
  .profile-meta { display: flex; flex-wrap: wrap; gap: 2px 18px; border-top: 0; padding-top: 14px; }
  .profile-stats { max-width: 360px; }
  .content { max-width: none; }
}
@media (max-width: 720px) {
  .container { padding-left: 16px; padding-right: 16px; }
  body:not(.page-home) .sidebar .profile-meta, body:not(.page-home) .sidebar .profile-stats { display: none; }
  body:not(.page-home) .sidebar { margin-bottom: 20px; padding-bottom: 16px; }
  body:not(.page-home) .avatar-link { flex-basis: 56px; }
  body:not(.page-home) .avatar { width: 56px; }
  .nav-toggle { display: inline-grid; }
  .nav {
    display: none; position: absolute; top: var(--masthead-h); left: 0; right: 0; flex-direction: column; gap: 0;
    padding: 8px 12px 12px; background: var(--bg); border-bottom: 1px solid var(--border); box-shadow: var(--shadow);
  }
  .nav.is-open { display: flex; }
  .nav a { padding: 10px 12px; }
  .masthead-actions { margin-left: auto; }
  .page-title { font-size: 1.6rem; }
  .pub { flex-direction: column; gap: 10px; }
  .pub-thumb, .pub-thumb img { width: 100%; flex-basis: auto; }
  .member-grid { grid-template-columns: 1fr; }
  .member-photo, .is-wide .member-photo { flex-basis: 80px; width: 80px; height: 80px; }
  .news-item { grid-template-columns: 1fr; gap: 0; }
  .stat { min-width: 0; flex: 1 1 28%; }
}

@media print {
  .masthead, .site-footer, .pub-toolbar, .pub-links, .theme-toggle { display: none !important; }
  .layout { display: block; }
}
