@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
  --paper: #fdfbf7;
  --paper-2: #f5f5f5;
  --ink: #1a1a1a;
  --line: #e0e0e0;
  --mute: #6b6b6b;
  --faint: #9a9a9a;
  --radius: 10px;
  --sans: Inter, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  --serif: "Songti SC", "Noto Serif SC", "Source Han Serif SC", "Iowan Old Style", Georgia, "Times New Roman", serif;
}

* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.7;
  font-weight: 400;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

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

img { max-width: 100%; height: auto; }

a { color: var(--ink); }

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 14px 6px 16px;
  background: rgba(253, 251, 247, 0.96);
  border-bottom: 1px solid var(--line);
}

.mark {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: 1px solid var(--ink);
  border-radius: 6px;
  text-decoration: none;
  color: var(--ink);
  background: var(--paper);
}

.mark-img { display: block; width: 28px; height: 28px; object-fit: contain; }
.mark-txt { font-weight: 700; font-size: 1rem; letter-spacing: -0.02em; }
.mark:hover { background: var(--ink); color: var(--paper); }

.topnav {
  flex: 1 1 auto;
  min-width: 0;
  max-width: 100%;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.topnav::-webkit-scrollbar { display: none; }

.menu {
  display: flex;
  gap: 2px;
  margin: 0;
  padding: 0;
  list-style: none;
  width: max-content;
}

.menu a {
  display: flex;
  align-items: center;
  min-height: 40px;
  padding: 8px 10px;
  font-size: 0.86rem;
  letter-spacing: -0.01em;
  color: #3a3a3a;
  text-decoration: none;
  white-space: nowrap;
  border-bottom: 2px solid transparent;
  transition: color 0.15s linear, border-color 0.15s linear;
}

.menu li:nth-child(3) {
  margin-right: 6px;
  padding-right: 6px;
  border-right: 1px solid var(--line);
}

.menu a:hover,
.menu a:focus-visible {
  color: var(--ink);
  border-bottom-color: var(--ink);
  outline: none;
}

/* ---------- 栅格 ---------- */
.shell {
  display: grid;
  grid-template-columns: 214px minmax(0, 1fr);
  align-items: stretch;
  border-bottom: 1px solid var(--line);
}

.rail {
  min-width: 0;
  border-right: 1px solid var(--line);
  padding: 30px 14px 40px 20px;
}

.rail nav {
  position: sticky;
  top: 74px;
  max-width: 100%;
}

.toc {
  counter-reset: t;
  margin: 0;
  padding: 0;
  list-style: none;
}

.toc li { counter-increment: t; }

.toc a {
  display: flex;
  gap: 9px;
  align-items: baseline;
  min-height: 40px;
  padding: 9px 0;
  font-size: 0.84rem;
  line-height: 1.35;
  color: var(--mute);
  text-decoration: none;
  border-bottom: 1px solid transparent;
}

.toc a::before {
  content: counter(t, decimal-leading-zero);
  flex: none;
  font-size: 0.66rem;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.08em;
  color: var(--faint);
}

.toc a:hover,
.toc a.is-live {
  color: var(--ink);
  border-bottom-color: var(--line);
}

.toc a.is-live::before { color: var(--ink); }

main { min-width: 0; }

/* ---------- Hero ---------- */
.hero {
  position: relative;
  min-height: 100vh;
  min-height: 100svh;
  display: grid;
  grid-template-rows: auto 1fr;
  max-width: 100%;
  overflow: hidden;
  border-bottom: 1px solid var(--line);
}

.hero-copy {
  position: relative;
  z-index: 2;
  padding: clamp(30px, 8vw, 76px) clamp(20px, 5vw, 56px) clamp(14px, 3vw, 30px);
}

.hero h1 {
  margin: 0;
  max-width: 11em;
  font-size: clamp(2rem, 6.6vw, 4.3rem);
  line-height: 1.06;
  letter-spacing: -0.04em;
  font-weight: 700;
  overflow-wrap: break-word;
}

.hero-art {
  position: relative;
  margin: 0;
  overflow: hidden;
  background: var(--paper-2);
  clip-path: polygon(0 7%, 100% 0, 100% 100%, 0 100%);
  border-top: 1px solid var(--line);
}

.hero-img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: grayscale(0.14) contrast(1.04);
}

.ghost {
  position: absolute;
  top: clamp(2px, 1.4vw, 18px);
  right: clamp(4px, 2vw, 26px);
  z-index: 1;
  max-width: 100%;
  font-size: clamp(3.4rem, 15vw, 10.5rem);
  line-height: 0.84;
  font-weight: 700;
  letter-spacing: -0.06em;
  color: rgba(26, 26, 26, 0.07);
  pointer-events: none;
  user-select: none;
}

/* ---------- 引言段 ---------- */
.brief {
  padding: clamp(30px, 6vw, 74px) clamp(20px, 5vw, 56px);
  border-bottom: 1px solid var(--line);
  background: var(--paper-2);
}

.brief h2 {
  margin: 0 0 12px;
  font-size: clamp(1.35rem, 3.4vw, 2rem);
  line-height: 1.2;
  letter-spacing: -0.03em;
  font-weight: 700;
}

.subtitle {
  margin: 0;
  max-width: 58ch;
  font-family: var(--serif);
  font-size: 1rem;
  line-height: 1.8;
  color: #4a4a4a;
}

