:root {
  --bg: #fbfbfa;
  --ink: #161616;
  --muted: #686868;
  --soft: #a2a2a2;
  --line: #e4e2de;
  --accent: #8e1f1f;
  --panel: #ffffff;
  --font-sans: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", Arial, sans-serif;
  --font-serif: Georgia, "Times New Roman", "Songti SC", "SimSun", serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  position: relative;
  isolation: isolate;
  margin: 0;
  min-height: 100vh;
  min-height: 100svh;
  overflow-x: hidden;
  color: var(--ink);
  background: var(--bg);
  font-family: var(--font-sans);
  letter-spacing: 0;
}

body::before {
  position: fixed;
  z-index: 1;
  inset: 0;
  background: radial-gradient(rgba(22, 22, 22, 0.026) 0.5px, transparent 0.72px) 0 0 / 4px 4px;
  backdrop-filter: blur(12px) saturate(0.95) brightness(1.04);
  -webkit-backdrop-filter: blur(12px) saturate(0.95) brightness(1.04);
  content: "";
  pointer-events: none;
}

body::after {
  position: fixed;
  z-index: 0;
  inset: -3%;
  background-image: url("./assets/site-background.jpg?v=20260802-scrollbar");
  background-position: 50% 50%;
  background-repeat: no-repeat;
  background-size: cover;
  content: "";
  filter: saturate(0.86) brightness(1.08) contrast(0.9);
  opacity: 0.46;
  pointer-events: none;
}

body[data-language="cn"] [data-i18n-lang="en"],
body[data-language="en"] [data-i18n-lang="cn"] {
  display: none;
}

body[data-language="en"] [data-i18n-lang="en"] {
  font-family: "Times New Roman", Times, serif;
}

a {
  color: inherit;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
}

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

.language-toggle {
  position: fixed;
  top: 24px;
  right: 28px;
  z-index: 10;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 34px;
  padding: 7px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--soft);
  background: rgba(251, 251, 250, 0.86);
  box-shadow: 0 10px 28px rgba(22, 22, 22, 0.08);
  font-size: 12px;
  font-weight: 850;
  line-height: 1;
  cursor: pointer;
  backdrop-filter: blur(14px);
}

.language-toggle:hover,
.language-toggle:focus-visible {
  color: var(--accent);
}

.scrollbar-control {
  display: none;
}

body[data-language="cn"] .language-toggle [data-toggle-lang="cn"],
body[data-language="en"] .language-toggle [data-toggle-lang="en"] {
  color: var(--ink);
}

.site-frame {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: 280px minmax(0, 720px);
  gap: 74px;
  width: min(1120px, calc(100% - 48px));
  margin: 0 auto;
  padding: 56px 0 42px;
}

.sidebar {
  position: sticky;
  top: 44px;
  align-self: start;
  min-height: calc(100vh - 88px);
  display: flex;
  flex-direction: column;
  gap: 34px;
  padding-right: 30px;
  border-right: 1px solid var(--line);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  width: fit-content;
  color: var(--ink);
  font-size: 15px;
  font-weight: 850;
  text-decoration: none;
}

.brand img {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  object-fit: cover;
  box-shadow: 0 10px 28px rgba(22, 22, 22, 0.08);
}

.profile {
  display: grid;
  gap: 0;
}

.portrait-wrap {
  width: 132px;
  height: 132px;
  margin-bottom: 24px;
  border-radius: 50%;
  background: var(--panel);
  box-shadow: 0 22px 56px rgba(22, 22, 22, 0.1);
}

.portrait {
  display: block;
  width: 132px;
  height: 132px;
  border: 3px solid rgba(255, 255, 255, 0.95);
  border-radius: 50%;
  object-fit: cover;
  object-position: 50% 35%;
}

.eyebrow,
.section-kicker {
  margin: 0 0 8px;
  color: var(--soft);
  font-size: 12px;
  font-weight: 850;
  line-height: 1.35;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 4px;
  font-size: 42px;
  line-height: 1;
  font-weight: 900;
}

.english-name {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 22px;
  line-height: 1.18;
  font-weight: 780;
}

