/* ========== Base ========== */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  color: #333;
  line-height: 1.75;
  background: #fff;
  -webkit-font-smoothing: antialiased;
  padding-top: 56px;
}

.container {
  max-width: 820px;
  margin: 0 auto;
  padding: 32px 24px;
}

a {
  color: #1772d0;
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

hr {
  border: none;
  border-top: 1px solid #ddd;
  margin: 36px 0;
}

/* ========== Language ========== */
[data-lang-zh] {
  display: none;
}

body.lang-zh [data-lang-en] {
  display: none;
}

body.lang-zh [data-lang-zh] {
  display: inline;
}

/* ========== Top Navigation ========== */
.topnav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background: #fff;
  border-bottom: 1px solid #e5e7eb;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.topnav-inner {
  max-width: 820px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  height: 56px;
  gap: 8px;
}

.nav-name {
  font-weight: 700;
  font-size: 1.1rem;
  color: #222;
  margin-right: 24px;
  white-space: nowrap;
  text-decoration: none;
}

.nav-name:hover {
  text-decoration: none;
  color: #1772d0;
}

.nav-links {
  display: flex;
  gap: 4px;
  flex: 1;
  overflow-x: auto;
}

.nav-tab {
  padding: 6px 16px;
  font-size: 0.9rem;
  color: #666;
  border-radius: 6px;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
}

.nav-tab:hover {
  background: #f3f4f6;
  color: #333;
  text-decoration: none;
}

.nav-tab.active {
  background: #eff6ff;
  color: #1772d0;
  font-weight: 600;
}

.lang-btn {
  margin-left: auto;
  background: none;
  border: 1px solid #d1d5db;
  padding: 4px 12px;
  font-size: 0.82rem;
  color: #666;
  cursor: pointer;
  border-radius: 4px;
  font-family: inherit;
  white-space: nowrap;
}

.lang-btn:hover {
  border-color: #1772d0;
  color: #1772d0;
}

/* ========== Page Sections ========== */
.page {
  display: none;
}

.page.active {
  display: block;
}

/* ========== Bio / Header ========== */
.bio {
  display: flex;
  gap: 36px;
  align-items: flex-start;
  margin-bottom: 36px;
}

.bio-photo {
  flex-shrink: 0;
}

.avatar-img {
  width: 180px;
  height: 180px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid #e5e7eb;
}

.bio-text h1 {
  font-size: 1.8rem;
  font-weight: 700;
  margin-bottom: 4px;
  color: #111;
}

.bio-chinese-name {
  font-size: 1.1rem;
  font-weight: 400;
  color: #888;
}

.bio-affiliation {
  font-size: 1.05rem;
  color: #444;
  margin-bottom: 2px;
}

.bio-location {
  font-size: 0.9rem;
  color: #888;
  margin-bottom: 12px;
}

.bio-links {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.bio-links a {
  font-size: 0.9rem;
  padding: 4px 12px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  color: #555;
  transition: all 0.15s;
}

.bio-links a:hover {
  border-color: #1772d0;
  color: #1772d0;
  text-decoration: none;
  background: #f8faff;
}

.bio-interests {
  margin-top: 8px;
}

.interest-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
}

.interest-label {
  font-size: 0.82rem;
  color: #999;
  margin-right: 4px;
  white-space: nowrap;
}

.interest-tag {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 3px;
  font-size: 0.8rem;
  font-weight: 500;
  white-space: nowrap;
}

.tag-pro {
  background: #eef2ff;
  color: #4338ca;
  border: 1px solid #c7d2fe;
}

.tag-hobby {
  background: #fef9ec;
  color: #b45309;
  border: 1px solid #fde68a;
}

/* ========== About Sections ========== */
.about-section {
  margin-bottom: 32px;
}

.about-section h2 {
  font-size: 1.3rem;
  font-weight: 700;
  color: #222;
  margin-bottom: 14px;
  padding-bottom: 8px;
  border-bottom: 2px solid #e5e7eb;
}

.about-section p {
  font-size: 0.95rem;
  color: #444;
  margin-bottom: 12px;
}

