/* Ruishan Guo — personal homepage */
:root {
  --paper: #fcfbf7;
  --card: #ffffff;
  --ink: #1b2228;
  --muted: #5a6469;
  --accent: #660874;          /* Tsinghua purple */
  --accent-strong: #660874;
  --accent-soft: #f1e7f4;
  --line: #dcdfd9;
  --wash: #f2f1ee;
  --gold-bg: #ffe8aa;
  --gold-fg: #764600;
  --kw-bg: #ecebf0;
  --kw-fg: #474754;
  --bar-bg: rgba(252, 251, 247, .97);
  --foot-bg: #efece4;
  --shadow: rgba(27, 34, 40, .09);
  --serif: 'Iowan Old Style', 'Palatino Linotype', Palatino, Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --paper: #0b0e14;
  --card: #121722;
  --ink: #e7e9ee;
  --muted: #99a2ae;
  --accent: #c79ae8;
  --accent-strong: #b07fd6;
  --accent-soft: rgba(176, 127, 214, .15);
  --line: #232a38;
  --wash: #151b26;
  --gold-bg: #4a3a12;
  --gold-fg: #ffd98a;
  --kw-bg: #1c2330;
  --kw-fg: #b3bcc9;
  --bar-bg: rgba(11, 14, 20, .94);
  --foot-bg: #141a25;
  --shadow: rgba(0, 0, 0, .45);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { scroll-padding-top: 92px; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
body { margin: 0; min-height: 100vh; display: flex; flex-direction: column; background: var(--paper); color: var(--ink); font: 1rem/1.7 var(--sans); -webkit-font-smoothing: antialiased; transition: background-color .25s ease, color .25s ease; }
main { flex: 1; }
a { color: inherit; text-decoration: none; }
a:hover { color: var(--accent); }
a:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
button { font: inherit; color: inherit; }
img, video { max-width: 100%; display: block; }
h1, h2, h3, h4, p, figure, ul { margin: 0; }
h1, h2, h3, h4 { line-height: 1.2; }
ul { padding: 0; list-style: none; }
strong { font-weight: 670; }
.frame { width: min(1216px, calc(100% - clamp(36px, 9vw, 144px))); margin-inline: auto; }
.skip { position: fixed; z-index: 20; top: 12px; left: 12px; background: var(--ink); color: var(--paper); padding: 8px 12px; transform: translateY(-160%); }
.skip:focus { transform: none; color: var(--paper); }

/* ---------- top bar ---------- */
.bar { position: sticky; z-index: 5; top: 0; border-bottom: 1px solid var(--line); background: var(--bar-bg); backdrop-filter: saturate(1.4) blur(6px); }
.bar-inner { display: flex; align-items: center; gap: clamp(14px, 2vw, 28px); min-height: 72px; }
.brand { display: inline-flex; align-items: center; gap: 10px; font: 700 19px/1 var(--serif); white-space: nowrap; }
.brand-mark { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 6px; background: var(--accent); color: #fff; font: 700 13px/1 var(--sans); letter-spacing: .02em; }
:root[data-theme="dark"] .brand-mark { color: #16101c; }
.nav { display: flex; gap: clamp(12px, 1.6vw, 22px); margin-right: auto; font-size: .97rem; color: var(--muted); }
.nav a { padding: 6px 0; border-bottom: 2px solid transparent; white-space: nowrap; }
.nav a[aria-current="true"] { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.nav-short { display: none; }
.profile-links { display: flex; align-items: center; }
.profile-links a { display: inline-flex; align-items: center; gap: 9px; color: var(--muted); }
.profile-links a:hover { color: var(--accent); }
.profile-icon { width: 18px; height: 18px; flex: none; object-fit: contain; color: var(--ink); }
.profile-emoji { font: 17px/1 'Apple Color Emoji', 'Segoe UI Emoji', 'Noto Color Emoji', sans-serif; width: 18px; text-align: center; }
.header-profiles { gap: 1px; padding: 2px; border: 1px solid var(--line); background: var(--wash); border-radius: 7px; }
.header-profiles a { justify-content: center; width: 31px; height: 31px; border-radius: 4px; }
.header-profiles a:hover { background: var(--card); }
.header-profiles .profile-label { position: absolute; clip-path: inset(50%); width: 1px; height: 1px; overflow: hidden; white-space: nowrap; }

.theme-toggle { display: inline-grid; place-items: center; width: 34px; height: 34px; flex: none; border: 1px solid var(--line); border-radius: 7px; background: var(--wash); cursor: pointer; color: var(--muted); }
.theme-toggle:hover { color: var(--accent); border-color: var(--accent); }
.theme-toggle svg { width: 18px; height: 18px; }
.theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

/* ---------- hero ---------- */
.hero { display: grid; grid-template: 'identity side' auto 'bio side' 1fr / minmax(0, 1fr) 230px; column-gap: clamp(40px, 9vw, 150px); padding: clamp(44px, 7vw, 72px) 0 clamp(40px, 6vw, 64px); }
.hero-identity { grid-area: identity; }
.hero-affiliation { display: flex; align-items: center; gap: 12px; font-size: 1.02rem; font-weight: 600; color: var(--muted); flex-wrap: wrap; }
.hero-affiliation a { color: var(--accent); }
.hero-affiliation strong { color: var(--ink); }
.hero-affiliation .dot { margin: 0 .5em; color: var(--muted); font-weight: 400; }
.institution-mark { display: grid; place-items: center; width: 44px; height: 44px; flex: none; border: 1px solid var(--line); border-radius: 8px; background: var(--card); }
.institution-mark img { width: 34px; height: 34px; object-fit: contain; }
h1 { margin: 18px 0 26px; font: 500 clamp(3rem, 7.4vw, 4.9rem)/1.02 var(--serif); letter-spacing: -.02em; display: flex; align-items: baseline; gap: clamp(14px, 1.6vw, 26px); flex-wrap: wrap; }
.cn-name { font: 500 clamp(1.4rem, 2.6vw, 2rem)/1.1 'Kaiti SC', 'STKaiti', 'KaiTi', 'Songti SC', serif; letter-spacing: .02em; color: var(--muted); }
.hero-side { grid-area: side; }
.portrait { position: relative; aspect-ratio: 56 / 81; overflow: hidden; border-radius: 6px; background: linear-gradient(160deg, #7a2a86, #3d0a47); }
.portrait::before { content: attr(data-initials); position: absolute; inset: 0; display: grid; place-items: center; color: rgba(255, 255, 255, .88); font: 500 4rem/1 var(--serif); letter-spacing: .04em; }
.portrait img { position: relative; width: 100%; height: 100%; object-fit: cover; object-position: center 20%; }
.hero-contacts { flex-direction: column; align-items: flex-start; gap: 9px; margin: 22px 0 0 38px; font-weight: 550; font-size: .95rem; }
.hero-contacts a { color: var(--ink); }
.hero-bio { grid-area: bio; }
.prose { max-width: 830px; font-size: 1.0625rem; line-height: 1.72; }
.prose p + p { margin-top: 1.05em; }
.prose a { border-bottom: 1px solid color-mix(in srgb, var(--accent) 45%, transparent); color: var(--accent); }
.focus-list { margin-top: .7em; }
.focus-list li { position: relative; margin-top: .35em; padding-left: 1.05em; }
.focus-list li::before { content: ''; position: absolute; left: 0; top: .66em; width: 5px; height: 5px; border-radius: 50%; background: var(--accent); }
.focus-list + p { margin-top: 1.05em; }
.hello { color: var(--accent); font-weight: 650; }
.nowrap { white-space: nowrap; }

/* ---------- section bands ---------- */
.band { padding: clamp(34px, 5vw, 52px) 0; border-top: 1px solid var(--line); }
.band-head { display: flex; align-items: baseline; justify-content: space-between; gap: 18px; flex-wrap: wrap; margin-bottom: 24px; }
.band-head h2 { font: 500 clamp(1.7rem, 3.2vw, 2.15rem)/1.15 var(--serif); letter-spacing: -.01em; }
.band-head.sub { margin-top: 34px; margin-bottom: 12px; }
.band-note { margin: -12px 0 26px; color: var(--muted); font-size: .95rem; }
.band-note a, .plain a { color: var(--accent); border-bottom: 1px solid color-mix(in srgb, var(--accent) 45%, transparent); }
.text-link { display: inline-flex; align-items: center; gap: 6px; color: var(--accent); font-weight: 600; font-size: .95rem; }
.jump { width: 15px; height: 15px; }

/* ---------- research cards ---------- */
.research-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.research-card { padding: 20px 22px 18px; border: 1px solid var(--line); border-radius: 9px; background: var(--card); }
.research-card h3 { display: flex; align-items: center; gap: 11px; font-size: 1.04rem; font-weight: 670; }
.research-card p { margin-top: 10px; color: var(--muted); font-size: .93rem; line-height: 1.55; }
.research-mark { display: grid; place-items: center; width: 34px; height: 34px; flex: none; border-radius: 8px; background: var(--accent-soft); color: var(--accent); }
.research-mark svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linejoin: round; stroke-linecap: round; }
.research-links { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.research-links a { display: inline-block; padding: 2px 10px; border: 1px solid var(--line); border-radius: 999px; font-size: .85rem; font-weight: 550; background: var(--paper); }
.research-links a:hover { border-color: var(--accent); background: var(--accent-soft); }

/* ---------- tags ---------- */
.tag { display: inline-block; padding: 2px 9px 2px; border-radius: 5px; font-size: .78rem; font-weight: 700; line-height: 1.55; white-space: nowrap; }
.tag-first { background: var(--accent); color: #fff; }
:root[data-theme="dark"] .tag-first { color: #17101d; }
.tag-co { background: var(--accent-soft); color: var(--accent); }
.tag-hl { background: var(--gold-bg); color: var(--gold-fg); }
.pub-legend { display: flex; align-items: center; gap: 14px; color: var(--muted); font-size: .88rem; margin: -14px 0 6px; flex-wrap: wrap; }

/* ---------- publication tabs ---------- */
.pub-tabs { display: flex; gap: 8px; flex-wrap: wrap; }
.pub-tab { padding: 5px 15px; border: 1px solid var(--line); border-radius: 999px; background: var(--paper); color: var(--muted); font-size: .9rem; font-weight: 600; cursor: pointer; }
.pub-tab span { font-weight: 500; opacity: .8; margin-left: 3px; }
.pub-tab:hover { border-color: var(--accent); color: var(--accent); }
.pub-tab[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }

/* ---------- publications ---------- */
.pub-group + .pub-group { margin-top: 30px; }
.pub-area { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; padding-bottom: 6px; border-bottom: 1px solid var(--line); }
.pub-area h3 { font: 500 1.32rem/1.2 var(--serif); color: var(--accent); }
.pub-area span { color: var(--muted); font-style: italic; font-size: .92rem; }
.pub-row { display: grid; grid-template-columns: minmax(0, 380px) minmax(0, 1fr); gap: clamp(24px, 3.4vw, 44px); padding: 20px 0; border-bottom: 1px solid var(--line); scroll-margin-top: 92px; }
.pub-group .pub-row:last-child { border-bottom: 0; padding-bottom: 4px; }
.pub-row:target .pub-figure { outline: 2px solid var(--accent); outline-offset: 3px; }
.pub-figure { align-self: start; display: grid; place-items: center; width: 100%; aspect-ratio: 16 / 9.6; padding: 7px; border: 1px solid var(--line); border-radius: 7px; background: var(--card); cursor: zoom-in; overflow: hidden; grid-template: minmax(0, 1fr) / minmax(0, 1fr); }
.pub-figure img { width: 100%; height: 100%; min-height: 0; object-fit: contain; }
.pub-figure:hover { border-color: var(--accent); }
.pub-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.pub-body h4 { margin-top: 8px; font-size: 1.08rem; font-weight: 670; line-height: 1.35; }
.pub-body h4 a:hover { color: var(--accent); }
.pub-authors { margin-top: 5px; color: var(--muted); font-size: .9rem; line-height: 1.5; }
.me { color: var(--ink); text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1.5px; }
.kw { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
.kw li.kw-hl { background: var(--gold-bg); color: var(--gold-fg); }
.kw li { padding: 0 8px; border-radius: 5px; background: var(--kw-bg); color: var(--kw-fg); font-size: .75rem; font-weight: 550; line-height: 1.75; }
.pub-summary { margin-top: 9px; font-size: .93rem; line-height: 1.6; color: var(--ink); }
.pub-links { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.pub-links a { padding: 2px 11px; border: 1px solid var(--line); border-radius: 999px; font-size: .82rem; font-weight: 600; color: var(--accent); background: var(--card); }
.pub-links a:hover { border-color: var(--accent); background: var(--accent-soft); }

/* ---------- experience ---------- */
.timeline { border-top: 1px solid var(--line); }
.timeline li { display: grid; grid-template-columns: 168px minmax(0, 1fr) auto; gap: 18px; align-items: baseline; padding: 15px 0; border-bottom: 1px solid var(--line); }
.timeline li:last-child { border-bottom: 0; }
.timeline time { color: var(--muted); font-size: .93rem; white-space: nowrap; font-variant-numeric: tabular-nums; }
.timeline p { font-size: 1.02rem; line-height: 1.55; }
.tl-logo { display: inline-block; width: 28px; height: 28px; margin-right: 10px; vertical-align: -7px; object-fit: contain; }
.tl-wordmark { display: inline-block; height: 19px; width: auto; vertical-align: -4px; }
.tl-wordmark.baidu { height: 24px; vertical-align: -6px; }
.timeline .at { color: var(--muted); font-weight: 400; }
.tl-note { color: var(--muted); }
.timeline .adv { color: var(--muted); font-size: .93rem; }
.timeline .adv a { color: var(--accent); }
.tl-role { color: var(--muted); font-size: .93rem; white-space: nowrap; }

/* ---------- education + honors ---------- */
.exp-row { display: grid; grid-template-columns: 52px minmax(0, 1fr); gap: 18px; padding: 20px 0; border-bottom: 1px solid var(--line); }
.exp-row:last-of-type { border-bottom: 0; }
.exp-row.compact { padding: 12px 0; }
.exp-logo { width: 52px; height: 52px; object-fit: contain; }
.exp-body header { display: flex; align-items: baseline; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.exp-body h3 { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 1.08rem; font-weight: 670; }
.exp-body time, .honors time { color: var(--muted); font-size: .93rem; white-space: nowrap; font-variant-numeric: tabular-nums; }
.exp-role { display: flex; justify-content: space-between; gap: 14px; flex-wrap: wrap; margin-top: 3px; color: var(--muted); font-size: .95rem; }
.exp-role a { color: var(--accent); }
.two-col { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: clamp(28px, 5vw, 64px); }
.plain { font-size: .98rem; }
.honors li { display: flex; justify-content: space-between; gap: 16px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: .97rem; line-height: 1.5; }
.honors li:last-child { border-bottom: 0; }

/* ---------- footer ---------- */
.foot { border-top: 1px solid var(--line); background: var(--foot-bg); color: var(--muted); font-size: .9rem; }
.foot-card { display: grid; grid-template-columns: 116px minmax(0, 1fr); gap: 26px; align-items: start; padding: 36px 0 28px; }
.foot-photo { width: 116px; height: 116px; object-fit: cover; border-radius: 14px; }
.foot-name { font: 600 1.5rem/1.2 var(--serif); color: var(--ink); }
.foot-aff { margin-top: 4px; font-size: .95rem; }
.foot-links { flex-wrap: wrap; gap: 8px 20px; margin: 16px 0 14px; font-size: .95rem; font-weight: 550; }
.foot-links a { color: var(--ink); gap: 7px; }
.foot-links a:hover { color: var(--accent); }
.foot-note { max-width: 720px; font-size: .97rem; line-height: 1.7; color: var(--ink); }
.foot-meta { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-top: 22px; padding-top: 14px; border-top: 1px solid var(--line); font-size: .88rem; }

/* ---------- dialogs ---------- */
dialog { padding: 0; border: 1px solid var(--line); border-radius: 10px; background: var(--paper); color: var(--ink); }
dialog::backdrop { background: rgba(16, 24, 33, .66); }
.contact-dialog { width: min(400px, calc(100% - 28px)); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; padding: 8px 10px 8px 16px; border-bottom: 1px solid var(--line); }
.dialog-head h2 { font: 600 1rem/1.2 var(--sans); }
.dialog-close { width: 34px; height: 34px; border: 0; border-radius: 6px; background: transparent; font-size: 1.5rem; line-height: 1; cursor: pointer; color: var(--muted); }
.dialog-close:hover { background: var(--wash); color: var(--ink); }
.contact-dialog img { width: 100%; max-height: calc(100dvh - 110px); object-fit: contain; background: #fff; border-radius: 0 0 10px 10px; }
.lightbox { width: min(1400px, calc(100% - 28px)); max-height: calc(100dvh - 28px); background: var(--card); }
.lightbox img { width: 100%; max-height: calc(100dvh - 60px); object-fit: contain; padding: 14px; cursor: zoom-out; }
.lightbox .dialog-close { position: absolute; top: 6px; right: 6px; background: var(--card); }

/* ---------- responsive ---------- */
@media (max-width: 1080px) {
  .header-profiles { display: none; }
  .research-grid { grid-template-columns: 1fr; }
  .pub-row { grid-template-columns: minmax(0, 300px) minmax(0, 1fr); }
}
@media (max-width: 820px) {
  .hero { grid-template: 'identity' 'side' 'bio' / 1fr; row-gap: 22px; }
  .hero-side { display: grid; grid-template-columns: 150px 1fr; gap: 22px; align-items: center; }
  .hero-contacts { margin: 0; }
  h1 { margin-bottom: 4px; }
  .two-col, .pub-row { grid-template-columns: 1fr; }
  .pub-figure { max-width: 520px; }
  .nav { overflow-x: auto; }
  .nav-full { display: none; }
  .nav-short { display: inline; }
  .timeline li { grid-template-columns: 1fr auto; row-gap: 2px; }
  .timeline time { grid-column: 1 / -1; }
  .foot-card { grid-template-columns: 84px minmax(0, 1fr); gap: 16px; }
  .foot-photo { width: 84px; height: 84px; border-radius: 10px; }
}
@media (max-width: 560px) {
  .bar-inner { min-height: 60px; gap: 10px; }
  .nav { gap: 11px; font-size: .88rem; }
  .brand span:last-child { display: none; }
  .exp-row { grid-template-columns: 40px minmax(0, 1fr); gap: 12px; }
  .exp-logo { width: 40px; height: 40px; }
  .honors li { flex-direction: column; gap: 0; }
  .timeline li { grid-template-columns: 1fr; }
  .tl-role { justify-self: start; }
}