.role {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 16px;
  font-weight: 720;
}

.side-nav {
  display: grid;
  gap: 12px;
  width: fit-content;
}

.side-nav a {
  color: var(--muted);
  font-size: 15px;
  font-weight: 760;
  text-decoration: none;
}

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

.mini-contact {
  display: grid;
  gap: 8px;
  margin-top: auto;
  color: var(--soft);
  font-size: 13px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.mini-contact a {
  color: var(--ink);
  font-weight: 760;
}

.content {
  min-width: 0;
  padding-top: 82px;
}

.intro {
  padding-bottom: 68px;
}

.intro-copy {
  max-width: 650px;
  color: var(--muted);
  font-size: 21px;
  font-weight: 690;
  line-height: 1.62;
}

.intro-copy .latin {
  font-family: "Times New Roman", Times, serif;
  font-weight: 700;
}

.intro-copy h2 {
  margin-bottom: 22px;
  color: var(--ink);
  font-size: 34px;
  line-height: 1.1;
  font-weight: 880;
}

.intro-copy p {
  margin-bottom: 18px;
}

.intro-copy .name-line {
  color: var(--ink);
  font-size: 24px;
  font-weight: 720;
}

.section-block {
  scroll-margin-top: 24px;
  padding: 44px 0;
  border-top: 1px solid var(--line);
}

.section-head {
  display: grid;
  grid-template-columns: 116px minmax(0, 1fr);
  gap: 24px;
  align-items: baseline;
  margin-bottom: 8px;
}

.section-head h2 {
  margin-bottom: 0;
  font-family: var(--font-serif);
  font-size: 27px;
  line-height: 1.2;
  font-weight: 700;
}

.section-title-button {
  display: inline;
  padding: 0;
  border: 0;
  color: inherit;
  background: transparent;
  font: inherit;
  cursor: pointer;
}

.section-kicker-button {
  display: inline-block;
  padding: 0;
  border: 0;
  background: transparent;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
}

.section-kicker-button:hover,
.section-kicker-button:focus-visible,
.section-title-button:hover,
.section-title-button:focus-visible {
  color: var(--accent);
}

.link-list,
.text-list {
  display: grid;
}

.collapsible-section.is-collapsed .collapsible-body {
  display: none;
}

.details-hint {
  position: relative;
  z-index: 1;
  margin: 0 0 10px;
  color: var(--soft);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.06em;
}

.link-row {
  display: grid;
  grid-template-columns: minmax(180px, 0.55fr) minmax(220px, 1fr);
  gap: 22px;
  align-items: center;
  min-height: 58px;
  padding: 13px 0;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  text-decoration: none;
}

.link-row b {
  font-size: 22px;
  line-height: 1.2;
}

.link-row span:last-child {
  justify-self: end;
  color: var(--soft);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 14px;
  font-weight: 760;
  overflow-wrap: anywhere;
  text-align: right;
}

.link-row:hover b,
.link-row:hover span:last-child {
  color: var(--accent);
}

.link-row.pending {
  cursor: default;
}

.link-row.pending:hover b {
  color: var(--ink);
}

.link-row.pending:hover span:last-child {
  color: var(--soft);
}

.text-row {
  display: grid;
  grid-template-columns: minmax(190px, 0.55fr) minmax(0, 1fr);
  gap: 24px;
  padding: 22px 0;
  border-bottom: 1px solid var(--line);
}

.text-row h3 {
  margin-bottom: 0;
  font-size: 19px;
  line-height: 1.42;
  font-weight: 850;
}

.text-row p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.72;
}

.text-row time {
  color: var(--accent);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 13px;
  font-weight: 850;
}

.project-link {
  display: inline-block;
  margin-top: 10px;
  color: var(--soft);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
  font-weight: 760;
  line-height: 1.5;
  overflow-wrap: anywhere;
  text-decoration: none;
}

.project-link:hover,
.project-link:focus-visible {
  color: var(--accent);
}

.project-meta-list {
  display: grid;
  gap: 6px;
  margin-top: 10px;
  color: var(--soft);
  font-size: 13px;
  font-weight: 760;
  line-height: 1.5;
}

