@import url('https://fonts.googleapis.com/css2?family=Atkinson+Hyperlegible:wght@400;700&family=Crimson+Pro:wght@400;500;600;700&display=swap');

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

:root {
  --ink: #172623;
  --ink-soft: #33504a;
  --paper: #f4eee2;
  --sand: #e5d9c2;
  --clay: #c7b294;
  --terracotta: #c67b5c;
  --teal: #5cc6b0;
  --teal-deep: #2c8776;
  --forest: #14322b;
  --r: 4px;
  --pad: clamp(1rem, 4vw, 2.25rem);
  --serif: "Crimson Pro", Georgia, "Songti SC", "Noto Serif SC", serif;
  --ui: "Atkinson Hyperlegible", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

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

body {
  margin: 0;
  background-color: var(--paper);
  background-image:
    radial-gradient(58rem 26rem at 88% -12%, rgba(92, 198, 176, .22), transparent 70%),
    radial-gradient(48rem 24rem at -8% 26%, rgba(198, 123, 92, .12), transparent 66%);
  background-repeat: no-repeat;
  color: var(--ink);
  font-family: var(--serif);
  font-size: 1.0625rem;
  line-height: 1.75;
  letter-spacing: .002em;
}

.grain {
  position: fixed;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  opacity: .16;
  mix-blend-mode: multiply;
  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='0.85' numOctaves='2'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)' opacity='0.42'/%3E%3C/svg%3E");
}

a { color: var(--teal-deep); }
a:focus-visible {
  outline: 2px solid var(--teal-deep);
  outline-offset: 3px;
}

p a, li a, blockquote a {
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
}

p a:hover, li a:hover, blockquote a:hover { color: var(--forest); }

/* 页头：品牌独占一行，下一行药丸菜单 */
.mast {
  display: flex;
  flex-direction: column;
  gap: .85rem;
  padding: clamp(1rem, 3vw, 1.9rem) var(--pad) 0;
}

.mast-top {
  display: flex;
  align-items: center;
  gap: .9rem;
}

.mast-logo {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  font-family: var(--serif);
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: .05em;
  color: var(--ink);
  text-decoration: none;
}

.mast-logo::before {
  content: "";
  width: .78rem;
  height: .78rem;
  margin-right: .55rem;
  border-radius: 2px 6px 2px 6px;
  background: var(--teal);
  transform: rotate(-9deg);
}

.mast-logo:hover::before { background: var(--terracotta); }

.mast-line {
  flex: 1 1 auto;
  height: 1px;
  min-width: 2rem;
  background: linear-gradient(90deg, var(--clay), rgba(199, 178, 148, 0));
}

.mast-nav nav ul {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem .42rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.mast-nav a {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: .3rem .9rem;
  border-radius: 999px;
  background: var(--sand);
  color: var(--ink-soft);
  font-family: var(--ui);
  font-size: .9rem;
  line-height: 1.2;
  letter-spacing: .01em;
  text-decoration: none;
  transition: background .22s ease-out, color .22s ease-out, transform .22s ease-out;
}

.mast-nav a:hover,
.mast-nav a:focus-visible {
  background: var(--teal);
  color: var(--forest);
  transform: translateY(-2px);
}

.mast-nav a.is-current {
  background: var(--forest);
  color: var(--paper);
}

/* 版心：正文在左，页内目录在右 */
.sheet {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 14.5rem;
  column-gap: clamp(1.5rem, 4vw, 3rem);
  row-gap: 2rem;
  max-width: 74rem;
  margin: 0 auto;
  padding: 0 var(--pad) clamp(2rem, 6vw, 3.5rem);
}

.hero {
  grid-column: 1 / -1;
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  min-height: 45vh;
  padding: clamp(1.2rem, 5vw, 2.4rem) 0 clamp(1.4rem, 3vw, 2rem);
}

.hero h1 {
  margin: 0;
  max-width: 24ch;
  font-family: var(--serif);
  font-size: clamp(2.1rem, 6.4vw, 4.3rem);
  font-weight: 700;
  line-height: 1.08;
  letter-spacing: -.018em;
  color: var(--forest);
}

.wedge {
  display: block;
  height: .55rem;
  margin-top: clamp(1rem, 3vw, 1.6rem);
  background: linear-gradient(90deg, var(--teal) 0%, var(--terracotta) 100%);
  clip-path: polygon(0 62%, 100% 0, 100% 100%, 0 100%);
}

.prose { min-width: 0; }

.prose > *:first-child {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}

.prose > section {
  margin-top: clamp(1.7rem, 4vw, 2.8rem);
  padding-top: clamp(1.5rem, 4vw, 2.4rem);
  border-top: 1px solid var(--clay);
  scroll-margin-top: 1.5rem;
}

.prose h2,
.prose h3 {
  margin: 1.6em 0 .55em;
  font-family: var(--serif);
  line-height: 1.24;
  letter-spacing: -.01em;
  color: var(--forest);
}

.prose h2 { font-size: clamp(1.45rem, 3.1vw, 1.95rem); }
.prose h3 { font-size: clamp(1.16rem, 2.2vw, 1.35rem); }

.prose small {
  display: block;
  margin-bottom: .38rem;
  font-family: var(--ui);
  font-size: .76rem;
  font-weight: 700;
  letter-spacing: .17em;
  line-height: 1.4;
  color: var(--teal-deep);
}

.prose small + h2,
.prose small + h3 {
  margin-top: .1em;
}

.prose p { margin: 0 0 1.05em; }

.prose ul,
.prose ol {
  margin: 0 0 1.15em;
  padding-left: 1.35em;
}

.prose li { margin: .38em 0; }
.prose li::marker { color: var(--teal-deep); }

.prose blockquote {
  margin: 1.4em 0;
  padding: .95em 1.15em;
  background: var(--sand);
  border-left: 4px solid var(--teal);
  border-radius: var(--r) 14px var(--r) 14px;
  font-style: italic;
  color: var(--ink-soft);
}

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

.prose img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 1.3em 0;
  border-radius: var(--r);
}