/* ========== Education ========== */
.edu-item {
  margin-bottom: 16px;
}

.edu-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  margin-bottom: 2px;
}

.edu-header strong {
  font-size: 0.95rem;
}

.edu-detail {
  font-size: 0.88rem;
  color: #666;
}

/* ========== News ========== */
.news-list {
  list-style: none;
  padding: 0;
}

.news-list li {
  padding: 8px 0;
  font-size: 0.92rem;
  color: #444;
  border-bottom: 1px solid #f3f4f6;
}

.news-list li:last-child {
  border-bottom: none;
}

.news-list .testimonials {
  margin-top: 8px;
  width: 100%;
}

.news-date {
  display: inline-block;
  min-width: 80px;
  font-size: 0.82rem;
  font-weight: 600;
  color: #1772d0;
  margin-right: 8px;
}

/* ========== Date Tag ========== */
.date-tag {
  font-size: 0.82rem;
  color: #888;
  white-space: nowrap;
  background: #f3f4f6;
  padding: 2px 10px;
  border-radius: 4px;
}

/* ========== Sections (h2) ========== */
h2 {
  font-size: 1.3rem;
  font-weight: 700;
  color: #222;
  margin-bottom: 20px;
  padding-bottom: 8px;
  border-bottom: 2px solid #e5e7eb;
}

h3 {
  font-size: 1.05rem;
  font-weight: bold;
  color: #333;
  margin-top: 24px;
  margin-bottom: 12px;
}

/* ========== CV Page ========== */
.cv-section {
  margin-bottom: 32px;
}

.cv-section-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: #222;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: 0;
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 2px solid #e5e7eb;
}

.cv-info-grid {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.cv-info-row {
  display: flex;
  gap: 16px;
  font-size: 0.92rem;
  line-height: 1.7;
}

.cv-info-label {
  min-width: 100px;
  font-weight: 600;
  color: #555;
  flex-shrink: 0;
}

.cv-info-value {
  color: #333;
}

.cv-entry {
  display: flex;
  gap: 24px;
  margin-bottom: 20px;
}

.cv-entry-time {
  min-width: 110px;
  flex-shrink: 0;
  font-size: 0.88rem;
  color: #888;
  padding-top: 2px;
  font-variant-numeric: tabular-nums;
}

.cv-entry-content {
  flex: 1;
  font-size: 0.92rem;
  color: #444;
  line-height: 1.7;
}

.cv-entry-title {
  font-weight: 700;
  font-size: 0.95rem;
  color: #222;
  font-variant: small-caps;
  text-transform: lowercase;
  letter-spacing: 0.03em;
}

.cv-entry-org {
  font-size: 0.92rem;
  color: #555;
  margin-bottom: 6px;
}

.cv-entry-note {
  font-size: 0.88rem;
  color: #666;
  margin-top: 2px;
}

.cv-entry-details {
  padding-left: 18px;
  margin-top: 6px;
}

.cv-entry-details li {
  margin-bottom: 8px;
  font-size: 0.9rem;
  color: #444;
  line-height: 1.65;
}

.cv-interests {
  padding-left: 18px;
  list-style: disc;
}

.cv-interests li {
  font-size: 0.92rem;
  color: #444;
  margin-bottom: 6px;
  line-height: 1.65;
}

.testimonials {
  margin-top: 10px;
}

.testimonials blockquote {
  margin: 0 0 8px 0;
  padding: 8px 14px;
  border-left: 3px solid #d1d5db;
  font-size: 0.85rem;
  color: #666;
  font-style: italic;
  background: #fafafa;
  border-radius: 0 4px 4px 0;
}

/* ========== Publications ========== */
.pub-list {
  padding-left: 20px;
}

.pub-list li {
  margin-bottom: 14px;
  font-size: 0.92rem;
  color: #444;
  line-height: 1.6;
}

.pub-list li strong {
  color: #222;
}

.pub-list li em {
  color: #666;
}

.patent-id {
  font-size: 0.82rem;
  color: #999;
  font-family: 'SF Mono', 'Menlo', monospace;
}

.patent-granted {
  font-size: 0.85rem;
  color: #16a34a;
  font-weight: bold;
}

.scholar-note {
  font-size: 0.92rem;
  color: #666;
  margin-bottom: 16px;
}

.patent-list li {
  margin-bottom: 10px;
}

/* ========== Awards ========== */
.awards-list {
  list-style: none;
  padding: 0;
}

.awards-list li {
  padding: 10px 0;
  font-size: 0.92rem;
  color: #444;
  border-bottom: 1px solid #f3f4f6;
  display: flex;
  gap: 12px;
  align-items: baseline;
}

.awards-list li:last-child {
  border-bottom: none;
}

/* ========== Footer ========== */
.footer {
  text-align: center;
  padding-top: 24px;
  margin-top: 40px;
  border-top: 1px solid #e5e7eb;
}

.footer p {
  font-size: 0.85rem;
  color: #999;
}

/* ========== Tabs (Projects sub-tabs) ========== */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid #e5e7eb;
  margin-bottom: 24px;
}