.project-description {
  display: grid;
  gap: 12px;
}

.project-description p {
  margin: 0;
}

.education-row,
.experience-row {
  grid-template-columns: 116px minmax(0, 1fr);
  gap: 28px;
}

.experience-row {
  grid-template-columns: 144px minmax(0, 1fr);
}

.experience-row time {
  white-space: nowrap;
}

.education-row h3,
.experience-row h3 {
  margin-bottom: 12px;
}

.education-row p,
.experience-row p {
  max-width: 620px;
  font-size: 15px;
  line-height: 1.86;
}

.education-extra {
  display: grid;
  gap: 4px;
  margin-top: 18px;
  max-width: 620px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.76;
}

.education-extra p {
  margin-bottom: 4px;
  font-size: inherit;
  line-height: inherit;
}

.education-extra b {
  color: var(--ink);
  font-weight: 850;
}

.certificate-list {
  display: grid;
  gap: 8px;
  padding-top: 10px;
}

.certificate-list p {
  display: block;
  margin: 0;
  color: var(--ink);
  font-size: 16px;
  font-weight: 400;
  line-height: 1.72;
}

.site-footer {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  padding-top: 34px;
  border-top: 1px solid var(--line);
  color: var(--soft);
  font-size: 14px;
  font-weight: 720;
}

.site-footer a {
  text-decoration: none;
}

