/* ---------- Theme tokens ---------- */
:root {
  --bg: #fbfaf8;
  --surface: #ffffff;
  --text: #1d1b22;
  --text-2: #4a4655;
  --muted: #77737f;
  --line: #e9e6ee;
  --accent: #5a45c2;
  --accent-hover: #46339f;
  --accent-soft: #efebfb;
  --mark: #e6dffc;
  --badge-bg: #f0eff3;
  --badge-text: #5d5967;
  --thumb-bg: #ffffff;
  --hover: rgba(90, 69, 194, 0.045);
  --ease: cubic-bezier(0.23, 1, 0.32, 1);
  --shadow: 0 1px 2px rgba(29, 27, 34, 0.04), 0 10px 28px -14px rgba(29, 27, 34, 0.18);
  --serif: "Newsreader", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "PingFang SC", "Microsoft YaHei", sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #131218;
    --surface: #1b1a22;
    --text: #edebf3;
    --text-2: #c5c1d0;
    --muted: #9a96a7;
    --line: #2c2a36;
    --accent: #b6a9ff;
    --accent-hover: #d2c9ff;
    --accent-soft: #29244a;
    --mark: #3a3166;
    --badge-bg: #25232e;
    --badge-text: #b9b5c6;
    --thumb-bg: #f4f3f7;
    --hover: rgba(182, 169, 255, 0.06);
    --shadow: none;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #131218;
  --surface: #1b1a22;
  --text: #edebf3;
  --text-2: #c5c1d0;
  --muted: #9a96a7;
  --line: #2c2a36;
  --accent: #b6a9ff;
  --accent-hover: #d2c9ff;
  --accent-soft: #29244a;
  --mark: #3a3166;
  --badge-bg: #25232e;
  --badge-text: #b9b5c6;
  --thumb-bg: #f4f3f7;
  --hover: rgba(182, 169, 255, 0.06);
  --shadow: none;
  color-scheme: dark;
}

/* ---------- Base ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scrollbar-gutter: stable;
  scroll-behavior: smooth;
  scroll-padding-top: 28px;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16.5px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.15s ease, background-color 0.15s ease, border-color 0.15s ease;
}

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

p:not(.pub-links) a,
.section-meta a {
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-decoration-color: color-mix(in srgb, var(--accent) 35%, transparent);
  text-underline-offset: 3px;
}

p:not(.pub-links) a:hover,
.section-meta a:hover {
  text-decoration-color: currentColor;
}

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

::selection {
  background: var(--mark);
}

.icon {
  width: 16px;
  height: 16px;
  flex: none;
}

.skip-link {
  position: absolute;
  left: 16px;
  top: -48px;
  padding: 8px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  z-index: 10;
}

.skip-link:focus {
  top: 16px;
}

/* ---------- Layout ---------- */
.page {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 40px;
  display: grid;
  grid-template-columns: 272px minmax(0, 1fr);
  gap: 80px;
}

.profile-inner {
  position: sticky;
  top: 0;
  padding: 76px 0 40px;
}

.content {
  padding: 76px 0 0;
  max-width: 720px;
  min-width: 0;
}

/* ---------- Profile sidebar ---------- */
.avatar {
  display: block;
  width: 168px;
  height: 168px;
  border-radius: 50%;
  object-fit: cover;
  object-position: 50% 30%;
  background: var(--accent-soft);
  box-shadow: 0 0 0 5px var(--surface), 0 0 0 6px var(--line), var(--shadow);
  transition: transform 0.45s var(--ease);
}

.avatar:hover {
  transform: rotate(-6deg) scale(1.03);
}

.name {
  margin: 30px 0 4px;
  font-family: var(--serif);
  font-size: 42px;
  font-weight: 500;
  line-height: 1.05;
  letter-spacing: -0.02em;
}

.role {
  margin: 0 0 18px;
  color: var(--text-2);
  font-size: 15px;
  line-height: 1.5;
}

.facts,
.links {
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 14.5px;
}

.facts li,
.links a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 3px 0;
}

.facts {
  color: var(--muted);
  margin-bottom: 18px;
}

.facts a {
  color: inherit;
}

.facts a:hover,
.links a:hover {
  color: var(--accent);
}

