:root {
  color-scheme: light;
  --bg: #ffffff;
  --surface: #ffffff;
  --surface-strong: #ffffff;
  --text: #222222;
  --muted: #666666;
  --line: #e5e5e5;
  --accent: #2f6f6d;
  --accent-strong: #174b49;
  --soft: #f7f7f7;
  --shadow: 0 18px 45px rgba(0, 0, 0, 0.06);
  --sidebar-bg: rgba(255, 255, 255, 0.94);
  --code-bg: rgba(47, 111, 109, 0.1);
  --map-bg: #ffffff;
  --publication-link: #1f5fbf;
  --divider: rgba(0, 0, 0, 0.08);
  --toggle-track: #e6e9e9;
  --toggle-thumb: #ffffff;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111315;
  --surface: #171a1d;
  --surface-strong: #1c2024;
  --text: #e7e9ea;
  --muted: #a4abb2;
  --line: #30363d;
  --accent: #78b8b3;
  --accent-strong: #9cd4d0;
  --soft: #1c2024;
  --shadow: 0 18px 45px rgba(0, 0, 0, 0.28);
  --sidebar-bg: rgba(17, 19, 21, 0.94);
  --code-bg: rgba(120, 184, 179, 0.14);
  --map-bg: #ffffff;
  --publication-link: #78aaff;
  --divider: rgba(255, 255, 255, 0.12);
  --toggle-track: #394249;
  --toggle-thumb: #f2f4f5;
}

* {
  box-sizing: border-box;
}

html {
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}

body {
  min-height: 100vh;
  margin: 0;
  background: var(--bg);
  line-height: 1.6;
  transition: background-color 180ms ease, color 180ms ease;
}

a {
  color: inherit;
}

code {
  padding: 0.12rem 0.32rem;
  border-radius: 5px;
  background: var(--code-bg);
  color: var(--accent-strong);
  font-size: 0.92em;
}

.theme-toggle {
  position: fixed;
  top: 1.25rem;
  right: 1.25rem;
  z-index: 20;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 54px;
  height: 32px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-strong);
  color: var(--muted);
  cursor: pointer;
  box-shadow: var(--shadow);
}

.theme-toggle:hover {
  color: var(--text);
}

.theme-toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.theme-toggle-track {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 46px;
  height: 24px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--toggle-track);
}

.theme-toggle svg {
  position: relative;
  z-index: 1;
  width: 13px;
  height: 13px;
  stroke: currentColor;
}

.theme-toggle-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--toggle-thumb);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
  transition: transform 180ms ease;
}

:root[data-theme="dark"] .theme-toggle-thumb {
  transform: translateX(22px);
}

.site-sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  width: 300px;
  padding: 2rem 1.35rem;
  border-right: 1px solid var(--line);
  background: var(--sidebar-bg);
  backdrop-filter: blur(16px);
  transition: background-color 180ms ease, border-color 180ms ease;
}

.site-mark {
  margin-bottom: 1.2rem;
  font-weight: 800;
  text-decoration: none;
}

.sidebar-avatar {
  display: block;
  width: 176px;
  height: 176px;
  max-width: 176px;
  margin-bottom: 1rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  object-fit: cover;
}

.sidebar-role {
  margin-bottom: 1rem;
  color: var(--muted);
  font-size: 0.94rem;
  line-height: 1.45;
}

.social-icons {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  margin-top: 1rem;
  margin-bottom: 1.35rem;
}

.social-icons a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  color: var(--muted);
  text-decoration: none;
}

.social-icons a:hover {
  color: var(--accent);
}

.social-icons svg {
  display: block;
  width: 19px;
  height: 19px;
  fill: currentColor;
}

.site-nav {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.site-nav a {
  padding: 0.28rem 0;
  color: var(--muted);
  font-size: 0.94rem;
  text-decoration: none;
}

.site-nav a:hover {
  color: var(--accent-strong);
}

.sidebar-meta {
  margin: auto 0 0;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.45;
}

.site-main {
  min-height: 100vh;
  margin-left: 300px;
}

.page-shell {
  width: min(1180px, calc(100% - 96px));
  margin: 0 0 0 64px;
}

.eyebrow {
  margin: 0 0 0.45rem;
  color: var(--accent);
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

.button {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0.55rem 0.95rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  text-decoration: none;
}

.button-primary {
  border-color: var(--accent);
  background: var(--accent);
  color: white;
}

.section-grid {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  gap: 1.75rem;
  padding: 2rem 0;
  border-top: 1px solid var(--line);
}

.section-grid h2 {
  font-size: 1rem;
  font-weight: 400;
  line-height: 1.25;
}

.page-heading h1 {
  font-size: 1.35rem;
  font-weight: 600;
  line-height: 1.08;
}

.prose {
  max-width: 720px;
  color: var(--text);
  font-size: 1.05rem;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin-top: 1.25rem;
}

.tags span {
  padding: 0.42rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--accent-strong);
  font-size: 0.9rem;
}

.post-list {
  display: grid;
  border-top: 1px solid var(--line);
}

.post-list.large {
  margin-bottom: 5rem;
}

.post-row {
  display: flex;
  justify-content: space-between;
  gap: 1.5rem;
  padding: 1.05rem 0;
  border-bottom: 1px solid var(--line);
  text-decoration: none;
}

.post-row span {
  font-weight: 700;
}

.post-row time {
  flex: none;
  color: var(--muted);
}

.post-row:hover span {
  color: var(--accent);
}

.visitor-widget {
  display: grid;
  gap: 1rem;
}

.visitor-widget p {
  max-width: 680px;
  color: var(--text);
}

.misc-section {
  padding-top: 1rem;
  border-top: 1px solid var(--line);
}

.misc-section h2 {
  margin-bottom: 0.5rem;
  font-size: 1.1rem;
  font-weight: 500;
}

.misc-section p {
  color: var(--text);
}

.air-photo {
  width: calc((100% - 2rem) / 3);
  margin-bottom: 3rem;
}

.air-photo img {
  display: block;
  width: 100%;
  height: 260px;
  border: 1px solid var(--line);
  border-radius: 8px;
  object-fit: cover;
}

.cat-gallery {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
  width: 100%;
  margin-bottom: 4rem;
}

.cat-gallery img {
  width: 100%;
  height: 260px;
  border: 1px solid var(--line);
  border-radius: 8px;
  object-fit: cover;
}

.visitor-map-embed {
  display: grid;
  justify-items: start;
  max-width: 420px;
  min-height: 160px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--map-bg);
}

