:root {
  --paper: #efe4d0;
  --paper-deep: #e7d7bc;
  --ink: #1b1510;
  --ink-soft: #5a4d42;
  --cinnabar: #9c3224;
  --rule: rgba(156, 50, 36, 0.55);
  --display: "EB Garamond", "Noto Serif SC", "Songti SC", serif;
  --body: "Source Serif 4", "Noto Serif SC", "Songti SC", serif;
  --zh: "Noto Serif SC", "Source Han Serif SC", "Songti SC", serif;
}

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

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(1200px 500px at 10% -10%, rgba(156, 50, 36, 0.08), transparent 50%),
    linear-gradient(180deg, var(--paper) 0%, var(--paper-deep) 100%);
  font-family: var(--body);
  font-size: 18px;
  line-height: 1.65;
}

[data-lang="zh"] body,
html[data-lang="zh"] {
  font-family: var(--zh);
}

.en,
.zh {
  display: none;
}

html[data-lang="en"] .en,
html[data-lang="zh"] .zh {
  display: inline;
}

li .en,
li .zh,
dd .en,
dd .zh,
p .en,
p .zh,
h1 .en,
h1 .zh,
h2 .en,
h2 .zh {
  display: none;
}

html[data-lang="en"] li .en,
html[data-lang="en"] dd .en,
html[data-lang="en"] p .en,
html[data-lang="en"] h1 .en,
html[data-lang="en"] h2 .en,
html[data-lang="zh"] li .zh,
html[data-lang="zh"] dd .zh,
html[data-lang="zh"] p .zh,
html[data-lang="zh"] h1 .zh,
html[data-lang="zh"] h2 .zh {
  display: inline;
}

.paper-grain {
  pointer-events: none;
  position: fixed;
  inset: 0;
  z-index: 0;
  opacity: 0.22;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)' opacity='.55'/%3E%3C/svg%3E");
}

.bind-rule {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 28px;
  width: 2px;
  background: linear-gradient(180deg, transparent, var(--cinnabar) 12%, var(--cinnabar) 88%, transparent);
  opacity: 0.7;
  z-index: 1;
}

.masthead,
.sheet,
footer {
  position: relative;
  z-index: 2;
}

.masthead {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  max-width: 760px;
  margin: 0 auto;
  padding: 28px 28px 0 64px;
}

.running {
  margin: 0;
  font-family: var(--display);
  font-size: 12px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

html[data-lang="zh"] .running {
  letter-spacing: 0.28em;
  text-transform: none;
}

.lang-switch {
  font-family: var(--display);
  font-size: 14px;
  letter-spacing: 0.12em;
}

.lang-switch button {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--ink-soft);
  cursor: pointer;
  padding: 0;
  font: inherit;
}

.lang-switch button[aria-pressed="true"] {
  color: var(--cinnabar);
}

.lang-dot {
  color: var(--ink-soft);
  padding: 0 6px;
}

.sheet {
  max-width: 760px;
  margin: 0 auto;
  padding: 48px 28px 72px 64px;
}

.hero {
  animation: rise 0.9s ease both;
}

.hero .meta {
  margin-top: 28px;
}

.kicker {
  margin: 0 0 12px;
  color: var(--cinnabar);
  font-family: var(--display);
  font-size: 13px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

html[data-lang="zh"] .kicker {
  letter-spacing: 0.22em;
  text-transform: none;
}

h1 {
  margin: 0;
  font-family: var(--display);
  font-weight: 600;
  font-size: clamp(3.4rem, 8vw, 5.6rem);
  line-height: 0.92;
  letter-spacing: -0.03em;
}

.name-zh {
  letter-spacing: 0.12em;
}

.lede {
  max-width: 36em;
  margin: 28px 0 22px;
  font-size: 1.12rem;
  color: var(--ink-soft);
}

.meta {
  margin: 0;
  padding: 0;
  list-style: none;
  color: var(--ink-soft);
  font-size: 0.98rem;
}

.meta li + li {
  margin-top: 2px;
}

.cv-line {
  margin: 22px 0 0;
}

.cv-line a,
.biblio a,
footer a,
.meta a {
  color: var(--cinnabar);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.cv-line a:hover,
.biblio a:hover,
footer a:hover,
.meta a:hover {
  text-decoration-thickness: 2px;
}

.toc {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 28px;
  margin: 56px 0 8px;
  padding: 22px 0;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  animation: rise 0.9s ease 0.12s both;
}

.toc a {
  color: inherit;
  text-decoration: none;
  font-family: var(--display);
  font-size: 1.05rem;
}

.toc a:hover {
  color: var(--cinnabar);
}

.toc .num {
  display: inline-block;
  width: 2.1em;
  color: var(--cinnabar);
  font-variant-numeric: oldstyle-nums;
  font-size: 0.86em;
}

section {
  padding-top: 48px;
  animation: rise 0.8s ease both;
}

section:nth-of-type(3) { animation-delay: 0.16s; }
section:nth-of-type(4) { animation-delay: 0.22s; }
section:nth-of-type(5) { animation-delay: 0.28s; }
section:nth-of-type(6) { animation-delay: 0.34s; }
section:nth-of-type(7) { animation-delay: 0.4s; }

h2 {
  margin: 0 0 18px;
  font-family: var(--display);
  font-size: 1.7rem;
  font-weight: 600;
}

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

.chips li {
  border: 1px solid var(--rule);
  padding: 6px 12px;
  font-size: 0.92rem;
}

.biblio {
  margin: 0;
  padding-left: 1.25em;
}

.biblio.plain {
  list-style: disc;
}

.biblio li {
  margin-bottom: 1.05em;
  padding-left: 0.4em;
}

.biblio li:last-child {
  margin-bottom: 0;
}

.badge {
  display: inline-block;
  margin-left: 0.35em;
  color: var(--ink-soft);
  font-size: 0.78rem;
  letter-spacing: 0.04em;
}

.with {
  display: block;
  color: var(--ink-soft);
  font-size: 0.95em;
}

.timeline {
  margin: 0;
}

.timeline > div {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 12px 24px;
  padding: 14px 0;
  border-top: 1px solid rgba(27, 21, 16, 0.12);
}

.timeline dt {
  margin: 0;
  font-variant-numeric: oldstyle-nums;
  color: var(--cinnabar);
  font-size: 0.92rem;
}

.timeline dd {
  margin: 0;
}

.timeline strong {
  display: block;
  font-family: var(--display);
  font-size: 1.12rem;
  font-weight: 600;
}

footer {
  max-width: 760px;
  margin: 0 auto;
  padding: 0 28px 56px 64px;
  color: var(--ink-soft);
  font-size: 0.92rem;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@media (max-width: 720px) {
  .bind-rule {
    left: 14px;
  }

  .masthead,
  .sheet,
  footer {
    padding-left: 36px;
    padding-right: 20px;
  }

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

  .timeline > div {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  h1 {
    font-size: 3.1rem;
  }
}

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

  .hero,
  .toc,
  section {
    animation: none;
  }
}
