:root {
  --primary: #0b66b2;
  --primary-light: #eef6ff;
  --text-main: #2d3748;
  --text-light: #718096;
  --heading: #1a202c;
  --bg: #f8fafc;
  --card-bg: #ffffff;
  --pku-red: #8c0000;
  --border-color: #edf2f7;
  --hiring-bg: #fffaf0;
  --hiring-border: #ed8936;
  --hover-bg: #f1f5f9;
}

/* 夜间模式变量 */
[data-theme="dark"] {
  --bg: #0f172a;
  --card-bg: #1e293b;
  --text-main: #e2e8f0;
  --text-light: #94a3b8;
  --heading: #f8fafc;
  --primary-light: #1e293b;
  --primary: #38bdf8;
  /* 稍微调亮蓝色以适应深色背景 */
  --border-color: #334155;
  --hiring-bg: #2d2a24;
  /* 深色调的橙色背景 */
  --hiring-border: #f6ad55;
  --hover-bg: #334155;
}

/* 微调原有样式以支持变量 */
#container {
  background: var(--card-bg);
  /* 确保背景使用变量 */
}

.tabs-nav {
  background: var(--card-bg);
  /* 确保粘性导航也跟随变色 */
}

.pub-card:hover {
  background: var(--primary-light);
  /* 使用变量代替硬编码的 #f1f5f9 */
}

.social-links a {
  border-color: var(--text-light);
  color: var(--text-main);
}

/* 主题切换按钮样式 */
#theme-toggle {
  position: absolute;
  top: 50px;
  right: 50px;
  background: none;
  border: 1px solid var(--text-light);
  color: var(--text-main);
  padding: 8px;
  border-radius: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  transition: 0.2s;
}

#theme-toggle:hover {
  background: var(--hover-bg); /* 使用我们专门定义的悬停背景变量 */
  color: var(--primary);       /* 悬停时让图标颜色也变一下，增加反馈感 */
  border-color: var(--primary);
}

@media (max-width: 768px) {
  #theme-toggle {
    top: 20px;
    right: 20px;
  }
  .tabs-nav {
    display: flex;
    flex-wrap: wrap;          /* 允许换行实现 2x2 布局 */
    overflow: visible;        /* 关键：确保不产生任何方向的滚动条 */
    border-bottom: none;      /* 移除容器底边，改由按钮底边代替 */
    background: var(--card-bg);
    position: sticky;
    top: 0;
    z-index: 10;
  }

  .tab-btn {
    flex: 0 0 50%;            /* 强制每个按钮占 50% 宽度 */
    padding: 12px 5px;        /* 适当的内边距 */
    font-size: 0.9rem;
    text-align: center;
    border-bottom: 2px solid var(--border-color); /* 统一底部线条 */
    box-sizing: border-box;
    white-space: nowrap;      /* 防止文字在按钮内部换行 */
  }

  .tab-btn.active::after {
    bottom: -2px;             /* 让高亮蓝条覆盖在 border-bottom 之上 */
    width: 100%;
    left: 0;
  }

}

* {
  box-sizing: border-box;
}

html {
  font-size: 16px;
}

body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background-color: var(--bg);
  color: var(--text-main);
  line-height: 1.6;
  margin: 0;
  padding: 0;
  scroll-behavior: smooth;
  font-size: 1rem;
  /* 1rem = 16px */
}

a {
  color: var(--primary);
  text-decoration: none;
  transition: 0.2s;
}

a:hover {
  text-decoration: underline;
}

/* Container Layout */
#container {
  max-width: 960px;
  margin: 40px auto;
  background: var(--card-bg);
  padding: 50px;
  border-radius: 20px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.04);
  overflow: hidden;
  position: relative;
}

/* Header / Bio */
.profile-section {
  display: flex;
  gap: 40px;
  align-items: center;
  margin-bottom: 40px;
}

.portrait-wrapper {
  flex: 0 0 240px;
}