.links {
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.links a {
  color: var(--text);
}

.links .icon {
  color: var(--muted);
  transition: color 0.15s ease;
}

.links a:hover .icon {
  color: var(--accent);
}

.email-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.copy {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 26px;
  height: 26px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: copy;
  transition: color 0.15s ease, background-color 0.15s ease;
}

.copy:hover {
  color: var(--accent);
  background: var(--accent-soft);
}

.copy .icon {
  width: 14px;
  height: 14px;
}

.copy::after {
  content: attr(data-label);
  position: absolute;
  left: calc(100% + 6px);
  top: 50%;
  padding: 2px 8px;
  border-radius: 6px;
  background: var(--text);
  color: var(--bg);
  font-size: 12px;
  line-height: 1.5;
  white-space: nowrap;
  opacity: 0;
  transform: translate(-4px, -50%);
  transition: opacity 0.2s var(--ease), transform 0.2s var(--ease);
  pointer-events: none;
}

.copy:hover::after,
.copy.copied::after {
  opacity: 1;
  transform: translate(0, -50%);
}

.toc {
  display: flex;
  flex-direction: column;
  margin-top: 22px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  font-size: 14px;
}

.toc a {
  position: relative;
  padding: 3px 0 3px 14px;
  color: var(--muted);
}

.toc a::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  width: 5px;
  height: 5px;
  margin-top: -2.5px;
  border-radius: 50%;
  background: var(--line);
  transition: background-color 0.15s ease, transform 0.15s ease;
}

.toc a:hover,
.toc a[aria-current="true"] {
  color: var(--text);
}

.toc a[aria-current="true"]::before {
  background: var(--accent);
  transform: scale(1.3);
}

.theme-toggle {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  margin-top: 22px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease;
}

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

.theme-toggle .icon {
  grid-area: 1 / 1;
}

.icon-sun {
  display: none;
}

:root[data-theme="dark"] .icon-sun {
  display: block;
}

:root[data-theme="dark"] .icon-moon {
  display: none;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .icon-sun {
    display: block;
  }
  :root:not([data-theme="light"]) .icon-moon {
    display: none;
  }
}

/* ---------- Sections ---------- */
.content {
  counter-reset: section;
}

.section {
  margin-bottom: 76px;
  counter-increment: section;
}

.section-heading::before {
  content: counter(section, decimal-leading-zero);
  display: block;
  margin-bottom: 8px;
  color: var(--accent);
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.14em;
  line-height: 1;
}

.section-heading {
  text-wrap: balance;
  margin: 0 0 22px;
  font-family: var(--serif);
  font-size: 30px;
  font-weight: 500;
  line-height: 1.2;
  letter-spacing: -0.015em;
}

.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 8px;
}

.section-head .section-heading {
  margin-bottom: 0;
}

.section-meta {
  display: flex;
  gap: 18px;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

#about p {
  margin: 0 0 16px;
  max-width: 66ch;
  text-wrap: pretty;
}

#about .lead {
  margin-bottom: 20px;
  font-family: var(--serif);
  font-size: 23px;
  line-height: 1.4;
  letter-spacing: -0.01em;
  color: var(--text);
  text-wrap: balance;
}

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

.tags li {
  padding: 4px 12px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.5;
}

/* ---------- Publications ---------- */
.pubs {
  list-style: none;
  margin: 0;
  padding: 0;
}

.pub {
  position: relative;
  display: grid;
  grid-template-columns: 168px minmax(0, 1fr);
  gap: 22px;
  margin: 0 -18px;
  padding: 24px 18px;
  border-radius: 16px;
  transition: background-color 0.25s var(--ease);
}

.pub + .pub::before {
  content: "";
  position: absolute;
  top: 0;
  left: 18px;
  right: 18px;
  border-top: 1px solid var(--line);
}

.pub:hover {
  background: var(--hover);
}

.pub-thumb {
  display: block;
  align-self: start;
  aspect-ratio: 19 / 10;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--thumb-bg);
  overflow: hidden;
  transition: border-color 0.25s var(--ease), transform 0.25s var(--ease);
}

.pub-thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.pub:hover .pub-thumb {
  border-color: color-mix(in srgb, var(--accent) 40%, var(--line));
  transform: translateY(-1px);
}

.pub-body {
  min-width: 0;
}

.pub.no-thumb .pub-body {
  grid-column: 2;
}

.pub-body p {
  margin: 0;
}

.pub-venue {
  margin-bottom: 7px !important;
  line-height: 1;
}