@media (max-width: 860px) {
  body::after {
    inset: -4%;
    background-position: 50% 50%;
  }

  body::before {
    backdrop-filter: blur(10px) saturate(0.95) brightness(1.05);
    -webkit-backdrop-filter: blur(10px) saturate(0.95) brightness(1.05);
  }

  .language-toggle {
    top: calc(14px + env(safe-area-inset-top));
    right: max(16px, env(safe-area-inset-right));
  }

  .scrollbar-control {
    position: fixed;
    z-index: 12;
    top: calc(72px + env(safe-area-inset-top));
    right: max(2px, env(safe-area-inset-right));
    bottom: calc(16px + env(safe-area-inset-bottom));
    display: block;
    width: 18px;
    padding: 0 5px;
    border: 0;
    border-radius: 999px;
    background: transparent;
    cursor: grab;
    touch-action: none;
    user-select: none;
  }

  .scrollbar-control::before {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 7px;
    width: 4px;
    border-radius: 999px;
    background: rgba(22, 22, 22, 0.12);
    content: "";
  }

  .scrollbar-thumb {
    position: absolute;
    top: 0;
    left: 5px;
    width: 8px;
    min-height: 52px;
    border-radius: 999px;
    background: rgba(142, 31, 31, 0.66);
    box-shadow: 0 2px 10px rgba(22, 22, 22, 0.16);
    transition: background 160ms ease;
  }

  .scrollbar-control:hover .scrollbar-thumb,
  .scrollbar-control:focus-visible .scrollbar-thumb,
  .scrollbar-control.is-dragging .scrollbar-thumb {
    background: var(--accent);
  }

  .scrollbar-control.is-dragging {
    cursor: grabbing;
  }

  .site-frame {
    grid-template-columns: 1fr;
    gap: 0;
    width: min(100%, 720px);
    margin: 0 auto;
    padding:
      calc(20px + env(safe-area-inset-top))
      max(18px, env(safe-area-inset-right))
      calc(34px + env(safe-area-inset-bottom))
      max(18px, env(safe-area-inset-left));
  }

  .sidebar {
    position: static;
    min-height: auto;
    gap: 22px;
    padding: 0 0 30px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .brand {
    margin-bottom: 2px;
  }

  .profile {
    display: grid;
    grid-template-columns: 108px minmax(0, 1fr);
    column-gap: 20px;
    align-items: start;
  }

  .profile > :not(.portrait-wrap) {
    grid-column: 2;
  }

  .profile .portrait-wrap {
    grid-row: 1 / span 4;
    grid-column: 1;
    margin-bottom: 0;
  }

  .portrait-wrap,
  .portrait {
    width: 108px;
    height: 108px;
  }

  h1 {
    font-size: clamp(32px, 8vw, 38px);
  }

  .english-name {
    font-size: clamp(18px, 4.8vw, 21px);
  }

  .role {
    font-size: 15px;
    line-height: 1.42;
  }

  .side-nav {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 4px 10px;
    width: 100%;
  }

  .side-nav a {
    display: flex;
    align-items: center;
    min-height: 44px;
    font-size: 14px;
  }

  .mini-contact {
    margin-top: 0;
    font-size: 12px;
  }

  .content {
    padding-top: clamp(30px, 8vw, 44px);
  }

  .intro {
    padding-bottom: clamp(40px, 10vw, 54px);
  }

  .intro-copy h2 {
    margin-bottom: 18px;
    font-size: clamp(28px, 7vw, 32px);
  }

  .intro-copy p {
    margin-bottom: 14px;
  }

  .intro-copy {
    font-size: clamp(17px, 4.4vw, 19px);
    line-height: 1.68;
  }

  .intro-copy .name-line {
    font-size: clamp(20px, 5.2vw, 23px);
  }

  .section-block {
    scroll-margin-top: calc(64px + env(safe-area-inset-top));
    padding: clamp(30px, 8vw, 40px) 0;
  }

  .section-head {
    grid-template-columns: minmax(78px, 0.34fr) minmax(0, 1fr);
    gap: 16px;
    align-items: center;
    margin-bottom: 10px;
  }

  .section-head h2 {
    font-size: clamp(25px, 7vw, 29px);
  }

  .section-kicker {
    margin-bottom: 0;
    font-size: 11px;
  }

  .section-title-button,
  .section-kicker-button {
    min-height: 44px;
  }

  .section-title-button {
    display: inline-flex;
    align-items: center;
    text-align: left;
  }

  .section-kicker-button {
    display: flex;
    align-items: center;
    width: 100%;
  }

  .details-hint {
    margin-bottom: 6px;
    font-size: 11px;
  }

  .link-row,
  .text-row {
    grid-template-columns: 1fr;
  }

  .link-row {
    gap: 5px;
    min-height: 64px;
    padding: 12px 0;
  }

  .link-row span:last-child {
    justify-self: start;
    max-width: 100%;
    text-align: left;
  }

  .text-row {
    gap: 9px;
    padding: 20px 0;
  }

  .text-row h3 {
    font-size: 18px;
  }

  .text-row p,
  .education-row p,
  .experience-row p {
    max-width: 100%;
    font-size: 15px;
    line-height: 1.78;
  }

  .education-extra {
    max-width: 100%;
    font-size: 13.5px;
  }

  .project-link,
  .project-meta-list {
    overflow-wrap: anywhere;
  }

  .certificate-list {
    gap: 10px;
  }

  .site-footer {
    flex-direction: column;
    padding-top: 28px;
    font-size: 13px;
  }
}

@media (max-width: 520px) {
  .site-frame {
    padding-right: max(15px, env(safe-area-inset-right));
    padding-left: max(15px, env(safe-area-inset-left));
  }

  .profile {
    grid-template-columns: 88px minmax(0, 1fr);
    column-gap: 16px;
  }

  .portrait-wrap,
  .portrait {
    width: 88px;
    height: 88px;
  }

  .profile .eyebrow {
    margin-bottom: 5px;
  }

  .side-nav {
    gap: 2px 8px;
  }

  .section-head {
    grid-template-columns: 78px minmax(0, 1fr);
    gap: 12px;
  }

  .section-head h2 {
    font-size: clamp(24px, 7.2vw, 28px);
  }

  .link-row b {
    font-size: 20px;
  }

  .link-row span:last-child {
    font-size: 12px;
  }

  .site-footer {
    gap: 12px;
  }
}

@media (max-width: 360px) {
  .profile {
    grid-template-columns: 78px minmax(0, 1fr);
    column-gap: 14px;
  }

  .portrait-wrap,
  .portrait {
    width: 78px;
    height: 78px;
  }

  .side-nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .section-head {
    grid-template-columns: 70px minmax(0, 1fr);
    gap: 10px;
  }

  .section-kicker {
    font-size: 10px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}