.portrait {
  width: 100%;
  border-radius: 16px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.08);
  height: auto;
}

.bio-wrapper {
  flex: 1;
}

h1 {
  font-size: 2.4rem;
  margin: 0 0 10px 0;
  color: var(--heading);
  font-weight: 800;
}

.email-tag {
  background: var(--primary-light);
  color: var(--primary);
  padding: 4px 12px;
  border-radius: 20px;
  font-family: monospace;
  font-size: 0.95rem;
  display: inline-block;
  margin: 10px 0;
}

.social-links {
  margin-top: 20px;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.social-links a {
  padding: 6px 16px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-main);
}

.social-links a:hover {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
  text-decoration: none;
}

/* Hiring Box */
.hiring-box {
  background: var(--hiring-bg);
  border-left: 4px solid var(--hiring-border);
  padding: 16px 20px;
  margin: 25px 0;
  border-radius: 4px;
}

/* Tab Navigation */
.tabs-nav {
  display: flex;
  border-bottom: 2px solid var(--border-color);
  margin-bottom: 30px;
  position: sticky;
  top: 0;
  background: var(--card-bg);
  z-index: 10;
}

.tab-btn {
  padding: 12px 24px;
  cursor: pointer;
  border: none;
  background: none;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-light);
  position: relative;
  transition: 0.2s;
}

.tab-btn:hover {
  color: var(--primary);
}

.tab-btn.active {
  color: var(--primary);
}

.tab-btn.active::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 100%;
  height: 2px;
  background: var(--primary);
}

/* Tab Content Control */
.tab-content {
  display: none;
  animation: fadeIn 0.4s ease;
}

.tab-content.active {
  display: block;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Content styles */
section-title {
  display: block;
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--heading);
  margin: 50px 0 10px 0;
  padding-bottom: 8px;
  /* border-bottom: 2px solid var(--border-color); */
}

.year-tag {
  font-weight: 800;
  font-size: 1.2rem;
  color: var(--text-light);
  margin: 30px 0 15px 0;
  display: block;
}

.pub-card {
  padding: 16px;
  margin-bottom: 15px;
  border-radius: 12px;
  transition: 0.2s;
  border: 1px solid transparent;
}

.pub-card:hover {
  background: var(--hover-bg);
  border-color: var(--border-color);
}

.pub-title {
  display: block;
  font-weight: 600;
  color: var(--heading);
  font-size: 1.05rem;
  line-height: 1.4;
}

.pub-venue {
  display: inline-block;
  font-weight: 700;
  color: var(--primary);
  margin: 4px 0;
}

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

.lang-info {
  font-size: 0.9rem;
  color: var(--text-light);
  font-style: italic;
  margin-top: 6px;
  display: block;
}

ul {
  padding-left: 20px;
}

li {
  margin-bottom: 8px;
}

/* 回到顶部按钮样式 */
#backToTop {
  display: none;
  position: fixed;
  bottom: 30px;
  right: 30px;
  z-index: 99;
  border: 1px solid rgba(255, 255, 255, 0.3);
  outline: none;
  background: rgba(11, 102, 178, 0.15);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: var(--primary);
  cursor: pointer;
  width: 45px;
  height: 45px;
  border-radius: 12px;
  font-size: 20px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
  justify-content: center;
}

#backToTop:hover {
  background: var(--primary);
  color: white;
  transform: translateY(-5px);
  box-shadow: 0 8px 15px rgba(11, 102, 178, 0.2);
}

#backToTop svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Responsive */
@media (max-width: 768px) {
  #container {
    padding: 25px;
    margin: 10px;
    border-radius: 10px;
  }

  .profile-section {
    flex-direction: column;
    text-align: center;
  }

  .portrait-wrapper {
    flex: 0 0 180px;
    width: 180px;
  }

  .portrait {
    width: 100%;
  }

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

  .tabs-nav {
    overflow-x: auto;
    white-space: nowrap;
  }

  #backToTop {
    bottom: 20px;
    right: 20px;
  }
}