.tab-btn {
  padding: 10px 20px;
  border: none;
  background: none;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  color: #888;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color 0.2s, border-color 0.2s;
}

.tab-btn:hover {
  color: #444;
}

.tab-btn.active {
  color: #1772d0;
  border-bottom-color: #1772d0;
}

.tab-panel {
  display: none;
}

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

.project-item {
  margin-bottom: 20px;
  padding: 16px 20px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #fafbfc;
  transition: box-shadow 0.15s;
  cursor: pointer;
}

.project-item:hover {
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.project-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.project-header strong {
  font-size: 0.95rem;
  color: #222;
}

.project-status {
  font-size: 0.78rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 3px;
  white-space: nowrap;
}

.status-wip {
  background: #dbeafe;
  color: #1d4ed8;
}

.status-done {
  background: #dcfce7;
  color: #16a34a;
}

.status-plan {
  background: #f3e8ff;
  color: #7c3aed;
}

.project-desc {
  font-size: 0.9rem;
  color: #555;
  line-height: 1.65;
  margin-bottom: 10px;
}

.project-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.project-tag {
  display: inline-block;
  font-size: 0.75rem;
  padding: 1px 8px;
  border-radius: 3px;
  background: #f1f5f9;
  color: #64748b;
  border: 1px solid #e2e8f0;
}

.tab-note {
  font-size: 0.88rem;
  color: #888;
  margin-top: 16px;
  padding: 12px 16px;
  background: #f8fafc;
  border-left: 3px solid #1772d0;
  border-radius: 0 4px 4px 0;
}

/* ========== Project Detail View ========== */
.project-detail {
  padding-top: 8px;
}

.project-back-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 8px 16px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  background: #fff;
  color: #555;
  font-size: 0.9rem;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s;
  margin-bottom: 24px;
}

.project-back-btn:hover {
  border-color: #1772d0;
  color: #1772d0;
  background: #f8faff;
}

/* Markdown rendered content */
#project-detail-content {
  line-height: 1.8;
}

#project-detail-content h1 {
  font-size: 1.6rem;
  font-weight: 700;
  color: #111;
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 2px solid #e5e7eb;
}

#project-detail-content h2 {
  font-size: 1.25rem;
  font-weight: 700;
  color: #222;
  margin-top: 32px;
  margin-bottom: 14px;
  padding-bottom: 6px;
  border-bottom: 1px solid #e5e7eb;
}

#project-detail-content h3 {
  font-size: 1.05rem;
  font-weight: 700;
  color: #333;
  margin-top: 24px;
  margin-bottom: 10px;
}

#project-detail-content h4 {
  font-size: 0.95rem;
  font-weight: 700;
  color: #444;
  margin-top: 20px;
  margin-bottom: 8px;
}

#project-detail-content p {
  font-size: 0.95rem;
  color: #444;
  margin-bottom: 14px;
}

#project-detail-content ul,
#project-detail-content ol {
  padding-left: 24px;
  margin-bottom: 14px;
}

