:root {
  --ink: #1c1d1f;
  --ink-soft: #4a4c52;
  --ink-faint: #666971;
  --paper: #fdfcfa;
  --paper-alt: #f4f2ee;
  --line: #e3e0d9;
  --accent: #7a3b2e;
  --accent-soft: #a8593f;
  --accent-btn: #7a3b2e;
  --accent-btn-hover: #a8593f;
  --header-bg: rgba(253, 252, 250, 0.92);
  --shadow: rgba(28, 29, 31, 0.14);
  --serif: "Source Serif 4", "Noto Serif SC", "Songti SC", Georgia, "Times New Roman", serif;
  --sans: "Inter", "PingFang SC", "Microsoft YaHei", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --max: 800px;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --ink: #f2ede6;
  --ink-soft: #c7c0b8;
  --ink-faint: #a29b91;
  --paper: #17151a;
  --paper-alt: #221f1e;
  --line: #38332f;
  --accent: #d97757;
  --accent-soft: #e6987b;
  --header-bg: rgba(23, 21, 26, 0.85);
  --shadow: rgba(0, 0, 0, 0.4);
  color-scheme: dark;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.2s ease, color 0.2s ease;
}

/* CJK text needs more line-height to stay comfortable to read */
html[lang="zh"] body {
  line-height: 1.9;
}
html[lang="zh"] .eyebrow,
html[lang="zh"] .contact-label,
html[lang="zh"] .timeline-date {
  line-height: 1.5;
}

::selection {
  background: var(--accent-btn);
  color: #fff;
}

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

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

.wrap {
  max-width: var(--max);
  margin: 0 auto;
  padding: 0 24px;
}

.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--accent-btn);
  color: #fff;
  padding: 10px 16px;
  z-index: 100;
}
.skip-link:focus { left: 12px; top: 12px; }

/* Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--header-bg);
  backdrop-filter: saturate(180%) blur(8px);
  border-bottom: 1px solid var(--line);
}

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

.brand {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 1.15rem;
  color: var(--ink);
  text-decoration: none;
  letter-spacing: 0.01em;
}

.site-nav {
  display: flex;
  gap: 28px;
}

.site-nav a {
  color: var(--ink-soft);
  text-decoration: none;
  font-size: 0.92rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  transition: color 0.15s ease;
}

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

.header-right {
  display: flex;
  align-items: center;
  gap: 14px;
}

.lang-toggle {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ink-soft);
  font-family: var(--sans);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 20px;
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease;
}
.lang-toggle:hover,
.lang-toggle:focus-visible {
  border-color: var(--accent);
  color: var(--accent);
}

.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--ink-soft);
  cursor: pointer;
  padding: 0;
  transition: border-color 0.15s ease, color 0.15s ease;
}
.theme-toggle:hover,
.theme-toggle:focus-visible {
  border-color: var(--accent);
  color: var(--accent);
}
.theme-toggle svg {
  width: 17px;
  height: 17px;
}
.theme-toggle .icon-moon { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: block; }

.nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 36px;
  height: 36px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
}
.nav-toggle span {
  display: block;
  height: 2px;
  background: var(--ink);
  border-radius: 2px;
}

/* Language toggle visibility */
html[lang="en"] .i18n-zh { display: none; }
html[lang="zh"] .i18n-en { display: none; }

.pub-overview {
  color: var(--ink-soft);
  max-width: 620px;
  margin: 0 0 32px;
}

.pub-note {
  font-size: 0.85rem;
  color: var(--ink-faint);
  font-style: italic;
  margin: -8px 0 18px;
}

/* Hero */
.hero {
  padding: 96px 0 72px;
  border-bottom: 1px solid var(--line);
}

.hero-inner {
  display: flex;
  align-items: center;
  gap: 44px;
}

.avatar {
  width: 168px;
  height: 168px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  border: 4px solid var(--paper);
  box-shadow: 0 6px 24px var(--shadow);
}

.hero-text { min-width: 0; }

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--accent);
  margin: 0 0 18px;
}

.hero h1 {
  font-family: var(--serif);
  font-size: clamp(2.4rem, 5vw, 3.4rem);
  line-height: 1.1;
  margin: 0 0 22px;
  font-weight: 700;
}

.hero-lede {
  font-size: 1.1rem;
  color: var(--ink-soft);
  max-width: 640px;
  margin: 0 0 32px;
}

.hero-actions {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
}

.btn {
  display: inline-block;
  padding: 12px 24px;
  border-radius: 3px;
  font-size: 0.94rem;
  font-weight: 600;
  text-decoration: none;
  border: 1px solid transparent;
  transition: transform 0.12s ease, background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.btn:hover { transform: translateY(-1px); }

.btn-primary {
  background: var(--accent-btn);
  color: #fff;
}
.btn-primary:hover { background: var(--accent-btn-hover); }

.btn-secondary {
  background: transparent;
  color: var(--ink);
  border-color: var(--line);
}
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); }

/* Sections */
.section { padding: 72px 0; }
.section-alt { background: var(--paper-alt); }

.section-title {
  font-family: var(--serif);
  font-size: 1.8rem;
  font-weight: 700;
  margin: 0 0 40px;
  position: relative;
  padding-bottom: 14px;
}
.section-title::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0;
  width: 44px;
  height: 3px;
  background: var(--accent);
  border-radius: 2px;
}