.badge {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 6px;
  background: var(--badge-bg);
  color: var(--badge-text);
  font-size: 11.5px;
  font-weight: 650;
  letter-spacing: 0.04em;
  line-height: 1.2;
}

.badge-conf {
  background: var(--accent-soft);
  color: var(--accent);
}

.pub-title {
  margin: 0 0 6px;
  font-family: var(--serif);
  font-size: 20px;
  font-weight: 500;
  line-height: 1.3;
  letter-spacing: -0.005em;
  text-wrap: pretty;
}

.pub-title a {
  color: var(--text);
}

.pub-title a:hover {
  color: var(--accent);
}

.pub-authors {
  color: var(--text-2);
  font-size: 14.5px;
  line-height: 1.6;
}

.me {
  color: var(--text);
  font-weight: 650;
  background: linear-gradient(transparent 60%, var(--mark) 60%);
  border-radius: 2px;
}

.pub-where {
  margin-top: 2px !important;
  color: var(--muted);
  font-size: 14px;
  font-style: italic;
  line-height: 1.55;
}

.pub-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px !important;
}

.pub-links a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 11px 3px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-2);
  font-size: 12.5px;
  font-weight: 550;
  line-height: 1.6;
}

.pub-links .icon {
  width: 13px;
  height: 13px;
}

.pub-links a:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

/* ---------- Visitor statistics (rendered off-screen, never shown) ---------- */
.visitor-tracker {
  position: absolute;
  left: -10000px;
  top: 0;
  width: 320px;
  height: 200px;
  overflow: hidden;
}

/* ---------- Footer ---------- */
.footer {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 26px 0 48px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
}

/* ---------- Responsive ---------- */
@media (max-width: 960px) {
  .page {
    grid-template-columns: 232px minmax(0, 1fr);
    gap: 48px;
    padding: 0 28px;
  }
  .avatar {
    width: 148px;
    height: 148px;
  }
  .pub {
    grid-template-columns: 140px minmax(0, 1fr);
    gap: 18px;
  }
}

@media (max-width: 760px) {
  body {
    font-size: 16px;
  }
  .page {
    display: block;
    padding: 0 20px;
  }
  .profile-inner {
    position: relative;
    display: grid;
    grid-template-columns: 96px minmax(0, 1fr);
    gap: 4px 18px;
    align-items: center;
    padding: 36px 0 8px;
  }
  .avatar {
    grid-row: 1 / 3;
    width: 96px;
    height: 96px;
    box-shadow: 0 0 0 4px var(--surface), 0 0 0 5px var(--line);
  }
  .name {
    margin: 0;
    font-size: 34px;
    align-self: end;
  }
  .role {
    margin: 0;
    align-self: start;
    font-size: 14px;
  }
  .facts {
    grid-column: 1 / -1;
    display: flex;
    flex-wrap: wrap;
    gap: 0 18px;
    margin: 16px 0 0;
  }
  .links {
    grid-column: 1 / -1;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 14px;
    padding-top: 14px;
  }
  .links a {
    padding: 5px 12px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--surface);
    font-size: 13.5px;
    gap: 7px;
  }
  .links .icon {
    width: 14px;
    height: 14px;
  }
  .toc {
    display: none;
  }
  .theme-toggle {
    position: absolute;
    top: 30px;
    right: 0;
    margin: 0;
  }
  .content {
    padding-top: 36px;
  }
  .section {
    margin-bottom: 56px;
  }
  .section-heading {
    font-size: 27px;
  }
  #about .lead {
    font-size: 21px;
  }
  .section-head {
    flex-wrap: wrap;
  }
  .pub {
    grid-template-columns: minmax(0, 1fr);
    gap: 14px;
    margin: 0;
    padding: 24px 0;
    border-radius: 0;
  }
  .pub:hover {
    background: none;
  }
  .pub + .pub::before {
    left: 0;
    right: 0;
  }
  .pub-title {
    font-size: 19px;
  }
  .email-row {
    display: contents;
  }
  .copy {
    display: none;
  }
  .pub-thumb {
    width: 200px;
  }
  .pub.no-thumb .pub-body {
    grid-column: auto;
  }
  .footer {
    flex-direction: column;
    gap: 2px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  *,
  *::before,
  *::after {
    transition: none !important;
  }
  .pub:hover .pub-thumb,
  .avatar:hover {
    transform: none;
  }
}
