/* Xinyu Tan homepage — sidebar profile + dense, highlight-first content. */

:root {
  --bg: #ffffff;
  --surface: #f8f7f5;
  --surface-2: #fdf5f4;
  --line: #e9e5e1;
  --text: #24272b;
  --muted: #6b7076;
  --faint: #9a9ea3;
  --accent: #a3262f;          /* highlight red (PKU-ish) */
  --accent-soft: #f7e5e5;
  --accent-line: #e7b9b9;
  --venue: #255c96;           /* venue / links blue */
  --venue-soft: #e8f0f9;
  --ok: #2f8a4a;
  --shadow: 0 1px 2px rgba(30, 20, 20, .05), 0 4px 14px rgba(30, 20, 20, .04);
  --radius: 10px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16181c;
    --surface: #1e2126;
    --surface-2: #2a1f22;
    --line: #2f333a;
    --text: #e6e7e9;
    --muted: #a3a8ae;
    --faint: #7c8187;
    --accent: #f08a8f;
    --accent-soft: #3a2427;
    --accent-line: #6b3a3f;
    --venue: #8ab8ec;
    --venue-soft: #1f2b3a;
    --ok: #5fc47c;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 64px; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15.5px/1.65 var(--font);
}
a { color: var(--venue); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
img { max-width: 100%; display: block; }
svg { width: 1em; height: 1em; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.symbols { display: none; }
h1, h2, h3, p { margin: 0; }

/* bilingual switch */
html[lang="zh-CN"] .en, html:not([lang="zh-CN"]) .zh { display: none !important; }

.skip-link { position: absolute; left: -999px; top: 8px; background: var(--text); color: var(--bg); padding: 6px 12px; border-radius: 6px; z-index: 50; }
.skip-link:focus { left: 12px; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(160%) blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  max-width: 1240px; margin: 0 auto; padding: 0 24px;
  height: 54px; display: flex; align-items: center; gap: 24px;
}
.brand { display: inline-flex; align-items: center; gap: 9px; font-weight: 700; color: var(--text); font-size: 16px; white-space: nowrap; }
.brand-mark { width: 26px; height: 26px; border-radius: 6px; }
.brand:hover { text-decoration: none; color: var(--accent); }
.brand-zh { color: var(--muted); font-weight: 500; margin-left: 4px; }
nav { display: flex; gap: 4px; margin-left: auto; overflow-x: auto; scrollbar-width: none; }
nav::-webkit-scrollbar { display: none; }
nav a {
  color: var(--muted); font-size: 14.5px; font-weight: 500;
  padding: 6px 10px; border-radius: 6px; white-space: nowrap;
}
nav a:hover { color: var(--text); background: var(--surface); text-decoration: none; }
nav a[aria-current] { color: var(--accent); background: var(--accent-soft); }
.locale {
  display: inline-flex; align-items: center; gap: 6px;
  font: 500 13.5px var(--font); color: var(--muted);
  background: none; border: 1px solid var(--line); border-radius: 999px;
  padding: 5px 12px; cursor: pointer;
}
.locale:hover { color: var(--text); border-color: var(--muted); }

/* ---------- layout ---------- */
.layout {
  max-width: 1240px; margin: 0 auto; padding: 36px 24px 0;
  display: grid; grid-template-columns: 290px minmax(0, 1fr); gap: 60px;
}

/* ---------- profile sidebar ---------- */
.profile { position: sticky; top: 86px; align-self: start; }
.avatar {
  width: 220px; height: 220px; border-radius: 50%; object-fit: cover; object-position: 50% 40%;
  border: 3px solid var(--bg); box-shadow: 0 0 0 1px var(--line), var(--shadow);
}
.profile h1 { font-size: 28px; line-height: 1.25; margin-top: 22px; letter-spacing: -.01em; }
.profile h1 .han { display: block; font-size: 19px; font-weight: 500; color: var(--muted); letter-spacing: .08em; margin-top: 2px; }
.affil { margin-top: 10px; font-weight: 650; color: var(--accent); font-size: 16.5px; }
.tagline { margin-top: 8px; color: var(--muted); font-size: 15.5px; line-height: 1.6; }
.profile-links { list-style: none; padding: 0; margin: 20px 0 0; display: grid; gap: 10px; font-size: 15.5px; }
.profile-links li { display: flex; align-items: center; gap: 9px; min-width: 0; }
.profile-links a { display: inline-flex; align-items: center; gap: 9px; color: var(--text); min-width: 0; overflow-wrap: anywhere; }
.profile-links a:hover { color: var(--venue); }
.profile-links svg { color: var(--accent); font-size: 18px; }
.profile-links .muted { color: var(--muted); }

/* ---------- sections ---------- */
main { min-width: 0; }
section { padding-bottom: 40px; }
section + section { padding-top: 4px; }
h2 {
  display: flex; align-items: center; gap: 10px;
  font-size: 22px; font-weight: 700; letter-spacing: -.01em;
  padding-bottom: 8px; margin-bottom: 16px; border-bottom: 1px solid var(--line);
  position: relative;
}
h2::after { content: ""; position: absolute; left: 0; bottom: -1px; width: 44px; height: 2px; background: var(--accent); }

.prose p + p { margin-top: 12px; }
.prose strong { font-weight: 650; }
.hl { color: var(--accent); font-weight: 650; }
a.hl:hover { color: var(--accent); }

/* highlight stats */
.stats { list-style: none; padding: 0; margin: 20px 0 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.stats li {
  position: relative;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 14px; display: flex; flex-direction: column; gap: 1px;
  font-size: 13px; color: var(--muted);
}
.stats b { font-size: 21px; line-height: 1.25; color: var(--accent); font-weight: 750; letter-spacing: -.01em; }

.interests { margin-top: 16px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 13.5px; }
.interests .label { font-weight: 650; margin-right: 4px; }
.tag {
  color: var(--accent); background: var(--accent-soft); border: 1px solid var(--accent-line);
  border-radius: 6px; padding: 2px 10px; font-weight: 550;
}

/* icons */
.hicon { width: 22px; height: 22px; color: var(--accent); stroke-width: 2; }
.sicon { position: absolute; top: 12px; right: 12px; width: 20px; height: 20px; color: var(--accent); opacity: .35; }
.licon { width: 15px; height: 15px; color: var(--accent); margin-right: 5px; vertical-align: -2px; }
.dicon { width: 13px; height: 13px; color: var(--faint); }
.nicon { width: 16px; height: 16px; color: var(--accent); margin-top: 4px; }
.aicon { width: 16px; height: 16px; color: var(--accent); flex: none; }
.awards b { display: flex; align-items: center; gap: 6px; }

/* news */
.news { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.news li { display: grid; grid-template-columns: 70px 18px minmax(0, 1fr); gap: 10px; align-items: start; }
.news time { font-variant-numeric: tabular-nums; color: var(--venue); font-weight: 650; font-size: 14.5px; }

/* experience */
.exp-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.exp {
  display: flex; gap: 12px; align-items: flex-start;
  border: 1px solid var(--line); border-radius: var(--radius); padding: 14px;
  background: var(--bg); box-shadow: var(--shadow);
}
.exp.current { background: var(--surface-2); border-color: var(--accent-line); }
.mono {
  flex: none; width: 44px; height: 44px; border-radius: 50%;
  display: grid; place-items: center; color: #fff; font-weight: 750; font-size: 12.5px; letter-spacing: .02em;
}
.logo {
  flex: none; width: 56px; height: 56px; object-fit: contain;
  border-radius: 50%; background: #fff;
}
.exp h3 { font-size: 15.5px; line-height: 1.35; }
.exp .when { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 6px; font-variant-numeric: tabular-nums; }
.exp .what { font-size: 14px; font-weight: 600; margin-top: 2px; }
.exp .note { font-size: 13px; color: var(--muted); margin-top: 4px; line-height: 1.5; }
.live { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 25%, transparent); }

/* publications */
.source-note { font-size: 13.5px; color: var(--muted); margin: -6px 0 12px; }
.source-note a { color: inherit; text-decoration: underline; text-decoration-color: var(--line); }
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.filters button {
  font: 550 13.5px var(--font); color: var(--muted);
  background: var(--bg); border: 1px solid var(--line); border-radius: 999px;
  padding: 4px 12px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
}
.filters button:hover { color: var(--text); border-color: var(--muted); }
.filters button[aria-pressed="true"] { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
.filters .count { font-size: 12px; color: var(--faint); font-variant-numeric: tabular-nums; }
.filters button[aria-pressed="true"] .count { color: var(--accent); }

.paper-list { display: grid; gap: 14px; }
.paper {
  display: grid; grid-template-columns: 210px minmax(0, 1fr); gap: 18px;
  border: 1px solid var(--line); border-radius: var(--radius); padding: 14px;
  background: var(--bg); box-shadow: var(--shadow);
}
.paper.featured { background: var(--surface-2); border-color: var(--accent-line); border-left: 3px solid var(--accent); }
.paper[hidden] { display: none; }
.thumb {
  align-self: start; border-radius: 6px; overflow: hidden; background: #fff;
  border: 1px solid var(--line); aspect-ratio: 16 / 10; display: grid; place-items: center;
}
.thumb img { width: 100%; height: 100%; object-fit: contain; padding: 4px; transition: transform .25s; }
.thumb:hover img { transform: scale(1.04); }
.paper h3 { font-size: 16px; line-height: 1.4; font-weight: 700; }
.paper h3 a { color: var(--text); }
.paper h3 a:hover { color: var(--venue); }
.authors { font-size: 13.5px; color: var(--muted); margin-top: 4px; line-height: 1.5; }
.authors .me { color: var(--accent); font-weight: 700; }
.authors sup { font-size: .7em; }
.summary { font-size: 14px; margin-top: 6px; line-height: 1.55; }
.paper-foot { margin-top: 9px; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; font-size: 13.5px; }
.venue { color: var(--venue); font-weight: 750; }
.venue-note { color: var(--venue); background: var(--venue-soft); border-radius: 4px; padding: 0 6px; font-size: 12px; font-weight: 600; margin-left: -6px; }
.pl { display: inline-flex; align-items: center; gap: 4px; font-weight: 600; }
.cites { color: var(--muted); font-weight: 550; }
.cites::before { content: "★ "; color: #d79b1c; }
.role {
  color: var(--accent); background: var(--accent-soft); border: 1px solid var(--accent-line);
  border-radius: 4px; padding: 0 7px; font-size: 12.5px; font-weight: 650;
}

/* engineering notes (home list + notes index) */
.notes-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.notes-list li {
  display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 14px;
  border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; background: var(--bg); box-shadow: var(--shadow);
}
.notes-list time { color: var(--venue); font-weight: 650; font-size: 14px; font-variant-numeric: tabular-nums; padding-top: 1px; }
.note-title { font-size: 16.5px; font-weight: 700; color: var(--text); }
.note-title:hover { color: var(--venue); }
.note-lang { margin-left: 8px; font-size: 12px; color: var(--venue); background: var(--venue-soft); border-radius: 4px; padding: 0 6px; vertical-align: 2px; }
.note-summary { font-size: 14px; color: var(--muted); margin-top: 4px; line-height: 1.55; }
.note-tags { margin-top: 6px; display: flex; flex-wrap: wrap; gap: 6px; }
.note-tag { font-size: 12px; color: var(--accent); background: var(--accent-soft); border-radius: 4px; padding: 0 7px; font-weight: 600; }
.notes-more { margin-top: 10px; font-size: 14px; font-weight: 600; }

/* note article pages */
.article { max-width: 780px; margin: 0 auto; padding: 36px 24px 48px; }
.article h1 { font-size: 30px; line-height: 1.3; letter-spacing: -.01em; }
.article-back { font-size: 14px; margin-bottom: 14px; }
.note-draft { display: inline-block; font-size: 12.5px; font-weight: 700; color: #8a5a00; background: #fff3d6; border: 1px solid #f0d48a; border-radius: 4px; padding: 1px 8px; margin-bottom: 10px; }
.article-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; color: var(--muted); font-size: 14px; margin: 10px 0 26px; padding-bottom: 18px; border-bottom: 1px solid var(--line); }
.article-meta time { color: var(--venue); font-weight: 650; }
.article-body { font-size: 16px; line-height: 1.8; }
.article-body > * + * { margin-top: 14px; }
.article-body h2 { margin-top: 36px; font-size: 22px; }
.article-body h3 { margin-top: 26px; font-size: 18px; }
.article-body .headerlink { margin-left: 6px; color: var(--faint); opacity: 0; font-weight: 400; text-decoration: none; }
.article-body h2:hover .headerlink, .article-body h3:hover .headerlink { opacity: 1; }
.article-body ul, .article-body ol { padding-left: 1.4em; }
.article-body li + li { margin-top: 4px; }
.article-body strong { color: var(--text); font-weight: 700; }
.article-body code { font-family: "SFMono-Regular", Menlo, Consolas, monospace; font-size: .88em; background: var(--surface); border: 1px solid var(--line); border-radius: 4px; padding: 1px 5px; }
.article-body pre { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 14px 16px; overflow-x: auto; line-height: 1.55; }
.article-body pre code { border: 0; padding: 0; background: none; font-size: 13.5px; }
.article-body pre code.hljs { background: none; padding: 0; }
.article-body blockquote { margin-left: 0; padding: 8px 16px; border-left: 3px solid var(--accent); background: var(--surface-2); border-radius: 0 8px 8px 0; color: var(--text); }
.article-body table { border-collapse: collapse; width: 100%; font-size: 14.5px; display: block; overflow-x: auto; }
.article-body th, .article-body td { border: 1px solid var(--line); padding: 7px 12px; text-align: left; }
.article-body th { background: var(--surface); }
.note-footer { max-width: 780px; margin: 0 auto; padding: 18px 24px 36px; border-top: 1px solid var(--line); display: flex; justify-content: space-between; color: var(--faint); font-size: 13.5px; }

/* awards */
.awards { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.awards li {
  display: grid; grid-template-columns: 78px minmax(0, 1fr); gap: 10px;
  border: 1px solid var(--line); border-left: 3px solid var(--line); border-radius: 8px;
  padding: 10px 12px; background: var(--bg);
}
.awards li.top { border-left-color: var(--accent); background: var(--surface-2); }
.awards time { color: var(--accent); font-weight: 650; font-size: 13px; padding-top: 1px; font-variant-numeric: tabular-nums; }
.awards div { display: flex; flex-direction: column; font-size: 13px; color: var(--muted); line-height: 1.45; }
.awards b { font-size: 14.5px; color: var(--text); font-weight: 650; }

footer {
  display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  border-top: 1px solid var(--line); padding: 16px 0 32px; color: var(--faint); font-size: 13px;
}

:focus-visible { outline: 2px solid var(--venue); outline-offset: 2px; border-radius: 4px; }

/* ---------- responsive ---------- */
@media (max-width: 1000px) {
  .exp-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; gap: 28px; padding-top: 24px; }
  .profile { position: static; display: flex; gap: 20px; align-items: center; }
  .avatar { width: 128px; height: 128px; }
  .profile h1 { margin-top: 0; }
  .profile-links { grid-template-columns: repeat(2, max-content); column-gap: 18px; }
  .brand-zh { display: none; }
}
@media (max-width: 640px) {
  body { font-size: 15px; }
  .topbar-inner { padding: 0 16px; gap: 12px; }
  .brand { display: none; }
  nav { margin-left: 0; }
  .layout { padding: 20px 16px 0; }
  .profile { flex-direction: column; align-items: flex-start; }
  .profile-links { grid-template-columns: 1fr; }
  .exp-grid, .awards { grid-template-columns: 1fr; }
  .paper { grid-template-columns: 1fr; gap: 10px; }
  .thumb { max-width: 320px; }
  .news li { grid-template-columns: 60px 16px minmax(0, 1fr); gap: 8px; }
  .notes-list li { grid-template-columns: 1fr; gap: 4px; }
  .article h1 { font-size: 25px; }
  .article { padding: 24px 16px 40px; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .thumb img { transition: none; }
}
