:root {
  --bg: #f8f6f2;
  --ink: #20201e;
  --ink-soft: #4a4640;
  --muted: #8a847a;
  --faint: #b0aaa0;
  --line: #e6e0d6;
  --accent: #e07a3d;
  --accent-ink: #fffaf6;
  --highlight: #f3de8a;
  --card: #fffcf7;
  --paper: #f4ead6;
  --paper-ink: #2a2318;
  --glow: #f3ddc6;
  --serif: "Noto Serif SC", "Noto Serif CJK SC", "Source Han Serif SC", "Songti SC", "Times New Roman", serif;
  --sans: "Source Sans 3", "Noto Sans SC", "Noto Sans CJK SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  --hand: "Ma Shan Zheng", "STKaiti", "KaiTi", cursive;
  --italic: "Instrument Serif", var(--serif);
  --col: min(40rem, calc(100% - 3.2rem));
  --wide: min(46rem, calc(100% - 3.2rem));
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; background: var(--bg); }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 17px;
  line-height: 1.8;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

.skip-link {
  position: absolute; left: 0.8rem; top: -4rem;
  background: var(--ink); color: var(--bg); padding: 0.4rem 0.7rem; border-radius: 8px; z-index: 80;
}
.skip-link:focus { top: 0.8rem; }

.glow {
  position: fixed; inset: -10% 0 40%;
  pointer-events: none; z-index: 0;
  background:
    radial-gradient(ellipse 80% 60% at 50% 26%, rgba(247, 220, 190, 0.9), transparent 68%),
    radial-gradient(ellipse 45% 40% at 15% 65%, rgba(248, 210, 185, 0.4), transparent 70%),
    radial-gradient(ellipse 50% 45% at 90% 32%, rgba(250, 200, 168, 0.5), transparent 70%);
}
.grain {
  position: fixed; inset: 0; z-index: 50;
  width: 100%; height: 100%;
  pointer-events: none;
  opacity: 0.09;
  mix-blend-mode: multiply;
  image-rendering: pixelated;
}
.garden {
  position: absolute; left: 0; top: 0; width: 100%;
  min-height: 100%;
  z-index: 1;
  pointer-events: none;
  overflow: hidden;
}
.garden .bloom {
  position: absolute;
  transform-origin: 50% 60%;
  will-change: transform, filter;
  animation: sway var(--sway, 8s) ease-in-out var(--delay, 0s) infinite;
}
.garden .bloom svg { display: block; width: 100%; height: 100%; overflow: visible; }
@keyframes sway {
  0%, 100% { transform: rotate(var(--r, 0deg)) translateY(0) rotate(-5deg); }
  50% { transform: rotate(var(--r, 0deg)) translateY(-10px) rotate(6deg); }
}

.nav {
  position: relative; z-index: 10;
  display: flex; align-items: center; justify-content: center;
  gap: 1.15rem;
  width: var(--wide);
  margin: 0 auto;
  padding: 1.25rem 0 0.2rem;
  font-family: var(--sans);
}
.logo { color: var(--ink); display: flex; align-items: center; flex: 0 0 auto; }
.logo-mark { width: 28px; height: 28px; display: block; }
nav { display: flex; gap: 1.25rem; }
nav a, .mute, .text-link, .skip {
  font-family: var(--sans);
  font-size: 0.92rem;
  font-weight: 500;
  color: var(--ink-soft);
  text-decoration: none;
  letter-spacing: 0.02em;
}
nav a:hover, .text-link:hover { color: var(--ink); }
.mute {
  border: 0;
  background: none;
  cursor: pointer;
  padding: 0.2rem 0;
  color: var(--muted);
  font-size: 0.82rem;
}
.mute[aria-pressed="false"] { color: var(--ink-soft); }

main { position: relative; z-index: 5; }
.hero {
  width: var(--col);
  margin: 0 auto;
  padding: 5.2vh 0 1rem;
}
.sign-wrap {
  margin: 0 0 0.15rem;
  color: var(--ink);
  line-height: normal;
  width: min(100%, 21rem);
  display: block;
  position: relative;
  z-index: 2;
}
.signature { width: 100%; height: auto; display: block; overflow: hidden; }

.hello {
  margin: 0.35rem 0 1.5rem;
  font-family: var(--hand);
  font-size: 1.35rem;
  color: var(--muted);
  letter-spacing: 0.06em;
}

