:root {
  color-scheme: light;
  --bg: #ececec;
  --bg-tint: rgba(143, 77, 77, 0.08);
  --text: #272727;
  --text-soft: #444;
  --text-mid: #595959;
  --heading: #555;
  --muted: #666;
  --subtle: #7d7d7d;
  --accent: #8f4d4d;
  --accent-strong: #6d3b3b;
  --accent-underline: #7d4545;
  --focus-ring: rgba(143, 77, 77, 0.45);
  --line: #d7d7d7;
  --control-fg: #333;
  --control-hover-bg: rgba(0, 0, 0, 0.06);
  --pill-bg: #d9d9d9;
  --nav-bg: #707070;
  --nav-fg: #f3f3f3;
  --nav-link: #e6e6e6;
  --nav-link-hover: #ffffff;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111114;
  --bg-tint: rgba(220, 168, 168, 0.12);
  --text: #ececf2;
  --text-soft: #c9c9d3;
  --text-mid: #c8c8d2;
  --heading: #d7d7e0;
  --muted: #b2b2bd;
  --subtle: #9a9aa6;
  --accent: #e2b0b0;
  --accent-strong: #f0c3c3;
  --accent-underline: #c97f7f;
  --focus-ring: rgba(240, 195, 195, 0.38);
  --line: #2a2a33;
  --control-fg: #ececf2;
  --control-hover-bg: rgba(255, 255, 255, 0.1);
  --pill-bg: #2a2a33;
  --nav-bg: #1f1f25;
  --nav-fg: #f0f0f6;
  --nav-link: #dadbe5;
  --nav-link-hover: #ffffff;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: radial-gradient(900px circle at 18% 0%, var(--bg-tint), transparent 60%), var(--bg);
  color: var(--text);
  font-family: "Avenir Next", "Helvetica Neue", "Segoe UI", sans-serif;
  line-height: 1.45;
}

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

a:hover {
  text-decoration: underline;
}

.blue-link {
  color: #0056b3 !important;
}

html[data-theme="dark"] .blue-link {
  color: #7ab4ff !important;
}

.page {
  max-width: 1220px;
  margin: 0 auto;
  padding: 48px 28px 72px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.topbar-actions {
  position: fixed;
  top: 16px;
  right: 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  z-index: 1100;
}

.icon-btn {
  width: 42px;
  height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: 12px;
  color: var(--control-fg);
  cursor: pointer;
}

.icon-btn:hover {
  background: var(--control-hover-bg);
}

.icon-btn:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

.theme-glyph {
  position: relative;
  width: 20px;
  height: 20px;
  display: inline-grid;
  place-items: center;
}

.theme-icon {
  position: absolute;
  inset: 0;
  font-size: 18px;
  line-height: 20px;
  text-align: center;
  transition:
    transform 0.2s ease,
    opacity 0.2s ease;
}

.theme-icon-sun {
  opacity: 1;
  transform: rotate(0deg) scale(1);
}

.theme-icon-moon {
  opacity: 0;
  transform: rotate(24deg) scale(0.78);
}

.theme-btn.is-dark .theme-icon-sun {
  opacity: 0;
  transform: rotate(-20deg) scale(0.78);
}

.theme-btn.is-dark .theme-icon-moon {
  opacity: 1;
  transform: rotate(0deg) scale(1);
}

.menu-glyph {
  width: 20px;
  height: 20px;
  display: inline-grid;
  place-items: center;
}

.menu-icon {
  font-size: 18px;
  line-height: 1;
  transition: transform 0.2s ease;
}

.menu-btn.is-open .menu-icon {
  transform: rotate(90deg);
}

.name {
  margin: 0;
  font-size: 60px;
  line-height: 1;
  font-weight: 600;
}

.name-cn {
  color: var(--subtle);
  font-size: 24px;
  font-weight: 500;
}

.mobile-nav {
  position: fixed;
  top: 60px;
  right: 0;
  height: auto;
  width: 260px;
  max-width: 75%;
  background: var(--nav-bg);
  color: var(--nav-fg);
  padding: 16px 24px;
  display: none;
  z-index: 1000;
}

.mobile-nav.is-open {
  display: block;
}

.mobile-nav-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
  font-size: 20px;
}

.mobile-nav-list a {
  color: var(--nav-link);
  text-decoration: none;
}

