/* ------------------------------------------------------------ tokens */
:root {
  --bg: #fbfbf9;
  --surface: #ffffff;
  --text: #1c1f24;
  --muted: #5d6470;
  --border: #e3e3de;
  --accent: #1d5ea8;
  --accent-soft: #e9f0f9;
  --award: #8a5200;
  --award-soft: #fdf1dc;
  --me: #1c1f24;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.04), 0 2px 8px rgb(0 0 0 / 0.04);
  --radius: 10px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121417;
    --surface: #191c20;
    --text: #e6e8eb;
    --muted: #9ba3ae;
    --border: #2b3036;
    --accent: #7db3f0;
    --accent-soft: #1a2736;
    --award: #f2b75e;
    --award-soft: #2d2416;
    --me: #ffffff;
    --shadow: none;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #121417;
  --surface: #191c20;
  --text: #e6e8eb;
  --muted: #9ba3ae;
  --border: #2b3036;
  --accent: #7db3f0;
  --accent-soft: #1a2736;
  --award: #f2b75e;
  --award-soft: #2d2416;
  --me: #ffffff;
  --shadow: none;
  color-scheme: dark;
}

/* -------------------------------------------------------------- base */
*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-padding-top: 5rem; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.65 var(--font);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

h1, h2, h3 { line-height: 1.25; letter-spacing: -0.01em; }
h1 { font-size: 2rem; margin: 0 0 0.5rem; }
h2 { font-size: 1.3rem; margin: 2.5rem 0 0.9rem; }
h3 { font-size: 1.05rem; margin: 1.6rem 0 0.4rem; }
p { margin: 0 0 1rem; }
ul, ol { padding-left: 1.3rem; }

.wrap { max-width: 50rem; margin: 0 auto; padding-left: 16px; padding-right: 16px; }
.muted { color: var(--muted); }
.small { font-size: 0.875rem; }

.icon { width: 1em; height: 1em; flex: none; vertical-align: -0.125em; }

.skip-link { position: absolute; left: -999px; }
.skip-link:focus { left: 16px; top: 8px; z-index: 10; background: var(--surface); padding: 0.4rem 0.8rem; }

/* ------------------------------------------------------------ header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 5;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--border);
}
.header-inner { display: flex; align-items: center; gap: 1.25rem; min-height: 3.5rem; flex-wrap: wrap; }
.brand { font-weight: 650; color: var(--text); white-space: nowrap; }
.brand:hover { text-decoration: none; color: var(--accent); }
.site-nav { display: flex; gap: 0.15rem 1rem; flex-wrap: wrap; margin-left: auto; font-size: 0.95rem; }
.site-nav a { color: var(--muted); padding: 0.2rem 0; border-bottom: 2px solid transparent; }
.site-nav a:hover { color: var(--text); text-decoration: none; }
.site-nav a[aria-current="page"] { color: var(--text); border-bottom-color: var(--accent); }

.theme-toggle {
  display: inline-grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
}
.theme-toggle:hover { color: var(--text); }
.theme-toggle .when-dark { display: none; }
:root[data-theme="dark"] .theme-toggle .when-dark { display: inline; }
:root[data-theme="dark"] .theme-toggle .when-light { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .when-dark { display: inline; }
  :root:not([data-theme="light"]) .theme-toggle .when-light { display: none; }
}

main { padding-top: 2.5rem; padding-bottom: 3rem; }

/* ------------------------------------------------------------ footer */
.site-footer { border-top: 1px solid var(--border); color: var(--muted); font-size: 0.875rem; }
.footer-inner { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; padding-top: 1.25rem; padding-bottom: 2rem; }

/* -------------------------------------------------------- page parts */
.page-header { margin-bottom: 2rem; }
.page-header .lede { color: var(--muted); font-size: 1.05rem; }
.eyebrow { text-transform: uppercase; letter-spacing: 0.08em; font-size: 0.78rem; font-weight: 600; color: var(--accent); margin: 0 0 0.4rem; }

.callout {
  background: var(--accent-soft);
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 0.85rem 1.1rem;
  margin: 1.5rem 0;
}
.callout p:last-child { margin: 0; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.15rem;
  box-shadow: var(--shadow);
}
.card h3 { margin-top: 0; }
.card p:last-child, .card ul:last-child { margin-bottom: 0; }

details.more > summary {
  cursor: pointer;
  color: var(--accent);
  font-weight: 550;
  font-size: 0.95rem;
  list-style: none;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}
details.more > summary::-webkit-details-marker { display: none; }
details.more > summary::before { content: "▸"; transition: transform 0.15s; }
details.more[open] > summary::before { transform: rotate(90deg); }

.more-link a { display: inline-flex; align-items: center; gap: 0.35rem; font-weight: 550; }

