:root {
  --ink: #000000;
  --paper: #ffffff;
  --mute: #8a8a8a;
  --line: #e2e2e2;
  --bar: 64px;
  --pad: clamp(1.1rem, 4vw, 3rem);
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
}

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

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

body {
  margin: 0;
  overflow-x: hidden;
  color: var(--ink);
  background-color: var(--paper);
  background-image: radial-gradient(120% 70% at 88% -12%, rgba(0, 0, 0, 0.06), transparent 62%),
    linear-gradient(180deg, #ffffff 0%, #fafafa 55%, #ffffff 100%);
  font-family: Inter, "Helvetica Neue", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  font-size: 17px;
  line-height: 1.72;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--ink);
  text-underline-offset: 0.22em;
}

button {
  font: inherit;
  color: inherit;
}

:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 3px;
}

[id] {
  scroll-margin-top: calc(var(--bar) + 60px);
}

/* ---- top bar ---- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: var(--bar);
  padding: 0.55rem var(--pad);
  background: rgba(255, 255, 255, 0.88);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--ink);
}

.brand {
  font-family: Calistoga, "Songti SC", serif;
  font-size: clamp(1.15rem, 3.4vw, 1.55rem);
  line-height: 1;
  letter-spacing: -0.02em;
  text-decoration: none;
  padding: 0.6rem 0;
}

.burger {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  min-height: 44px;
  padding: 0.45rem 0.9rem;
  background: var(--paper);
  border: 1px solid var(--ink);
  border-radius: 4px;
  font-size: 0.9rem;
  letter-spacing: 0.06em;
  cursor: pointer;
  transition: background 0.25s var(--ease), color 0.25s var(--ease);
}

.burger:hover {
  background: var(--ink);
  color: var(--paper);
}

.burger-bars {
  display: block;
  width: 18px;
}

.burger-bars i {
  display: block;
  height: 2px;
  margin: 3px 0;
  background: currentColor;
}

/* ---- sticky anchor strip (mobile) ---- */
.strip {
  position: sticky;
  top: var(--bar);
  z-index: 55;
  background: var(--ink);
  color: var(--paper);
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.strip::-webkit-scrollbar {
  display: none;
}

.strip ul {
  display: flex;
  margin: 0;
  padding: 0;
  list-style: none;
}

.strip a {
  display: flex;
  align-items: center;
  min-height: 44px;
  padding: 0 1rem;
  color: var(--paper);
  font-size: 0.88rem;
  letter-spacing: 0.04em;
  text-decoration: none;
  white-space: nowrap;
  border-right: 1px solid #303030;
}

.strip a.on {
  background: var(--paper);
  color: var(--ink);
}

/* ---- drawer ---- */
.drawer {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: flex;
  flex-direction: column;
  padding: 1rem var(--pad) 2rem;
  background: var(--ink);
  color: var(--paper);
  overflow-y: auto;
  visibility: hidden;
  transform: translateY(-100%);
  transition: transform 0.45s var(--ease), visibility 0.45s var(--ease);
}

.drawer.open {
  visibility: visible;
  transform: none;
}

.drawer-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding-bottom: 0.9rem;
  border-bottom: 1px solid #333333;
}

.drawer-brand {
  font-family: Calistoga, serif;
  font-size: 1.15rem;
  letter-spacing: -0.02em;
}

.closer {
  min-height: 44px;
  padding: 0.45rem 1rem;
  background: var(--paper);
  color: var(--ink);
  border: 0;
  border-radius: 4px;
  cursor: pointer;
}

.drawer-nav {
  margin-top: 1.6rem;
}

.drawer-nav ul {
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: dn;
}

.drawer-nav li {
  counter-increment: dn;
  border-bottom: 1px solid #232323;
}

.drawer-nav a {
  display: flex;
  align-items: center;
  gap: 1rem;
  min-height: 58px;
  padding: 0.55rem 0.4rem;
  color: var(--paper);
  font-family: Calistoga, "Songti SC", serif;
  font-size: clamp(1.25rem, 6vw, 2rem);
  line-height: 1.15;
  letter-spacing: -0.025em;
  text-decoration: none;
  transition: background 0.22s var(--ease), color 0.22s var(--ease);
}

.drawer-nav a::before {
  content: counter(dn, decimal-leading-zero);
  font-family: Inter, sans-serif;
  font-size: 0.68rem;
  letter-spacing: 0.22em;
  color: var(--mute);
}

.drawer-nav a:hover,
.drawer-nav a:focus-visible {
  background: var(--paper);
  color: var(--ink);
}

body.menu-open {
  overflow: hidden;
}

/* ---- shell / layout ---- */
.shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 2rem;
  max-width: 1220px;
  margin: 0 auto;
  padding: 0 var(--pad) 2rem;
}

main {
  min-width: 0;
}

.wrap {
  padding-top: clamp(1rem, 3vw, 2rem);
}

.stage {
  position: relative;
}

/* ---- hero ---- */
.hero {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(1rem, 3vw, 1.8rem);
  min-height: 45vh;
  padding: clamp(1.6rem, 6vw, 3.4rem) 0 clamp(2.4rem, 8vw, 4.4rem);
  text-align: center;
}

.hero::after {
  content: "";
  position: absolute;
  left: -8%;
  right: -8%;
  bottom: 0;
  height: 12px;
  background: var(--ink);
  transform: skewY(-1.8deg);
  transform-origin: left center;
}

.hero-mark {
  width: clamp(44px, 8vw, 84px);
  color: var(--ink);
}

.hero-glyph {
  display: block;
  width: 100%;
  height: auto;
}

.hero-img {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid var(--ink);
  border-radius: 4px;
}