.subsection-title {
  font-family: var(--serif);
  font-size: 1.25rem;
  font-weight: 600;
  margin: 48px 0 20px;
  color: var(--ink);
}
.subsection-title:first-of-type { margin-top: 0; }

/* About */
.about-grid {
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  gap: 48px;
}

.about-text p { color: var(--ink-soft); margin: 0 0 18px; }
.about-text p:last-child { margin-bottom: 0; }

.about-side {
  background: var(--paper-alt);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 24px;
  align-self: start;
}

.about-side h3 {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-faint);
  margin: 0 0 16px;
  font-weight: 600;
}

.tag-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag-list li {
  background: var(--paper);
  border: 1px solid var(--line);
  color: var(--ink-soft);
  padding: 6px 13px;
  border-radius: 20px;
  font-size: 0.85rem;
}

/* Timeline */
.timeline {
  list-style: none;
  margin: 0;
  padding: 0;
  border-left: 2px solid var(--line);
}

.timeline-item {
  position: relative;
  padding: 0 0 34px 28px;
}
.timeline-item:last-child { padding-bottom: 0; }

.timeline-item::before {
  content: "";
  position: absolute;
  left: -7px;
  top: 3px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--paper-alt);
}

/* The most recent entry in each list carries a touch more visual weight */
.timeline-item:first-child::before {
  width: 12px;
  height: 12px;
  left: -8px;
  top: 2px;
  box-shadow: 0 0 0 4px var(--paper-alt), 0 0 0 5px var(--accent);
}
.timeline-item:first-child .timeline-body h4 {
  color: var(--accent);
}

.timeline-date {
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--accent);
  text-transform: uppercase;
  margin-bottom: 4px;
}

.timeline-body h4 {
  font-family: var(--serif);
  font-size: 1.1rem;
  margin: 0 0 4px;
  font-weight: 600;
}

.timeline-org {
  font-size: 0.9rem;
  color: var(--ink-faint);
  margin: 0 0 8px;
  font-style: italic;
}

.timeline-body p:not(.timeline-org) {
  color: var(--ink-soft);
  margin: 0;
  font-size: 0.96rem;
  max-width: 62ch;
}

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

.pub-list li {
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
  color: var(--ink-soft);
  font-size: 0.96rem;
  line-height: 1.6;
}
.pub-list li:first-child { padding-top: 0; }
.pub-list li:last-child { border-bottom: none; }

.pub-list a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
  white-space: nowrap;
}
.pub-list a:hover { text-decoration: underline; }

.contrib {
  margin-bottom: 16px;
  padding: 20px 24px;
  background: var(--paper-alt);
  border: 1px solid var(--line);
  border-radius: 10px;
}
.contrib:last-of-type { margin-bottom: 0; }
.contrib h4 {
  font-family: var(--serif);
  font-size: 1.05rem;
  margin: 0 0 6px;
  font-weight: 600;
}
.contrib p {
  color: var(--ink-soft);
  margin: 0;
  font-size: 0.96rem;
  max-width: 62ch;
}

/* Contact */
.contact-lede {
  color: var(--ink-soft);
  max-width: 560px;
  margin: 0 0 36px;
}

.contact-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

.contact-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 20px 22px;
  text-decoration: none;
  color: var(--ink);
  transition: border-color 0.15s ease, transform 0.12s ease;
}

a.contact-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}

.contact-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-faint);
  font-weight: 600;
}

.contact-value {
  font-family: var(--serif);
  font-size: 1.02rem;
  word-break: break-word;
}

/* Moments */
.moments-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.moment-card {
  margin: 0;
  position: relative;
  border-radius: 8px;
  overflow: hidden;
  aspect-ratio: 3 / 4;
  background: var(--paper-alt);
}

.moment-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.3s ease;
}

.moment-card:hover img { transform: scale(1.04); }

.moment-card figcaption {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 28px 16px 12px;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.55), transparent);
  color: #fff;
  font-size: 0.85rem;
  font-weight: 500;
}

/* Footer */
.site-footer {
  border-top: 1px solid var(--line);
  padding: 28px 0;
}
.site-footer p {
  margin: 0;
  color: var(--ink-faint);
  font-size: 0.85rem;
}

/* Responsive */
@media (max-width: 720px) {
  .about-grid { grid-template-columns: 1fr; }

  .hero-inner {
    flex-direction: column;
    text-align: center;
    gap: 24px;
  }
  .avatar { width: 128px; height: 128px; }
  .hero-lede { margin-left: auto; margin-right: auto; }
  .hero-actions { justify-content: center; }

  .moments-grid { grid-template-columns: 1fr; }

  .nav-toggle { display: flex; }

  .site-nav {
    position: absolute;
    top: 64px;
    left: 0;
    right: 0;
    background: var(--paper);
    border-bottom: 1px solid var(--line);
    flex-direction: column;
    gap: 0;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.2s ease;
  }
  .site-nav.open { max-height: 260px; }
  .site-nav a {
    padding: 14px 24px;
    border-bottom: 1px solid var(--line);
  }

  .hero { padding: 56px 0 48px; }
  .section { padding: 52px 0; }
}
