:root {
  --bg: #ffffff;
  --text: #222222;
  --muted: #666666;
  --accent: #1a5fb4;
  --border: #e5e5e5;
  --nav-bg: rgba(255, 255, 255, 0.92);
  --hover-bg: #f1f5fb;
  --shadow: rgba(0, 0, 0, 0.15);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16181c;
    --text: #e6e6e6;
    --muted: #9a9a9a;
    --accent: #78aeed;
    --border: #2e3238;
    --nav-bg: rgba(22, 24, 28, 0.92);
    --hover-bg: #1f252d;
    --shadow: rgba(0, 0, 0, 0.5);
  }
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: 64px;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.6;
}

a {
  color: var(--accent);
  text-decoration: none;
}

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

/* Underline slides in on hover */
main a,
.footer a {
  background-image: linear-gradient(currentColor, currentColor);
  background-position: 0 100%;
  background-repeat: no-repeat;
  background-size: 0% 1px;
  transition: background-size 0.25s ease;
}

main a:hover,
.footer a:hover {
  background-size: 100% 1px;
}

.container {
  max-width: 860px;
  margin: 0 auto;
  padding: 0 20px;
}

/* ---------- Navigation ---------- */
.nav {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--nav-bg);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--border);
}

.nav-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 52px;
}

.nav-brand {
  font-weight: 700;
  color: var(--text);
}

.nav-links {
  display: flex;
  gap: 20px;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 0.95rem;
}

.nav-links a {
  position: relative;
  padding: 4px 0;
  color: var(--muted);
  transition: color 0.2s ease;
}

.nav-links a::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -2px;
  height: 2px;
  background: var(--accent);
  transform: scaleX(0);
  transition: transform 0.25s ease;
}

.nav-links a:hover,
.nav-links a.active {
  color: var(--accent);
}

.nav-links a:hover::after,
.nav-links a.active::after {
  transform: scaleX(1);
}

/* ---------- Profile ---------- */
.profile {
  display: flex;
  align-items: center;
  gap: 32px;
  padding: 48px 0 32px;
}

.profile.photo-right {
  flex-direction: row-reverse;
  justify-content: space-between;
}

.profile-photo {
  width: 160px;
  height: 160px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.profile h1 {
  margin: 0 0 8px;
  font-size: 2.75rem;
  line-height: 1.15;
  letter-spacing: -0.01em;
}

.profile-position {
  margin: 0;
  font-size: 1.1rem;
}

.profile-affiliation {
  margin: 4px 0 12px;
  color: var(--muted);
}

.profile-links {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin: 0;
  padding: 0;
  list-style: none;
}

/* ---------- Sections ---------- */
section {
  padding: 24px 0;
  border-top: 1px solid var(--border);
}

h2 {
  margin: 0 0 16px;
  font-size: 1.5rem;
}

h3 {
  margin: 24px 0 8px;
  font-size: 1.25rem;
  color: var(--accent);
}

h4 {
  margin: 16px 0 8px;
  font-size: 1.05rem;
  color: var(--muted);
}

/* ---------- About ---------- */
.about p {
  max-width: 70ch;
  margin: 0 0 12px;
}

.about p:last-child {
  margin-bottom: 0;
}

/* ---------- Education ---------- */
.edu-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.edu-list li {
  margin: 0 -12px;
  padding: 8px 12px;
  border-radius: 8px;
  transition: background-color 0.2s ease;
}

.edu-head {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}

.edu-degree {
  font-weight: 600;
}

.edu-period,
.edu-detail {
  color: var(--muted);
}

/* ---------- Research Interests ---------- */
.interest-list {
  margin: 0;
  padding-left: 20px;
}

.interest-list li {
  transition: color 0.2s ease;
}

/* ---------- Publications ---------- */
.pub-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.pub-list li {
  position: relative;
  margin: 0 -10px 4px;
  padding: 6px 10px 6px 66px;
  border-radius: 6px;
  transition: background-color 0.2s ease;
}

.pub-list li::before {
  content: attr(data-label);
  position: absolute;
  left: 10px;
  color: var(--muted);
  font-weight: 600;
  transition: color 0.2s ease;
}

.me {
  font-weight: 700;
  text-decoration: underline;
}

.pub-links a {
  margin-left: 4px;
  font-size: 0.9rem;
}

/* ---------- Footer ---------- */
.footer {
  padding: 24px 0 40px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.9rem;
  text-align: center;
}

/* ---------- Hover highlights (mouse only, so taps on phones don't stick) ---------- */
@media (hover: hover) {
  .profile-photo:hover {
    transform: scale(1.04);
    box-shadow: 0 8px 24px var(--shadow);
  }

  .about:has(p:hover) p:not(:hover) {
    color: var(--muted);
  }

  .edu-list li:hover,
  .pub-list li:hover {
    background: var(--hover-bg);
  }

  .interest-list li:hover,
  .pub-list li:hover::before {
    color: var(--accent);
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    transition: none !important;
  }
}

/* ---------- Mobile ---------- */
@media (max-width: 640px) {
  .nav-links {
    display: none;
  }

  .profile,
  .profile.photo-right {
    flex-direction: column;
    text-align: center;
  }

  .profile h1 {
    font-size: 2.25rem;
  }

  .profile-links {
    justify-content: center;
  }

  .profile-photo {
    width: 128px;
    height: 128px;
  }
}