.mobile-nav-list a:hover,
.mobile-nav-link:hover {
  color: var(--nav-link-hover);
}

.mobile-nav-link {
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  color: var(--nav-link);
  font: inherit;
  cursor: pointer;
  text-align: left;
}

.section-gap {
  margin-top: 44px;
}

.bio-grid {
  display: grid;
  grid-template-columns: 210px minmax(0, 1fr);
  gap: 44px;
}

.bio-left {
  padding-top: 4px;
}

.avatar {
  width: 170px;
  height: 215px;
  border-radius: 14px;
  object-fit: cover;
  object-position: center 15%;
  display: block;
}

.icon-row {
  margin-top: 18px;
  display: flex;
  gap: 22px;
  font-size: 24px;
}

.cv-link {
  display: inline-block;
  margin-top: 18px;
  font-size: 42px;
  font-weight: 700;
  text-decoration: underline;
}

.bio-tip {
  margin-top: 26px;
  font-size: 13px;
  color: var(--subtle);
}

.bio-right p {
  margin: 0 0 20px;
  line-height: 1.55;
}

.section-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

h2 {
  margin: 0;
  font-size: 42px;
  color: var(--heading);
}

.bio-right p {
  font-size: 20px;
}

.news-date {
  font-size: 19px;
}

.education-meta,
.education-main,
.news-text,
.pub-meta,
.pub-authors,
.pub-links {
  font-size: 17px;
}

.pub-note,
.pub-abstract {
  font-size: 15px;
}

#misc p {
  font-size: 18px;
  line-height: 1.58;
}

.section-heading {
  font-size: 28px;
  font-weight: 600;
}

.education-list {
  margin-top: 12px;
}

.education-item {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr) 140px;
  column-gap: 32px;
  padding: 16px 0;
  align-items: center;
}

.education-meta {
  text-align: right;
  color: var(--heading);
  line-height: 1.5;
}

.education-time {
  font-weight: 500;
}

.education-main {
  color: var(--text-soft);
}

.education-degree {
  font-weight: 600;
  margin-bottom: 4px;
}

.education-school {
  margin-bottom: 2px;
}