/* ---------- 正文 ---------- */
.prose {
  max-width: 76ch;
  padding: clamp(30px, 6vw, 70px) clamp(20px, 5vw, 56px) clamp(40px, 7vw, 84px);
  font-family: var(--serif);
  font-size: 1.02rem;
  line-height: 1.85;
  overflow-wrap: break-word;
  word-break: break-word;
}

.prose [id] { scroll-margin-top: 92px; }

.prose article + article {
  margin-top: clamp(36px, 6vw, 72px);
  padding-top: clamp(24px, 4vw, 44px);
  border-top: 1px solid var(--line);
}

.prose h2 {
  margin: 0 0 14px;
  font-family: var(--sans);
  font-size: clamp(1.3rem, 3.2vw, 1.85rem);
  line-height: 1.3;
  letter-spacing: -0.03em;
  font-weight: 700;
}

.prose h3 {
  margin: 30px 0 10px;
  font-family: var(--sans);
  font-size: 1.1rem;
  line-height: 1.4;
  letter-spacing: -0.02em;
}

.prose h4 {
  margin: 24px 0 8px;
  font-family: var(--sans);
  font-size: 1rem;
}

.prose p { margin: 0 0 16px; }
.prose p:last-child { margin-bottom: 0; }

.prose a {
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.prose ul,
.prose ol { margin: 0 0 18px; padding-left: 1.25em; }
.prose li { margin: 6px 0; }

.prose figure {
  margin: 26px 0;
  max-width: 100%;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper-2);
  box-shadow: 0 14px 26px -22px rgba(0, 0, 0, 0.55);
  transition: transform 0.16s ease-out, box-shadow 0.16s ease-out;
}

.prose figure img { display: block; width: 100%; height: auto; }

.prose figcaption {
  padding: 10px 14px;
  font-family: var(--sans);
  font-size: 0.8rem;
  color: var(--mute);
  border-top: 1px solid var(--line);
}

.prose blockquote {
  margin: 24px 0;
  padding: 2px 0 2px 18px;
  border-left: 3px solid var(--ink);
  color: #383838;
}

.prose table {
  display: block;
  max-width: 100%;
  overflow-x: auto;
  margin: 24px 0;
  border-collapse: collapse;
  font-family: var(--sans);
  font-size: 0.92rem;
}

.prose th,
.prose td {
  border: 1px solid var(--line);
  padding: 10px 12px;
  text-align: left;
  vertical-align: top;
}

.prose th { background: var(--paper-2); font-weight: 600; }

.prose pre {
  max-width: 100%;
  overflow-x: auto;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper-2);
  font-size: 0.86rem;
  line-height: 1.6;
}

.prose hr {
  margin: 30px 0;
  border: 0;
  border-top: 1px solid var(--line);
}

/* ---------- 页脚 ---------- */
footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 22px;
  padding: 22px clamp(20px, 5vw, 56px);
  font-size: 0.84rem;
  color: var(--mute);
  background: var(--paper);
}

footer p { margin: 0; }

footer a {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  color: var(--ink);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.15s linear;
}

footer a:hover { border-bottom-color: var(--ink); }

footer small { color: var(--faint); }

/* ---------- 动效 ---------- */
.js .reveal { opacity: 0; transform: translateY(10px); }
.js .reveal.in {
  opacity: 1;
  transform: none;
  transition: opacity 0.18s linear, transform 0.18s ease-out;
}

@media (hover: hover) {
  .prose figure:hover {
    transform: translateY(-3px);
    box-shadow: 0 20px 30px -22px rgba(0, 0, 0, 0.6);
  }
}

/* ---------- 移动端 ---------- */
@media (max-width: 860px) {
  .shell {
    grid-template-columns: minmax(0, 1fr);
  }

  .rail {
    min-width: 0;
    max-width: 100%;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 0 10px;
    background: var(--paper-2);
    overflow: hidden;
  }

  .rail nav {
    position: static;
    max-width: 100%;
    padding: 6px 0;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

  .rail nav::-webkit-scrollbar { display: none; }

  .toc {
    display: flex;
    gap: 6px;
    width: max-content;
  }

  .toc a {
    align-items: center;
    min-height: 44px;
    padding: 8px 12px;
    white-space: nowrap;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--paper);
    font-size: 0.78rem;
    color: #3a3a3a;
  }

  .toc a:hover,
  .toc a.is-live { border-color: var(--ink); }

  .hero { min-height: 0; }
  .hero-copy { padding-top: 30px; }
  .hero-art { min-height: 46vh; }
  .ghost { font-size: 15vw; }

  .prose { font-size: 1rem; max-width: 100%; }
  .prose [id] { scroll-margin-top: 110px; }

  footer { justify-content: flex-start; }
  footer small { flex: 1 0 100%; }
}

@media (max-width: 400px) {
  .topbar { padding-left: 12px; padding-right: 8px; gap: 8px; }
  .menu a { padding: 8px 8px; }
  .prose { padding-left: 18px; padding-right: 18px; }
  .hero-copy { padding-left: 18px; padding-right: 18px; }
  .brief { padding-left: 18px; padding-right: 18px; }
  footer { padding-left: 18px; padding-right: 18px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .js .reveal { opacity: 1; transform: none; }
  * { transition: none !important; }
}

button[aria-expanded]{min-width:44px;min-height:44px}
