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

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

body {
  margin: 0;
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 17px;
  line-height: 1.7;
  color: #1f1726;
  background-color: #f4ede4;
  background-image: radial-gradient(rgba(86, 34, 139, 0.13) 1px, transparent 1.3px);
  background-size: 22px 22px;
  -webkit-font-smoothing: antialiased;
}

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

.shell {
  max-width: 1140px;
  margin: 0 auto;
  padding: 0 20px;
}

.skip {
  display: inline-block;
  margin-top: 10px;
  padding: 8px 0;
  min-height: 40px;
  color: #56228b;
  font-size: 16px;
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* ---------- 顶栏 ---------- */
.mast {
  position: sticky;
  top: 0;
  z-index: 30;
  padding: 8px 0 10px;
  background: rgba(244, 237, 228, 0.9);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(86, 34, 139, 0.18);
  transition: box-shadow 0.2s ease;
}

.mast.is-stuck { box-shadow: 0 14px 28px -22px rgba(31, 23, 38, 0.9); }

.brandrow { display: flex; align-items: center; }

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-height: 48px;
  padding: 4px 0;
  color: #56228b;
  font-size: 21px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-decoration: none;
}

.brand-logo { width: 28px; height: 28px; border-radius: 50%; }

.navrow {
  margin-top: 6px;
  padding-bottom: 2px;
  overflow-x: auto;
  scrollbar-width: thin;
}

.pillset {
  display: flex;
  gap: 8px;
  min-width: max-content;
  margin: 0;
  padding: 0;
  list-style: none;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 18px;
  border-radius: 999px;
  background: #e9d9f0;
  color: #4a1d75;
  font-size: 16px;
  text-decoration: none;
  transition: background 0.18s ease, color 0.18s ease, transform 0.18s ease;
  animation: rise 0.5s ease both;
}

.pill:hover, .pill:focus-visible {
  background: #56228b;
  color: #fdf8f2;
  transform: translateY(-1px);
}

/* ---------- 首屏 ---------- */
.hero {
  position: relative;
  display: flex;
  align-items: flex-end;
  min-height: 100vh;
  min-height: 100svh;
  margin-top: 18px;
  overflow: hidden;
  border-radius: 0 0 52px 52px;
  background: #2a1636;
}

.hero-img {
  position: absolute;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.hero-veil {
  position: absolute;
  inset: 0;
  z-index: 1;
  background:
    linear-gradient(105deg, rgba(31, 23, 38, 0.94) 0%, rgba(56, 22, 90, 0.82) 46%, rgba(139, 69, 19, 0.42) 100%);
}

.hero::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background-image: radial-gradient(rgba(255, 255, 255, 0.42) 1px, transparent 1.3px);
  background-size: 16px 16px;
  opacity: 0.45;
}

.hero-blob {
  position: absolute;
  z-index: 1;
  opacity: 0.5;
  filter: blur(1px);
  mix-blend-mode: screen;
}