.education-logo {
  --education-logo-width: 140px;
  --education-logo-height: 48px;
  width: var(--education-logo-width);
  height: var(--education-logo-height);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.education-logo picture {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
}

.education-logo img {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  object-position: center;
}

.pager {
  display: none;
  align-items: center;
  gap: 12px;
}

.pager-btn,
.pager-num,
.tab {
  border: none;
  background: transparent;
  color: var(--control-fg);
  font-size: 14px;
  cursor: pointer;
}

.pager-num.is-active {
  width: 24px;
  height: 24px;
  border-radius: 999px;
  background: var(--pill-bg);
}

.news-row {
  display: grid;
  grid-template-columns: 170px 1fr;
  gap: 26px;
  padding: 16px 0;
}

.news-date {
  color: var(--text-soft);
  text-align: right;
}

.news-text {
}

.pub-note {
  color: var(--muted);
}

.pub-tabs {
  display: flex;
  gap: 26px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 12px;
  margin-bottom: 20px;
}

.tab {
  font-size: 16px;
  color: var(--muted);
}

.tab.is-active {
  color: var(--accent-strong);
  border-bottom: 4px solid var(--accent-underline);
  padding-bottom: 8px;
}

.pub-card {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 24px;
  padding-top: 10px;
}

.pub-card img {
  width: 100%;
}

.pub-body {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.pub-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 140px;
  align-items: stretch;
  column-gap: 24px;
}

.pub-header-main {
  min-width: 0;
}

.pub-header-logo {
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

.pub-header-logo img {
  max-width: 100%;
  max-height: 40px;
  object-fit: contain;
}

.pub-title {
  margin: 0 0 6px;
  font-size: 25px;
  font-weight: 600;
  color: var(--accent-strong);
}

.pub-meta,
.pub-authors {
  margin: 0;
  color: var(--text-mid);
}

.pub-meta {
  margin-bottom: 4px;
}

/* Venue Tag Base */
.venue-tag {
  display: inline-block;
  padding: 2px 8px;
  font-size: 16px;
  font-weight: 650;
  border-radius: 4px;
  color: var(--tag-color, var(--text-mid));
  background: var(--tag-bg, transparent);
  line-height: 1.4;
}

/* --- Specific Conference Colors --- */

/* CHI */
.venue-tag.tag-chi {
  --tag-color: #0066cc;
  --tag-border: #4da6ff;
  --tag-bg: rgba(77, 166, 255, 0.1);
}
html[data-theme="dark"] .venue-tag.tag-chi {
  --tag-color: #66b3ff;
  --tag-border: #3399ff;
  --tag-bg: rgba(102, 179, 255, 0.15);
}

/* Example for future venues (you can add more like this) */
.venue-tag.tag-uist {
  --tag-color: #0066cc;
  --tag-border: #4da6ff;
  --tag-bg: rgba(77, 166, 255, 0.1);
}
html[data-theme="dark"] .venue-tag.tag-uist {
  --tag-color: #66b3ff;
  --tag-border: #3399ff;
  --tag-bg: rgba(102, 179, 255, 0.15);
}

.pub-authors a {
  color: inherit;
  text-decoration: none;
}

.pub-authors a:hover {
  color: var(--accent);
  text-decoration: underline;
}

.pub-links {
  margin-top: 12px;
  display: flex;
  gap: 22px;
}

.pub-links-row {
  margin-top: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.pub-abstract-toggle {
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.pub-abstract-arrow {
  display: inline-block;
  transition: transform 0.2s ease;
}

.pub-abstract-toggle.is-open .pub-abstract-arrow {
  transform: rotate(180deg);
}

.pub-abstract {
  display: none;
  margin-top: 8px;
  color: var(--heading);
}

.pub-abstract.is-open {
  display: block;
}

@media (max-width: 1200px) {
  .name { font-size: 58px; }
  .name-cn { font-size: 27px; }
  .bio-right p { font-size: 20px; }
  h2 { font-size: 36px; }
  .news-date { font-size: 18px; }
  .news-text,
  .education-meta,
  .education-main,
  .pub-meta,
  .pub-authors,
  .pub-links,
  .tab {
    font-size: 16px;
  }
  .pub-title { font-size: 25px; }
  .cv-link { font-size: 34px; }
  .bio-tip { font-size: 13px; }
}

@media (max-width: 820px) {
  .page { padding: 24px 14px 42px; }
  .name { font-size: 34px; }
  .name-cn { font-size: 18px; }
  .bio-grid { grid-template-columns: 1fr; gap: 16px; }
  .bio-left { text-align: center; }
  .avatar {
    width: 140px;
    height: 180px;
    margin: 0 auto;
  }
  .icon-row {
    justify-content: center;
  }
  .pub-card { grid-template-columns: 1fr; }
  .pub-title { font-size: 20px; }
  .pub-meta, .pub-authors { font-size: 14px; }
  .pub-header-logo img { max-height: 32px; }
  .pub-links { font-size: 14px; gap: 14px; }
  #misc p { font-size: 16px; }
  .news-row { grid-template-columns: 1fr; gap: 4px; }
  .news-date { text-align: left; }
  .pub-tabs { flex-wrap: wrap; }
  .section-title-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }
  .pub-note {
    font-size: 12px;
  }
  .education-item {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "meta logo"
      "main logo";
    column-gap: 12px;
    row-gap: 4px;
    align-items: center;
  }
  .education-meta {
    grid-area: meta;
    text-align: left;
    font-size: 14px;
    display: flex;
    column-gap: 12px;
    align-items: center;
  }
  .education-main {
    grid-area: main;
  }
  .education-time,
  .education-place {
    white-space: nowrap;
  }
  .education-logo {
    --education-logo-width: 120px;
    --education-logo-height: 44px;
    grid-area: logo;
    margin-top: 0;
    justify-self: flex-end;
    width: var(--education-logo-width);
    height: var(--education-logo-height);
  }
  .education-logo--mobile-tall {
    --education-logo-height: 54px;
  }
  #news .section-title-row {
    flex-direction: row;
    align-items: center;
    gap: 8px;
  }
  #news .pager {
    margin-left: auto;
  }
  .mobile-nav {
    width: 160px;
    max-width: 70%;
    padding: 32px 20px;
  }
  .mobile-nav-list {
    gap: 12px;
    font-size: 16px;
  }
}

@media (prefers-reduced-motion: no-preference) {
  body,
  .mobile-nav,
  .icon-btn,
  .pager-num.is-active,
  .tab.is-active {
    transition:
      background-color 0.18s ease,
      color 0.18s ease,
      border-color 0.18s ease;
  }
}
