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

:root {
  --paper: #f5e6c8;
  --paper-2: #f0dcb7;
  --tan: #d4a574;
  --ink: #262117;
  --ink-2: #4a3f30;
  --line: rgba(38, 33, 23, 0.22);
  --serif: "Noto Serif JP", "Songti SC", "SimSun", Georgia, serif;
  --sans: "Noto Sans JP", "Hiragino Sans", "Microsoft YaHei", sans-serif;
  --rail: clamp(178px, 16vw, 222px);
}

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

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

body {
  margin: 0;
  font-family: var(--serif);
  font-size: 17px;
  line-height: 1.85;
  color: var(--ink);
  background-color: var(--paper);
  background-image:
    radial-gradient(circle at 88% 6%, rgba(255, 249, 227, 0.95), rgba(255, 249, 227, 0) 44%),
    radial-gradient(circle at 6% 82%, rgba(212, 165, 116, 0.38), rgba(212, 165, 116, 0) 55%),
    radial-gradient(circle at 62% 48%, rgba(255, 240, 205, 0.5), rgba(255, 240, 205, 0) 60%);
  background-attachment: fixed;
  filter: sepia(0.16) saturate(0.92) contrast(1.02);
  overflow-x: hidden;
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 90;
  pointer-events: none;
  opacity: 0.17;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.82' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='220' height='220' filter='url(%23n)' opacity='0.6'/%3E%3C/svg%3E");
}

a {
  color: inherit;
}

.skip {
  position: fixed;
  left: 10px;
  top: 10px;
  z-index: 120;
  transform: translateY(-180%);
  background: var(--ink);
  color: var(--paper);
  font-family: var(--sans);
  font-size: 0.9rem;
  padding: 10px 16px;
  border-radius: 4px;
  text-decoration: none;
  min-height: 44px;
  display: flex;
  align-items: center;
  transition: transform 0.22s ease;
}

.skip:focus {
  transform: none;
}

/* ---------- 左侧竖排导航 ---------- */

.rail {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--rail);
  z-index: 40;
  display: flex;
  flex-direction: column;
  gap: 26px;
  padding: 28px 20px 26px;
  border-right: 2px solid var(--ink);
  background-image: linear-gradient(180deg, rgba(245, 230, 200, 0.97), rgba(236, 214, 175, 0.94));
  overflow-y: auto;
}

.rail-brand {
  writing-mode: vertical-rl;
  font-family: var(--sans);
  font-weight: 700;
  font-size: 1.42rem;
  letter-spacing: 0.24em;
  line-height: 1.05;
  color: var(--ink);
  text-decoration: none;
  align-self: flex-start;
  padding-bottom: 4px;
  border-bottom: 3px solid var(--tan);
  transition: color 0.25s ease, border-color 0.25s ease;
}

.rail-brand:hover,
.rail-brand:focus-visible {
  color: #7a4718;
  border-bottom-color: var(--ink);
}

.rail-nav {
  display: flex;
  flex-direction: column;
}

.rail-nav a {
  position: relative;
  display: flex;
  align-items: center;
  min-height: 44px;
  padding: 11px 2px 11px 16px;
  font-family: var(--sans);
  font-size: 0.94rem;
  letter-spacing: 0.05em;
  text-decoration: none;
  color: var(--ink-2);
  border-bottom: 1px dotted var(--line);
  transition: color 0.22s ease, padding-left 0.22s ease;
}

.rail-nav a::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  width: 8px;
  height: 2px;
  background: var(--tan);
  transform: translateY(-50%) scaleX(0);
  transform-origin: left center;
  transition: transform 0.25s ease;
}

.rail-nav a:hover,
.rail-nav a:focus-visible {
  color: #7a4718;
  padding-left: 24px;
}

.rail-nav a:hover::before,
.rail-nav a:focus-visible::before {
  transform: translateY(-50%) scaleX(1);
}

/* ---------- 主区 ---------- */

.page {
  margin-left: var(--rail);
  min-width: 0;
}

.hero {
  position: relative;
  min-height: 70vh;
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  gap: clamp(14px, 2.4vw, 32px);
  padding: clamp(40px, 6vw, 74px) clamp(20px, 5vw, 64px) clamp(34px, 5vw, 58px);
  border-bottom: 2px solid var(--ink);
  overflow: hidden;
  isolation: isolate;
}

.hero-ghost {
  position: absolute;
  left: 6px;
  top: 4%;
  writing-mode: vertical-rl;
  font-family: var(--sans);
  font-weight: 700;
  font-size: clamp(3rem, 11vw, 8.6rem);
  line-height: 0.92;
  letter-spacing: 0.08em;
  color: rgba(38, 33, 23, 0.09);
  pointer-events: none;
  user-select: none;
  z-index: 0;
}

.hero-art {
  flex: none;
  position: relative;
  z-index: 2;
  background: #fffdf5;
  padding: 8px 8px 24px;
  border: 1px solid rgba(38, 33, 23, 0.25);
  border-radius: 2px;
  box-shadow: 0 12px 26px rgba(38, 33, 23, 0.2);
  transform: rotate(-3deg);
  animation: wobble 8s ease-in-out infinite;
}