.prose figure { margin: 1.4em 0; }
.prose figure img { margin: 0 0 .5em; }
.prose figcaption {
  font-family: var(--ui);
  font-size: .82rem;
  color: var(--ink-soft);
}

.prose hr {
  height: 1px;
  margin: 2em 0;
  border: 0;
  background: var(--clay);
}

.prose code,
.prose pre {
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: .92em;
}

.prose pre {
  overflow-x: auto;
  padding: .9em 1em;
  background: var(--sand);
  border-radius: var(--r);
}

.prose table {
  width: 100%;
  margin: 1.3em 0;
  border-collapse: collapse;
  font-size: .95rem;
}

.prose th,
.prose td {
  padding: .5em .6em;
  border-bottom: 1px solid var(--clay);
  text-align: left;
}

/* 右侧页内目录 */
.rail {
  position: sticky;
  top: 1.25rem;
  align-self: start;
  padding: 1rem 1.1rem 1.15rem;
  background: var(--sand);
  border-radius: var(--r) 14px var(--r) 14px;
  box-shadow: 0 8px 22px -18px rgba(20, 50, 43, .8);
  font-family: var(--ui);
}

.rail-kicker {
  display: block;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .19em;
  color: var(--teal-deep);
}

.rail-title {
  margin: .15rem 0 .75rem;
  font-family: var(--serif);
  font-size: 1.12rem;
  line-height: 1.3;
  color: var(--forest);
}

.rail ul {
  display: grid;
  gap: .1rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.rail a {
  display: flex;
  align-items: center;
  min-height: 40px;
  padding: .2rem .35rem;
  border-bottom: 1px dashed rgba(23, 38, 35, .2);
  color: var(--ink-soft);
  font-size: .88rem;
  line-height: 1.3;
  text-decoration: none;
  transition: color .2s ease-out;
}

.rail a::before {
  content: "";
  flex: 0 0 auto;
  width: 6px;
  height: 6px;
  margin-right: .5rem;
  border-radius: 50%;
  background: var(--clay);
  transition: background .2s ease-out, transform .2s ease-out;
}

.rail a:hover { color: var(--forest); }
.rail a:hover::before { background: var(--teal); transform: scale(1.45); }
.rail a.is-current { color: var(--forest); font-weight: 700; }
.rail a.is-current::before { background: var(--terracotta); }

/* 页脚 */
.foot {
  position: relative;
  margin-top: clamp(1.5rem, 4vw, 2.5rem);
  padding: clamp(2.2rem, 7vw, 3.6rem) var(--pad) clamp(1.4rem, 3vw, 2rem);
  background: var(--forest);
  color: var(--paper);
}

.foot::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: .55rem;
  background: linear-gradient(90deg, var(--terracotta), var(--teal));
  clip-path: polygon(0 0, 100% 0, 100% 100%, 0 38%);
}

.foot address {
  display: block;
  font-style: normal;
}

.foot-brand {
  display: block;
  font-family: var(--serif);
  font-size: clamp(2.6rem, 12vw, 5.6rem);
  font-weight: 700;
  line-height: 1;
  letter-spacing: -.02em;
  color: var(--sand);
}

.foot-copy {
  display: block;
  margin-top: .55rem;
  font-family: var(--ui);
  font-size: .84rem;
  color: rgba(244, 238, 226, .72);
}

.foot-links {
  display: flex;
  flex-wrap: wrap;
  gap: .15rem 1rem;
  margin: 1.15rem 0 0;
  padding: 0;
  list-style: none;
  font-family: var(--ui);
  font-size: .84rem;
}

.foot-links a {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  border-bottom: 1px solid transparent;
  color: var(--sand);
  text-decoration: none;
  transition: color .2s ease-out, border-color .2s ease-out;
}

.foot-links a:hover {
  color: #fff;
  border-bottom-color: var(--teal);
}

/* 入场动画 */
@media (prefers-reduced-motion: no-preference) {
  .prose > article {
    animation: rise .55s cubic-bezier(.2, .7, .3, 1) both;
  }
  .prose > article:nth-child(2) { animation-delay: .05s; }
  .prose > article:nth-child(3) { animation-delay: .1s; }
  .prose > article:nth-child(4) { animation-delay: .15s; }
  .prose > article:nth-child(5) { animation-delay: .2s; }
  .prose > article:nth-child(6) { animation-delay: .25s; }
  .prose > article:nth-child(7) { animation-delay: .3s; }
}

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

/* 窄屏 */
@media (max-width: 760px) {
  .sheet {
    grid-template-columns: minmax(0, 1fr);
    row-gap: 1.6rem;
  }
  .hero { min-height: 42vh; }
  .rail {
    position: static;
    order: 3;
  }
  .rail ul { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .1rem .5rem; }
  .rail a { font-size: .84rem; }
  .mast-nav a { font-size: .86rem; padding: .3rem .75rem; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { animation: none !important; transition: none !important; }
}

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