.visitor-map-embed img,
.visitor-map-embed iframe,
.visitor-map-embed canvas {
  width: 100%;
  max-width: 100%;
  height: auto;
}

.page-shell {
  padding: 5rem 0;
}

.page-heading {
  max-width: 760px;
  margin-bottom: 3rem;
}

.page-heading.compact {
  margin-bottom: 2rem;
}

.page-heading p {
  color: var(--text);
  font-size: 1.08rem;
}

.page-heading a,
.experience-item a,
.academic-service a {
  color: var(--accent-strong);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.page-heading.compact h1 {
  font-size: 1.35rem;
}

.chinese-name {
  margin-left: 0.45rem;
  color: var(--text);
  font-size: inherit;
  font-weight: inherit;
}

.timeline,
.publication-list,
.experience-list {
  display: grid;
  gap: 1rem;
}

.timeline-item {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr);
  gap: 1rem;
}

.timeline-item time {
  color: var(--accent);
  font-size: 0.9rem;
  font-weight: 700;
}

.timeline-item time.news-highlight {
  color: var(--text);
  font-weight: 800;
  white-space: nowrap;
}

.timeline-item p {
  margin-bottom: 0;
  color: var(--text);
}

.experience-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 140px;
  gap: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--line);
}

.experience-item h3,
.academic-service h3 {
  margin-bottom: 0.2rem;
  font-size: 1rem;
}

.experience-item p {
  margin-bottom: 0.15rem;
  color: var(--text);
}

.experience-item time {
  color: var(--text);
  font-size: 0.92rem;
  text-align: right;
}

.academic-service p {
  margin-bottom: 0;
  color: var(--text);
}

.publication-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 190px;
  gap: 1.25rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--line);
}

.publication-item h3 {
  margin-bottom: 0.35rem;
  font-size: 1rem;
  line-height: 1.35;
  color: var(--publication-link);
}

.publication-item h3 a {
  color: var(--publication-link);
  text-decoration: none;
}

.publication-item h3 a:hover {
  text-decoration: underline;
  text-underline-offset: 2px;
}

.publication-item p {
  margin-bottom: 0.3rem;
  color: var(--text);
}

.publication-item span {
  color: var(--accent);
  font-size: 0.92rem;
  font-weight: 700;
  text-align: right;
}

.empty-state {
  padding: 2rem 0;
  color: var(--muted);
}

.post {
  max-width: 760px;
  margin: 0 auto;
}

.back-link {
  color: var(--muted);
  font-size: 0.95rem;
  text-decoration: none;
}

.post-header {
  margin: 2rem 0 2.5rem;
}

.post-header h1 {
  font-size: 3.5rem;
  line-height: 1;
}

.post-description {
  color: var(--muted);
  font-size: 1.12rem;
}

.post-content {
  font-size: 1.08rem;
}

.post-content p,
.post-content li {
  color: var(--text);
}

.section-divider {
  width: 100%;
  height: 1px;
  margin: 2.4rem 0;
  border: 0;
  background: var(--divider);
}

.site-footer {
  width: min(1180px, calc(100% - 96px));
  margin: 0 0 0 64px;
  padding: 1.5rem 0 2rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.9rem;
}

@media (max-width: 820px) {
  .site-sidebar {
    position: sticky;
    top: 0;
    inset: auto;
    width: 100%;
    padding: 1rem 5rem 1rem 1.25rem;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .sidebar-avatar,
  .sidebar-role,
  .sidebar-meta,
  .social-icons {
    display: none;
  }

  .site-mark {
    margin-bottom: 0.55rem;
  }

  .site-nav {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 0.75rem;
  }

  .site-main {
    margin-left: 0;
  }

  .page-shell,
  .site-footer {
    width: calc(100% - 40px);
    margin: 0 auto;
  }

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

  .post-row {
    display: grid;
    gap: 0.35rem;
  }

  .experience-item,
  .publication-item {
    grid-template-columns: 1fr;
  }

  .experience-item time,
  .publication-item span {
    text-align: left;
  }

  .post-header h1 {
    font-size: 2.5rem;
  }
}

@media (max-width: 520px) {
  .theme-toggle {
    top: 0.8rem;
    right: 0.75rem;
  }

  .page-shell {
    width: calc(100% - 24px);
    margin: 0 auto;
  }

  .site-footer {
    width: calc(100% - 24px);
    margin: 0 auto;
  }

  .page-heading.compact h1 {
    font-size: 1.4rem;
  }

  .cat-gallery {
    gap: 0.5rem;
  }

  .air-photo {
    width: calc((100% - 1rem) / 3);
  }

  .air-photo img {
    height: 150px;
  }

  .cat-gallery img {
    height: 150px;
  }

  .timeline-item {
    grid-template-columns: 1fr;
    gap: 0.2rem;
  }
}