.hero-art:empty {
  display: none;
}

.hero-art img {
  display: block;
  width: clamp(82px, 11vw, 128px);
  height: auto;
}

.hero-copy {
  position: relative;
  z-index: 3;
  text-align: right;
  max-width: 22ch;
}

.hero-kicker {
  margin: 0 0 10px;
  font-family: var(--sans);
  font-size: 0.82rem;
  font-weight: 500;
  letter-spacing: 0.42em;
  color: #8a5423;
  text-transform: none;
}

.hero h1 {
  margin: 0;
  font-family: var(--sans);
  font-weight: 700;
  font-size: clamp(2.1rem, 6.4vw, 4.2rem);
  line-height: 1.14;
  letter-spacing: 0.02em;
  text-shadow: 2px 2px 0 rgba(212, 165, 116, 0.45);
}

.wrap {
  padding: clamp(26px, 4vw, 56px) clamp(18px, 4vw, 56px) clamp(40px, 5vw, 70px);
}

.cols {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 242px;
  gap: clamp(20px, 3vw, 46px);
  align-items: start;
  max-width: 1160px;
}

/* ---------- 正文 ---------- */

.prose {
  min-width: 0;
  font-size: 17px;
}

.prose > section {
  position: relative;
  margin: 0 0 clamp(20px, 3vw, 34px);
  padding: clamp(16px, 2.4vw, 28px) clamp(15px, 2.4vw, 30px) clamp(20px, 2.6vw, 30px);
  background: rgba(255, 251, 240, 0.55);
  border: 1px solid rgba(38, 33, 23, 0.14);
  border-bottom: 3px solid var(--tan);
  border-radius: 4px;
  scroll-margin-top: 96px;
  animation: fadeUp 0.66s cubic-bezier(0.22, 0.7, 0.3, 1) both;
}

.prose > section:nth-child(1) { animation-delay: 0.04s; }
.prose > section:nth-child(2) { animation-delay: 0.1s; }
.prose > section:nth-child(3) { animation-delay: 0.16s; }
.prose > section:nth-child(4) { animation-delay: 0.22s; }
.prose > section:nth-child(5) { animation-delay: 0.28s; }
.prose > section:nth-child(6) { animation-delay: 0.34s; }
.prose > section:nth-child(7) { animation-delay: 0.4s; }

.prose h2 {
  margin: 0;
  font-family: var(--sans);
  font-weight: 700;
  font-size: clamp(1.35rem, 2.7vw, 1.8rem);
  line-height: 1.4;
  letter-spacing: 0.02em;
}

.prose h2 + hr {
  border: 0;
  border-top: 3px solid var(--tan);
  width: 58px;
  margin: 0.55rem 0 1rem;
}

.prose h3 {
  margin: 1.5rem 0 0.5rem;
  font-family: var(--sans);
  font-weight: 600;
  font-size: 1.12rem;
  line-height: 1.5;
}

.prose h3 + hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 0.4rem 0 0.9rem;
}

.prose p {
  margin: 0 0 1rem;
  color: var(--ink-2);
}

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

.prose strong {
  color: var(--ink);
  font-weight: 700;
  background: linear-gradient(transparent 64%, rgba(212, 165, 116, 0.6) 64%);
}

.prose a {
  color: #7a4718;
  text-decoration: none;
  border-bottom: 1px solid var(--tan);
  transition: background-color 0.2s ease, color 0.2s ease;
}

.prose a:hover,
.prose a:focus-visible {
  background-color: rgba(212, 165, 116, 0.35);
  color: var(--ink);
}

.prose ul,
.prose ol {
  margin: 0 0 1rem;
  padding-left: 1.35em;
  color: var(--ink-2);
}

.prose li {
  margin-bottom: 0.45rem;
}

.prose li::marker {
  color: var(--tan);
}

.prose blockquote {
  margin: 1.2rem 0;
  padding: 0.6rem 0 0.6rem 1.1rem;
  border-left: 3px solid var(--tan);
  color: var(--ink-2);
  font-style: normal;
}

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

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

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

.prose th {
  background: rgba(212, 165, 116, 0.28);
  font-family: var(--sans);
}

/* ---------- 侧栏 ---------- */

.railside {
  position: sticky;
  top: 26px;
  border-top: 3px solid var(--ink);
  border-bottom: 1px solid var(--line);
  padding: 14px 0 16px;
}

.railside h2 {
  margin: 0;
  font-family: var(--sans);
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: 0.2em;
}

.railside h2 + hr {
  border: 0;
  border-top: 2px solid var(--tan);
  width: 36px;
  margin: 0.55rem 0 0.8rem;
}

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

.toc li {
  counter-increment: toc;
}

.toc a {
  position: relative;
  display: flex;
  align-items: center;
  min-height: 42px;
  padding: 8px 0 8px 28px;
  font-size: 0.94rem;
  line-height: 1.5;
  text-decoration: none;
  color: var(--ink-2);
  transition: color 0.2s ease, padding-left 0.2s ease;
}

.toc a::before {
  content: counter(toc, decimal-leading-zero);
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  font-family: var(--sans);
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  color: var(--tan);
}