/* -------------------------------------------------------------- home */
.hero { display: flex; gap: 2rem; align-items: center; margin-bottom: 1.5rem; }
.avatar { width: 176px; height: 176px; border-radius: 50%; object-fit: cover; flex: none; border: 1px solid var(--border); }
.hero h1 { font-size: 2.3rem; margin-bottom: 0.15rem; }
.tagline { font-size: 1.1rem; color: var(--accent); margin-bottom: 0.6rem; font-weight: 500; }
.role, .location { margin: 0; color: var(--muted); }
.location { display: flex; align-items: center; gap: 0.35rem; }

.profile-links { list-style: none; padding: 0; margin: 1rem 0 0; display: flex; flex-wrap: wrap; gap: 0.5rem; }
.profile-links a {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font-size: 0.9rem;
}
.profile-links a:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }

.interest-list li { margin-bottom: 0.25rem; }

.news { list-style: none; padding: 0; margin: 0 0 0.75rem; }
.news li { display: grid; grid-template-columns: 5.5rem minmax(0, 1fr); gap: 1rem; padding: 0.45rem 0; border-bottom: 1px solid var(--border); }
.news li:last-child { border-bottom: 0; }
.news time { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 0.92rem; padding-top: 0.08rem; }
.news-link { font-size: 0.85rem; white-space: nowrap; }
.news-link::before { content: "→ "; }

/* ------------------------------------------------------ publications */
.filters { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: center; margin-bottom: 0.5rem; }
.chips { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.chip {
  font: inherit;
  font-size: 0.85rem;
  padding: 0.25rem 0.7rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}
.chip:hover { border-color: var(--accent); }
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--bg); }
.chip .count { opacity: 0.7; font-variant-numeric: tabular-nums; }

.search {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex: 1 1 14rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.25rem 0.8rem;
  background: var(--surface);
  color: var(--muted);
}
.search input { border: 0; outline: 0; background: transparent; color: var(--text); font: inherit; font-size: 0.9rem; width: 100%; }
.search:focus-within { border-color: var(--accent); }
.filter-status { color: var(--muted); font-size: 0.9rem; min-height: 1.5em; }

.pub-group h2 .count, .page-header .count { color: var(--muted); font-weight: 400; font-size: 0.9em; }

.pubs { list-style: none; padding: 0; margin: 0; }
.pub { display: grid; grid-template-columns: 7.5rem minmax(0, 1fr); gap: 1rem; padding: 0.9rem 0; border-bottom: 1px solid var(--border); }
.pub:last-child { border-bottom: 0; }
.pub:target { background: var(--accent-soft); border-radius: var(--radius); padding-left: 0.6rem; padding-right: 0.6rem; margin: 0 -0.6rem; }
.pub-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 6px;
  padding: 0.15rem 0.45rem;
  height: fit-content;
  justify-self: start;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.pub-body { min-width: 0; }
.pub-body p { margin: 0; }
.pub-title { font-weight: 600; line-height: 1.4; }
.pub-authors, .pub-venue { font-size: 0.93rem; color: var(--muted); }
.pub-authors .me { color: var(--me); font-weight: 600; }
.pub-meta { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 0.4rem; margin-top: 0.45rem; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.78rem;
  font-weight: 600;
  border-radius: 6px;
  padding: 0.1rem 0.5rem;
  line-height: 1.6;
}
.badge.award { color: var(--award); background: var(--award-soft); }
.badge.small { font-size: 0.72rem; padding: 0 0.4rem; }
.badge.link { color: var(--muted); border: 1px solid var(--border); cursor: pointer; }
.badge.link:hover { color: var(--accent); border-color: var(--accent); text-decoration: none; }

details.bibtex { flex-basis: 100%; min-width: 0; }
details.bibtex > summary { list-style: none; display: inline-flex; }
details.bibtex > summary::-webkit-details-marker { display: none; }
details.bibtex[open] { flex-basis: 100%; }
details.bibtex pre {
  margin: 0.5rem 0 0;
  padding: 0.75rem 0.9rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  font: 0.78rem/1.5 var(--mono);
  overflow-x: auto;
}
.pub-meta > .badge + details.bibtex:not([open]),
.pub-meta > details.bibtex:not([open]) { flex-basis: auto; }

.pub[hidden], .pub-group[hidden] { display: none; }

/* ---------------------------------------------------------- research */
.trends { display: grid; grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); gap: 1rem; margin: 1.5rem 0; }
.trends p { font-size: 0.95rem; }

.question {
  margin: 2rem 0;
  padding: 1.25rem 1.5rem;
  border-radius: var(--radius);
  background: var(--accent-soft);
  font-size: 1.2rem;
  font-weight: 550;
  line-height: 1.45;
}
.question p { margin: 0; }