.hero-blob.a {
  top: 10%;
  right: -70px;
  width: 320px;
  height: 320px;
  background: radial-gradient(circle at 35% 35%, #8b4513, #56228b 70%);
  border-radius: 62% 38% 47% 53% / 58% 44% 56% 42%;
  animation: blob-a 19s ease-in-out infinite;
}

.hero-blob.b {
  bottom: 16%;
  left: -50px;
  width: 210px;
  height: 210px;
  background: radial-gradient(circle at 60% 40%, #56228b, #8b4513 75%);
  border-radius: 47% 53% 62% 38% / 42% 56% 44% 58%;
  animation: blob-b 23s ease-in-out infinite;
}

.hero-inner {
  position: relative;
  z-index: 3;
  width: 100%;
  max-width: 900px;
  padding: 0 24px 12vh;
}

.hero h1 {
  margin: 0;
  color: #fdf7f1;
  font-size: clamp(2.1rem, 7vw, 4.4rem);
  font-weight: 500;
  line-height: 1.12;
  letter-spacing: 0.01em;
  text-shadow: 0 12px 30px rgba(31, 23, 38, 0.55);
  animation: rise 0.9s ease both;
}

/* ---------- 正文与侧栏 ---------- */
.spread {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 264px;
  gap: 36px;
  align-items: start;
  padding: 56px 0 40px;
}

.paper {
  padding: 32px clamp(18px, 4vw, 44px) 44px;
  border-radius: 22px;
  background: #faf5ef;
  box-shadow: 0 26px 48px -38px rgba(31, 23, 38, 0.85);
}

.paper section[id] { scroll-margin-top: 160px; }

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

.paper h2, .paper h3 {
  position: relative;
  margin: 2.1em 0 0.7em;
  padding-left: 16px;
  line-height: 1.28;
  color: #2b1a3e;
  scroll-margin-top: 160px;
}

.paper h2 { font-size: clamp(1.35rem, 3vw, 1.75rem); }
.paper h3 { font-size: clamp(1.12rem, 2vw, 1.3rem); }

.paper h2::before, .paper h3::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.18em;
  bottom: 0.18em;
  width: 6px;
  border-radius: 999px;
  background: linear-gradient(#56228b, #8b4513);
}

.paper h2 > span, .paper h3 > span {
  background: linear-gradient(transparent 64%, rgba(139, 69, 19, 0.26) 64%);
}

.paper ul, .paper ol { margin: 0 0 1.1em; padding-left: 1.3em; }
.paper li { margin: 0.35em 0; }

.paper a {
  color: #6a2f9b;
  text-decoration: underline;
  text-decoration-color: rgba(139, 69, 19, 0.5);
  text-underline-offset: 3px;
}

.paper a:hover { color: #8b4513; }

.paper blockquote {
  margin: 1.4em 0;
  padding: 14px 18px;
  border-left: 6px solid rgba(86, 34, 139, 0.35);
  border-radius: 4px;
  background: #f0e5f5;
}

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

.paper table {
  display: block;
  max-width: 100%;
  overflow-x: auto;
  border-collapse: collapse;
  font-size: 16px;
}

.paper th, .paper td {
  padding: 9px 12px;
  border-bottom: 1px solid rgba(86, 34, 139, 0.18);
  text-align: left;
}

.paper th { background: #efe1ea; }

.paper img { border-radius: 4px; }

.paper code, .paper pre {
  font-family: inherit;
  background: #efe4f3;
  border-radius: 4px;
}

.paper code { padding: 1px 5px; }
.paper pre { padding: 14px 16px; overflow-x: auto; }

.side {
  position: sticky;
  top: 148px;
  display: grid;
  gap: 4px;
}

.side-h {
  margin: 16px 0 8px;
  color: #8b4513;
  font-size: 16px;
  font-weight: 500;
  letter-spacing: 0.16em;
}

.side-h:first-child { margin-top: 0; }

.side-list {
  margin: 0;
  padding: 10px;
  list-style: none;
  border-radius: 4px;
  background: #efe2d5;
}

.side-list li { animation: rise 0.5s ease both; animation-delay: calc(var(--n, 0) * 55ms); }

.side-list a {
  display: flex;
  align-items: center;
  min-height: 40px;
  padding: 6px 9px;
  border-radius: 4px;
  color: #3c1a5f;
  font-size: 16px;
  text-decoration: none;
  transition: background 0.16s ease, color 0.16s ease, padding-left 0.16s ease;
}

.side-list a:hover, .side-list a:focus-visible, .side-list a.is-live {
  background: #56228b;
  color: #fdf8f2;
  padding-left: 14px;
}

.side-list--mark { background: #e7d6c4; }

/* ---------- 页脚 ---------- */
.foot {
  margin-top: 28px;
  padding: 52px 0 44px;
  border-top: 1px solid rgba(86, 34, 139, 0.22);
}

.foot-top {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 26px 40px;
}

.foot-id {
  flex: 1 1 100%;
  display: grid;
  gap: 12px;
  font-style: normal;
}

.foot-brand {
  color: #56228b;
  font-size: clamp(2rem, 10vw, 5rem);
  font-weight: 500;
  line-height: 1;
  letter-spacing: -0.02em;
  word-break: break-all;
}

.foot-copy { color: #6b5b57; font-size: 16px; }

.foot-nav dl {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 18px;
  margin: 0;
}

.foot-nav dt { color: #8b4513; font-size: 16px; align-self: center; }
.foot-nav dd { margin: 0; }

.foot-nav a, .foot-jump a {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  color: #1f1726;
  font-size: 16px;
  text-decoration: none;
  border-bottom: 2px solid transparent;
  transition: color 0.16s ease, border-color 0.16s ease;
}

.foot-nav a:hover, .foot-jump a:hover,
.foot-nav a:focus-visible, .foot-jump a:focus-visible {
  color: #56228b;
  border-bottom-color: #8b4513;
}

.foot-jump {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 20px;
  margin: 0 0 0 auto;
  padding: 0;
  list-style: none;
}

/* ---------- 动画 ---------- */
@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: none; }
}

@keyframes blob-a {
  50% { transform: translate3d(-20px, 16px, 0) scale(1.09); border-radius: 38% 62% 53% 47% / 44% 58% 42% 56%; }
}

@keyframes blob-b {
  50% { transform: translate3d(18px, -14px, 0) scale(1.06); border-radius: 58% 42% 38% 62% / 52% 40% 60% 48%; }
}

/* ---------- 断点 ---------- */
@media (max-width: 980px) {
  .spread {
    grid-template-columns: minmax(0, 1fr);
    gap: 26px;
    padding: 40px 0 32px;
  }

  .side { position: static; }

  .paper { border-radius: 18px; }

  .hero { min-height: 92vh; min-height: 92svh; border-radius: 0 0 34px 34px; }

  .hero-inner { padding: 0 16px 9vh; }

  .foot-jump { margin-left: 0; flex: 1 1 100%; }
}

@media (max-width: 620px) {
  body { font-size: 17px; background-size: 18px 18px; }

  .hero-blob.a { width: 220px; height: 220px; right: -80px; }
  .hero-blob.b { width: 150px; height: 150px; left: -60px; }

  .paper { padding: 22px 16px 32px; }

  .foot-brand { font-size: clamp(1.8rem, 13vw, 3rem); }

  .foot-top { gap: 18px 24px; }
}

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

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