.toc a:hover,
.toc a:focus-visible {
  color: var(--ink);
  padding-left: 34px;
}

.totop {
  display: flex;
  align-items: center;
  min-height: 44px;
  padding: 10px 0;
  border-top: 1px dashed var(--line);
  font-family: var(--sans);
  font-size: 0.86rem;
  letter-spacing: 0.14em;
  text-decoration: none;
  color: var(--ink-2);
  transition: color 0.2s ease;
}

.totop:hover,
.totop:focus-visible {
  color: #7a4718;
}

/* ---------- 页脚 ---------- */

.foot {
  position: relative;
  margin-left: var(--rail);
  overflow: hidden;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 26px;
  padding: 20px clamp(18px, 4vw, 56px);
  border-top: 2px solid var(--ink);
  background-image: linear-gradient(180deg, rgba(212, 165, 116, 0.2), rgba(212, 165, 116, 0.34));
}

.foot-ghost {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  font-family: var(--sans);
  font-weight: 700;
  font-size: clamp(2.4rem, 7vw, 5.2rem);
  line-height: 1;
  letter-spacing: 0.08em;
  white-space: nowrap;
  color: rgba(38, 33, 23, 0.075);
  pointer-events: none;
  user-select: none;
}

.foot-brand,
.foot-nav,
.foot-copy {
  position: relative;
  z-index: 1;
}

.foot-brand a {
  font-family: var(--sans);
  font-weight: 700;
  font-size: 1.02rem;
  letter-spacing: 0.1em;
  text-decoration: none;
  color: var(--ink);
  display: flex;
  align-items: center;
  min-height: 44px;
}

.foot-nav dl {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
}

.foot-nav dt {
  font-family: var(--sans);
  font-size: 0.72rem;
  letter-spacing: 0.16em;
  color: var(--ink-2);
}

.foot-nav dd {
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0 12px;
}

.foot-nav a {
  display: flex;
  align-items: center;
  min-height: 44px;
  padding: 10px 2px;
  font-family: var(--sans);
  font-size: 0.86rem;
  text-decoration: none;
  color: var(--ink-2);
  border-bottom: 1px solid transparent;
  transition: color 0.2s ease, border-color 0.2s ease;
}

.foot-nav a:hover,
.foot-nav a:focus-visible {
  color: var(--ink);
  border-bottom-color: var(--tan);
}

.foot-copy {
  margin: 0 0 0 auto;
  font-family: var(--sans);
  font-size: 0.8rem;
  letter-spacing: 0.06em;
  color: var(--ink-2);
}

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

@keyframes wobble {
  0%,
  100% {
    transform: rotate(-3deg) translateY(0);
  }
  50% {
    transform: rotate(-1.4deg) translateY(-5px);
  }
}

/* ---------- 断点 ---------- */

@media (max-width: 1000px) {
  .cols {
    grid-template-columns: minmax(0, 1fr) 200px;
  }
}

@media (max-width: 860px) {
  .rail {
    position: sticky;
    inset: auto;
    width: auto;
    flex-direction: row;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    border-right: 0;
    border-bottom: 2px solid var(--ink);
    overflow: visible;
    z-index: 60;
  }

  .rail-brand {
    writing-mode: horizontal-tb;
    flex: none;
    display: flex;
    align-items: center;
    min-height: 44px;
    padding: 8px 0 9px;
    font-size: 1rem;
    letter-spacing: 0.1em;
  }

  .rail-nav {
    flex-direction: row;
    flex: 1;
    gap: 4px;
    overflow-x: auto;
    scrollbar-width: thin;
  }

  .rail-nav a {
    white-space: nowrap;
    padding: 11px 11px;
    min-height: 44px;
    border-bottom: 0;
    border: 1px solid transparent;
    border-radius: 4px;
  }

  .rail-nav a:hover,
  .rail-nav a:focus-visible {
    padding-left: 11px;
    border-color: var(--line);
    background: rgba(255, 251, 240, 0.7);
  }

  .rail-nav a::before {
    display: none;
  }

  .page,
  .foot {
    margin-left: 0;
  }

  .hero {
    min-height: auto;
    flex-wrap: wrap;
    justify-content: flex-end;
    padding: 64px 18px 36px;
    gap: 14px;
  }

  .hero-ghost {
    font-size: 3.4rem;
    top: 10px;
    opacity: 0.85;
  }

  .hero-copy {
    max-width: none;
  }

  .cols {
    grid-template-columns: minmax(0, 1fr);
    gap: 26px;
  }

  .railside {
    position: static;
    order: 2;
  }

  .prose > section {
    scroll-margin-top: 76px;
    padding: 18px 16px 22px;
  }

  .foot-copy {
    margin-left: 0;
  }

  .foot-ghost {
    font-size: 2.6rem;
  }
}

@media (max-width: 420px) {
  body {
    font-size: 16.5px;
  }

  .hero h1 {
    font-size: 2.05rem;
  }

  .prose > section {
    padding: 16px 13px 20px;
  }

  .foot {
    gap: 4px 16px;
  }
}

@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}