.essay p { margin: 0 0 0.95rem; color: var(--ink-soft); }
.essay p:last-child { margin-bottom: 0; }
.lead-out { color: var(--muted) !important; margin-top: 1.25rem !important; }

.mark, .tag {
  display: inline-block;
  margin-right: 0.35em;
  padding: 0.02em 0.42em 0.06em;
  border-radius: 999px;
  border: 1px solid rgba(224, 122, 61, 0.4);
  color: var(--accent);
  font-family: var(--sans);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  vertical-align: 0.12em;
  background: rgba(224, 122, 61, 0.08);
}
.tag { margin-left: 0.2em; margin-right: 0; }
.hint { display: block; margin-top: 0.25rem; color: var(--faint); font-size: 0.9rem; }

.pill {
  display: inline-block;
  padding: 0.02em 0.42em 0.08em;
  margin: 0 0.05em;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-ink);
  font-family: var(--sans);
  font-weight: 600;
  font-size: 0.92em;
  letter-spacing: 0.04em;
  text-decoration: none;
  line-height: 1.4;
  position: relative;
}
.pill.quiet {
  background: #f0d9b8;
  color: #5a3d1f;
}
a.pill:hover { filter: brightness(1.05); }
.phrase {
  font-family: var(--italic);
  font-style: italic;
  font-size: 1.12em;
  color: #c45b6a;
  letter-spacing: 0.01em;
}
.chip {
  background: var(--highlight);
  padding: 0.05em 0.28em;
  border-radius: 3px;
  color: var(--ink);
}

.peek {
  position: absolute;
  z-index: 8;
  width: 240px;
  margin-top: 0.4rem;
  margin-left: -2rem;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 18px 40px rgba(60, 40, 20, 0.18);
  transform: rotate(-4deg);
  pointer-events: none;
}
.peek img { display: block; width: 100%; height: auto; }
.essay p { position: relative; }
.pill[data-hover]:hover + .peek, .peek.show { display: block !important; }

.works, .now, .about, footer {
  width: var(--wide);
  margin: 0 auto;
}
.sec-head, .now h2, .about h2 {
  display: flex; align-items: baseline;
  margin: 0 0 0.75rem;
}
.sec-head h2, .now h2, .about h2, .project h3 {
  font-family: var(--sans);
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--ink);
}
.sec-head h2, .now h2, .about h2 {
  font-size: 1.05rem;
  margin: 0 0 0.75rem;
}

.project {
  margin: 0 0 1.35rem;
  perspective: 900px;
}
.tilt-inner {
  display: grid;
  gap: 1.2rem;
  padding: 1.25rem 1.3rem 1.35rem;
  background: var(--card);
  border: 1px solid rgba(40, 32, 20, 0.06);
  border-radius: 22px;
  box-shadow: 0 1px 0 rgba(255,255,255,0.8) inset, 0 10px 30px rgba(70, 50, 30, 0.05);
  transform-style: preserve-3d;
  transition: transform 0.35s ease, box-shadow 0.35s ease;
}
.project:hover .tilt-inner {
  box-shadow: 0 1px 0 rgba(255,255,255,0.8) inset, 0 16px 40px rgba(70, 50, 30, 0.09);
}
.project .copy { min-width: 0; }
.kicker {
  margin: 0 0 0.35rem;
  font-family: var(--sans);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  color: var(--accent);
  text-transform: uppercase;
}
.project h3 { margin: 0; font-size: 1.35rem; }
.project .copy p { margin: 0.45rem 0 0.85rem; color: var(--ink-soft); }
.muted { margin: 0 !important; color: var(--muted) !important; font-size: 0.9rem; }
.text-link { display: inline-block; color: var(--accent); font-weight: 600; }
.text-link::after { content: " →"; }

.frame {
  margin: 0;
  border-radius: 16px;
  overflow: hidden;
  background: #efe8dc;
  box-shadow: 0 8px 24px rgba(60, 40, 20, 0.08);
  transform: rotate(-0.6deg);
}
.frame img { display: block; width: 100%; height: auto; }
.frame .desk { aspect-ratio: 16/10; object-fit: cover; object-position: center 42%; }
.frame .phone { display: none; }