.front-cards { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); gap: 0.75rem; margin: 1.5rem 0 1rem; }
.front-cards a {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  height: 100%;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
}
.front-cards a:hover { border-color: var(--accent); text-decoration: none; }
.front-cards strong { line-height: 1.35; }
.front-cards span:last-child { color: var(--muted); font-size: 0.9rem; }

.num {
  display: inline-grid;
  place-items: center;
  width: 1.6rem;
  height: 1.6rem;
  border-radius: 50%;
  background: var(--accent);
  color: var(--bg);
  font-size: 0.85rem;
  font-weight: 700;
  flex: none;
}
.front h2 { display: flex; gap: 0.6rem; align-items: baseline; }
.front h2 .num { transform: translateY(-0.1rem); }
.front { border-top: 1px solid var(--border); margin-top: 2.5rem; }
.cite { font-size: 0.9em; white-space: nowrap; }

.pub-compact { list-style: none; padding: 0; margin: 0.6rem 0 0; font-size: 0.93rem; }
.pub-compact li { padding: 0.25rem 0; }
.pub-compact a { color: var(--text); }
.pub-compact a:hover { color: var(--accent); }
.pub-compact .pub-label { margin-right: 0.35rem; }
.related { margin-top: 1rem; }

.future { padding-left: 1.2rem; }
.future h3 { margin-top: 1.25rem; }
.closing { font-style: italic; }

/* ---------------------------------------------------------- teaching */
.courses { list-style: none; padding: 0; margin: 0; }
.course { padding: 0.75rem 0; border-bottom: 1px solid var(--border); }
.course:last-child { border-bottom: 0; }
.course-head { display: flex; gap: 0.6rem; flex-wrap: wrap; align-items: baseline; }
.course-code { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--accent); white-space: nowrap; }
.course-title { font-weight: 600; }
.course-meta { display: flex; flex-wrap: wrap; gap: 0.35rem; align-items: center; margin-top: 0.3rem; font-size: 0.88rem; color: var(--muted); }
.course-role { margin-right: 0.3rem; }
.term { border: 1px solid var(--border); border-radius: 999px; padding: 0 0.55rem; background: var(--surface); }

.interest-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr)); gap: 1rem; }
.interest-grid ul { padding-left: 1.1rem; margin: 0; font-size: 0.95rem; }

/* ----------------------------------------------------------- service */
.dated { list-style: none; padding: 0; margin: 0; }
.dated li { display: grid; grid-template-columns: 3.5rem 1fr; gap: 0.75rem; padding: 0.35rem 0; }
.year { color: var(--muted); font-variant-numeric: tabular-nums; }
.two-col { columns: 2 18rem; column-gap: 2rem; padding-left: 1.1rem; }
.two-col li { break-inside: avoid; margin-bottom: 0.3rem; }

/* -------------------------------------------------------- good stuffs */
.link-list { list-style: none; padding: 0; }
.link-list li { padding: 0.45rem 0; border-bottom: 1px solid var(--border); display: flex; flex-direction: column; }
.link-list li:last-child { border-bottom: 0; }
.link-list a { display: inline-flex; align-items: center; gap: 0.35rem; font-weight: 550; width: fit-content; }
.link-list a .icon { width: 0.8em; height: 0.8em; opacity: 0.6; }
.link-list .muted { font-size: 0.9rem; }

/* ---------------------------------------------------------------- CV */
.cv-header { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; }
.actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.button {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  background: var(--accent);
  color: var(--bg);
  font-weight: 600;
  font-size: 0.92rem;
  border: 1px solid var(--accent);
}
.button:hover { text-decoration: none; filter: brightness(1.08); }
.button.secondary { background: transparent; color: var(--accent); }
.pdf-frame { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--surface); box-shadow: var(--shadow); }
.pdf-frame iframe { display: block; width: 100%; height: 85vh; border: 0; }

/* ------------------------------------------------------------ mobile */
@media (max-width: 640px) {
  body { font-size: 16px; }
  .header-inner { gap: 0.25rem 1rem; padding-top: 0.5rem; padding-bottom: 0.5rem; }
  .site-nav { order: 3; margin-left: 0; width: 100%; font-size: 0.9rem; }
  .theme-toggle { margin-left: auto; }
  main { padding-top: 1.75rem; }
  h1 { font-size: 1.7rem; }
  .hero { flex-direction: column; align-items: flex-start; gap: 1.25rem; }
  .avatar { width: 128px; height: 128px; }
  .hero h1 { font-size: 1.9rem; }
  .news li { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .pub { grid-template-columns: minmax(0, 1fr); gap: 0.35rem; }
  .pdf-frame iframe { height: 70vh; }
}