#project-detail-content li {
  font-size: 0.95rem;
  color: #444;
  margin-bottom: 6px;
  line-height: 1.7;
}

#project-detail-content img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  margin: 16px 0;
  border: 1px solid #e5e7eb;
}

#project-detail-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0;
  font-size: 0.9rem;
}

#project-detail-content th,
#project-detail-content td {
  padding: 10px 14px;
  border: 1px solid #e5e7eb;
  text-align: left;
}

#project-detail-content th {
  background: #f3f4f6;
  font-weight: 600;
  color: #333;
}

#project-detail-content td {
  color: #444;
}

#project-detail-content tr:hover {
  background: #fafbfc;
}

#project-detail-content code {
  font-family: 'SF Mono', 'Menlo', 'Consolas', monospace;
  font-size: 0.85em;
  background: #f3f4f6;
  padding: 2px 6px;
  border-radius: 3px;
  color: #d63384;
}

#project-detail-content pre {
  background: #1e1e2e;
  color: #cdd6f4;
  padding: 16px 20px;
  border-radius: 8px;
  overflow-x: auto;
  margin: 16px 0;
  line-height: 1.5;
}

#project-detail-content pre code {
  background: none;
  padding: 0;
  border-radius: 0;
  color: inherit;
  font-size: 0.88rem;
}

#project-detail-content blockquote {
  margin: 16px 0;
  padding: 12px 18px;
  border-left: 4px solid #1772d0;
  background: #f8faff;
  border-radius: 0 6px 6px 0;
  color: #555;
  font-size: 0.93rem;
}

#project-detail-content blockquote p {
  margin-bottom: 0;
}

#project-detail-content strong {
  color: #222;
}

#project-detail-content a {
  color: #1772d0;
  text-decoration: none;
}

#project-detail-content a:hover {
  text-decoration: underline;
}

/* KaTeX display math centering */
#project-detail-content .katex-display {
  margin: 20px 0;
  overflow-x: auto;
  overflow-y: hidden;
}

/* Loading and placeholder states */
.project-loading {
  text-align: center;
  color: #888;
  font-size: 0.95rem;
  padding: 48px 0;
}

.project-placeholder {
  text-align: center;
  padding: 64px 24px;
  color: #888;
  background: #fafbfc;
  border: 1px dashed #d1d5db;
  border-radius: 8px;
  margin-top: 8px;
}

.project-placeholder p {
  font-size: 1rem;
  color: #888;
}

/* ========== Responsive ========== */
@media (max-width: 640px) {
  .bio {
    flex-direction: column;
    align-items: center;
    text-align: center;
  }

  .avatar-img {
    width: 140px;
    height: 140px;
  }

  .bio-text h1 {
    font-size: 1.5rem;
  }

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

  .interest-group {
    justify-content: center;
  }

  .cv-entry {
    flex-direction: column;
    gap: 2px;
  }

  .cv-entry-time {
    min-width: unset;
  }

  .cv-info-row {
    flex-direction: column;
    gap: 0;
  }

  .edu-header {
    flex-direction: column;
    gap: 4px;
  }

  .tab-btn {
    padding: 8px 14px;
    font-size: 0.85rem;
  }

  .project-header {
    flex-direction: column;
    gap: 4px;
  }

  .awards-list li {
    flex-direction: column;
    gap: 4px;
  }

  .topnav-inner {
    padding: 0 12px;
    gap: 4px;
  }

  .nav-name {
    font-size: 0.95rem;
    margin-right: 8px;
  }

  .nav-tab {
    padding: 6px 10px;
    font-size: 0.82rem;
  }

  #project-detail-content h1 {
    font-size: 1.3rem;
  }

  #project-detail-content h2 {
    font-size: 1.1rem;
  }

  #project-detail-content table {
    font-size: 0.82rem;
    display: block;
    overflow-x: auto;
  }

  #project-detail-content th,
  #project-detail-content td {
    padding: 8px 10px;
  }

  .project-back-btn {
    font-size: 0.85rem;
    padding: 6px 12px;
  }
}