.cover-card .tilt-inner,
.intel .tilt-inner {
  grid-template-columns: 1fr;
  padding: 0.7rem 0.7rem 1.1rem;
}
.mat {
  margin: 0;
  border-radius: 16px;
  overflow: hidden;
  background: linear-gradient(180deg, #f8d5c2 0%, #f0b89a 100%);
  padding: 1rem 1.25rem 0;
  min-height: 15rem;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.mat img { display: block; width: 100%; height: auto; }
.mat .desk {
  aspect-ratio: 16/10;
  object-fit: cover;
  object-position: center 42%;
  border-radius: 12px 12px 0 0;
  box-shadow: 0 12px 28px rgba(80, 40, 16, 0.16);
  background: #fff;
}
.mat .phone { display: none; }
.mat.sage {
  background: linear-gradient(180deg, #efe6d4 0%, #e4d5b8 100%);
  padding: 1.6rem 1rem;
  min-height: 12rem;
  align-items: center;
}
.cover-card .copy,
.intel .copy {
  padding: 0.55rem 0.55rem 0.1rem;
}
.intel .paper {
  margin: 0 auto;
  width: min(100%, 320px);
  transform: rotate(-1.8deg);
}

.paper {
  margin: 0 auto;
  width: min(100%, 260px);
  padding: 0.85rem 0.9rem 1rem;
  background: var(--paper);
  color: var(--paper-ink);
  border-radius: 6px 10px 8px 7px;
  transform: rotate(-2.2deg);
  box-shadow: 0 14px 28px rgba(70, 50, 20, 0.1);
  font-family: var(--serif);
}
.mast { display: flex; justify-content: space-between; align-items: baseline; font-size: 0.58rem; letter-spacing: 0.12em; }
.mast b { font-size: 0.92rem; letter-spacing: 0.04em; font-family: var(--hand); }
.rule { height: 1.5px; background: var(--paper-ink); margin: 0.4rem 0 0.55rem; opacity: 0.7; }
.cols { display: grid; grid-template-columns: 1fr 0.85fr; gap: 0.5rem; }
.col i { display: block; height: 4px; background: #d3c4aa; margin: 0 0 0.32rem; border-radius: 2px; }
.col i.s { width: 62%; }
.col.note { padding: 0.28rem; background: #efe3cc; }
.col.note em { display: block; font-style: normal; font-size: 0.58rem; font-weight: 700; margin-bottom: 0.22rem; font-family: var(--sans); }

.community .tilt-inner { grid-template-columns: 1fr; }
.lines {
  list-style: none; margin: 0; padding: 0;
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.55rem;
}
.lines li {
  padding: 0.85rem 0.75rem;
  border-radius: 14px;
  background: #f5eee4;
  font-family: var(--sans);
  font-weight: 600;
  letter-spacing: 0.06em;
  transition: transform 0.25s ease, background 0.25s ease;
}
.lines li span {
  display: block; margin-bottom: 0.25rem;
  color: var(--accent);
  font-size: 0.66rem;
  letter-spacing: 0.14em;
}
.lines li:hover { background: #f0e0cc; transform: translateY(-2px); }

.now { padding: 1.2rem 0 0.4rem; }
.now ul { list-style: none; margin: 0; padding: 0; }
.now li {
  padding: 0.7rem 0;
  border-top: 1px solid var(--line);
  overflow-wrap: anywhere;
}
.now li:last-child { border-bottom: 1px solid var(--line); }

.about { padding: 2.2rem 0 1rem; }
.about-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 2rem; }
.about p { margin: 0; color: var(--ink-soft); }
.about dl { margin: 0; }
.about dl div {
  display: grid; grid-template-columns: 4.2rem 1fr; gap: 0.7rem;
  padding: 0.55rem 0; border-top: 1px solid var(--line);
}
.about dt { margin: 0; color: var(--muted); font-family: var(--sans); font-size: 0.88rem; }
.about dd { margin: 0; overflow-wrap: anywhere; }
.placeholder { color: var(--muted); }

footer {
  padding: 1.4rem 0 3rem;
  color: var(--faint);
  font-family: var(--hand);
  font-size: 1.05rem;
}
footer p { margin: 0; }

.intro-bar {
  position: fixed; z-index: 40; left: 50%; bottom: 1.4rem;
  transform: translateX(-50%);
  display: none;
}
html[data-intro="running"] .intro-bar { display: block; }
.skip {
  border: 0;
  background: rgba(32, 32, 30, 0.86);
  color: #f6f1ea;
  padding: 0.45rem 0.95rem;
  border-radius: 999px;
  cursor: pointer;
  backdrop-filter: blur(8px);
  font-size: 0.82rem;
  letter-spacing: 0.08em;
}
.skip:hover { background: #20201e; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* Intro choreography */
html[data-intro="running"] .signature .sig-ch {
  clip-path: inset(0 100% 0 0);
  animation: write 0.85s cubic-bezier(.2,.7,.2,1) forwards;
  animation-delay: calc(0.25s + var(--i) * 0.38s);
}
@keyframes write {
  to { clip-path: inset(0 0 0 0); }
}
html[data-intro="running"] .hello,
html[data-intro="running"] .essay,
html[data-intro="running"] .works,
html[data-intro="running"] .now,
html[data-intro="running"] .about,
html[data-intro="running"] footer {
  opacity: 0;
}
html[data-intro="running"] .hello {
  animation: fadeup 0.7s ease 1.5s forwards;
}
html[data-intro="running"] .essay {
  animation: fadeup 0.9s ease 1.85s forwards;
}
html[data-intro="running"] .works,
html[data-intro="running"] .now,
html[data-intro="running"] .about,
html[data-intro="running"] footer {
  filter: blur(14px);
  animation: reveal-rest 1s ease 2.6s forwards;
}
@keyframes fadeup {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}
@keyframes reveal-rest {
  from { opacity: 0; filter: blur(14px); }
  to { opacity: 1; filter: none; }
}
html[data-intro="running"] .garden .bloom {
  opacity: 0;
  animation: bloom-in 1.2s ease forwards, sway var(--sway, 8s) ease-in-out var(--delay, 0s) infinite;
  animation-delay: var(--in-delay, 0.4s), calc(var(--in-delay, 0.4s) + 1.2s);
}
@keyframes bloom-in {
  from { opacity: 0; transform: rotate(var(--r, 0deg)) scale(0.86) translateY(12px); }
  to { opacity: var(--o, 1); transform: rotate(var(--r, 0deg)) scale(1) translateY(0); }
}
html[data-intro="done"] .garden .bloom { opacity: var(--o, 1); }

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

@media (max-width: 820px) {
  :root { --col: calc(100% - 2rem); --wide: calc(100% - 2rem); }
  body { font-size: 16px; }
  .hero { padding-top: 4.5vh; }
  .sign-wrap { width: min(100%, 18.5rem); }
  .cover-card .tilt-inner,
  .intel .tilt-inner,
  .about-grid,
  .lines { grid-template-columns: 1fr; }
  .lines { grid-template-columns: 1fr 1fr; }
  .mat { min-height: 18rem; padding: 1.2rem 0 0; }
  .mat .desk { display: none; }
  .mat .phone {
    display: block;
    width: min(200px, 70%);
    margin: 0 auto;
    border-radius: 28px 28px 0 0;
    box-shadow: 0 16px 32px rgba(80, 40, 16, 0.18);
  }
  .mat.sage { min-height: 11rem; padding: 1.2rem 0.8rem; }
  .intel .paper { width: min(100%, 240px); }
  .nav { gap: 0.7rem; }
  nav { gap: 0.85rem; }
  .peek { width: 180px; margin-left: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .garden .bloom, html[data-intro="running"] .garden .bloom,
  html[data-intro="running"] .signature .sig-ch,
  html[data-intro="running"] .hello,
  html[data-intro="running"] .essay,
  html[data-intro="running"] .works,
  html[data-intro="running"] .now,
  html[data-intro="running"] .about,
  html[data-intro="running"] footer {
    animation: none !important;
    opacity: 1 !important;
    filter: none !important;
    clip-path: none !important;
    transform: none !important;
  }
  .intro-bar { display: none !important; }
  .tilt-inner { transition: none; }
  .lines li { transition: none; }
}

/* screenshot helper */
html.capture .garden .bloom { animation: none !important; opacity: var(--o, 1) !important; }
html.capture[data-intro="running"] .hello,
html.capture[data-intro="running"] .essay,
html.capture[data-intro="running"] .works,
html.capture[data-intro="running"] .now,
html.capture[data-intro="running"] .about,
html.capture[data-intro="running"] footer,
html.capture .signature .sig-ch {
  animation: none !important; opacity: 1 !important; filter: none !important; clip-path: none !important;
}