h1 {
  margin: 0;
  max-width: 18ch;
  font-family: Calistoga, "Songti SC", serif;
  font-weight: 400;
  font-size: clamp(2.3rem, 10vw, 8.5rem);
  line-height: 0.94;
  letter-spacing: -0.045em;
  overflow-wrap: anywhere;
}

/* ---- prose ---- */
.prose {
  max-width: 64ch;
  margin: 0 auto;
  padding-top: clamp(1.6rem, 5vw, 3rem);
}

.prose > section {
  margin: 0 0 clamp(1.4rem, 4vw, 2.6rem);
  padding: clamp(1.15rem, 4vw, 2.6rem);
  background: rgba(255, 255, 255, 0.62);
  -webkit-backdrop-filter: blur(9px) saturate(115%);
  backdrop-filter: blur(9px) saturate(115%);
  border: 1px solid var(--ink);
  border-radius: 4px;
}

.prose h2 {
  margin: 0.1rem 0 1rem;
  font-family: Calistoga, "Songti SC", serif;
  font-weight: 400;
  font-size: clamp(1.55rem, 5.2vw, 2.7rem);
  line-height: 1.08;
  letter-spacing: -0.03em;
}

.prose h3 {
  margin: 1.5rem 0 0.55rem;
  font-size: 1.1rem;
  letter-spacing: 0.01em;
}

.prose h2 > span,
.prose h3 > span,
.rail-title > span,
.foot-col h3 > span {
  display: block;
}

.prose p {
  margin: 0 0 1rem;
}

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

.prose ul,
.prose ol {
  margin: 0 0 1rem;
  padding-left: 1.25rem;
}

.prose li {
  margin: 0.3rem 0;
}

.prose blockquote {
  margin: 1.4rem 0;
  padding: 0.15rem 0 0.15rem 1.1rem;
  border-left: 3px solid var(--ink);
  font-family: Calistoga, "Songti SC", serif;
  font-size: 1.18rem;
}

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

.prose img {
  max-width: 100%;
  height: auto;
  border-radius: 4px;
  border: 1px solid var(--line);
}

.prose time {
  font-size: 0.84rem;
  letter-spacing: 0.08em;
  color: var(--mute);
}

.prose table {
  width: 100%;
  margin: 1rem 0;
  border-collapse: collapse;
  font-size: 0.95rem;
}

.prose th,
.prose td {
  padding: 0.5rem 0.6rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
}

.prose code {
  padding: 0.1em 0.35em;
  background: #f1f1f1;
  border-radius: 3px;
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 0.9em;
}

/* ---- rail ---- */
.rail {
  display: none;
}

.rail-title {
  margin: 0 0 1rem;
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.24em;
  color: var(--mute);
}

.rail ul {
  margin: 0;
  padding: 0;
  list-style: none;
  border-left: 1px solid var(--line);
}

.rail a {
  display: flex;
  align-items: center;
  min-height: 40px;
  margin-left: -1px;
  padding: 0.3rem 0 0.3rem 0.9rem;
  border-left: 2px solid transparent;
  font-size: 0.94rem;
  text-decoration: none;
}

.rail a:hover,
.rail a.on {
  border-left-color: var(--ink);
  font-weight: 600;
}

/* ---- footer ---- */
.foot {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.8rem 1.4rem;
  margin-top: clamp(2.5rem, 8vw, 5rem);
  padding: clamp(2.4rem, 7vw, 4.5rem) var(--pad) 1.4rem;
  background: var(--ink);
  color: var(--paper);
}

.foot-top {
  grid-column: 1 / -1;
  padding-bottom: 1.1rem;
  border-bottom: 1px solid #333333;
}

.foot-brand {
  margin: 0;
  font-family: Calistoga, "Songti SC", serif;
  font-size: clamp(2.8rem, 13vw, 8.5rem);
  line-height: 0.9;
  letter-spacing: -0.05em;
  overflow-wrap: anywhere;
}

.foot-col h3 {
  margin: 0 0 0.85rem;
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.24em;
  color: #9b9b9b;
}

.foot-col ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.foot-col a,
.foot-col button {
  display: flex;
  align-items: center;
  min-height: 42px;
  padding: 0;
  background: none;
  border: 0;
  color: var(--paper);
  font-size: 0.94rem;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}

.foot-col a:hover,
.foot-col button:hover {
  text-decoration: underline;
  text-underline-offset: 0.22em;
}

.foot-base {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  padding-top: 1rem;
  border-top: 1px solid #333333;
  font-size: 0.84rem;
  color: #9b9b9b;
}

.foot-base p {
  margin: 0;
}

.foot-base a {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  color: var(--paper);
}

/* ---- reveal ---- */
.rv {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.65s var(--ease), transform 0.65s var(--ease);
}

.rv.in {
  opacity: 1;
  transform: none;
}

/* ---- breakpoints ---- */
@media (min-width: 760px) {
  .foot {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 2.6rem;
  }
}

@media (min-width: 900px) {
  .strip {
    display: none;
  }

  .shell {
    grid-template-columns: minmax(0, 1fr) 180px;
    gap: clamp(1.6rem, 4vw, 4rem);
  }

  .rail {
    display: block;
    position: sticky;
    top: calc(var(--bar) + 2rem);
    align-self: start;
    padding-top: clamp(2rem, 5vw, 3.4rem);
  }

  .hero {
    min-height: 45vh;
  }
}

@media (min-width: 1100px) {
  body {
    font-size: 18px;
  }
}

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

  .rv {
    opacity: 1;
    transform: none;
    transition: none;
  }

  .drawer {
    transition: none;
  }
}

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