@font-face {
  font-family: "MEB Heiti";
  src: url("fonts/MEBheiheiti.ttf") format("truetype");
  font-display: swap;
}

:root {
  --paper: #f5efe6;
  --paper-2: #ede4d6;
  --card: #fffdf9;
  --ink: #1a1815;
  --ink-2: #3a352f;
  --muted: #776e63;
  --line: rgba(26, 24, 21, .13);
  --red: #c8352e;
  --blue: #2e52b5;
  --orange: #dc6a2b;
  --display: "MEB Heiti", "PingFang SC", "Hiragino Sans GB", "Noto Sans CJK SC", "Microsoft YaHei", sans-serif;
  --sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Noto Sans CJK SC", "Noto Sans SC", "Microsoft YaHei", "Segoe UI", "Apple Color Emoji", "Noto Color Emoji", "Segoe UI Emoji", sans-serif;
  --pad: clamp(20px, 5vw, 64px);
  --max: 1240px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 76px; -webkit-text-size-adjust: 100%; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.7 var(--sans);
  overflow-x: hidden;
  /* faint paper fibre */
  background-image:
    radial-gradient(rgba(120, 96, 60, .05) 1px, transparent 1.2px),
    radial-gradient(rgba(120, 96, 60, .035) 1px, transparent 1.2px);
  background-size: 23px 23px, 37px 37px;
  background-position: 0 0, 11px 17px;
}
img { display: block; max-width: 100%; }
a { color: inherit; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--blue); outline-offset: 3px; border-radius: 6px; }

.skip { position: absolute; left: -999px; top: 8px; z-index: 50; background: var(--ink); color: #fff; padding: 8px 14px; border-radius: 99px; }
.skip:focus { left: 12px; }

/* ---------- masthead ---------- */
.mast {
  position: sticky; top: 0; z-index: 20;
  background: rgba(245, 239, 230, .94);
  backdrop-filter: saturate(1.2) blur(8px);
  -webkit-backdrop-filter: saturate(1.2) blur(8px);
  border-bottom: 1px solid var(--line);
}
.mast__in {
  max-width: var(--max); margin: 0 auto; padding: 10px var(--pad);
  display: flex; align-items: center; gap: 16px;
}
.mast__brand { margin: 0; font-size: 15px; color: var(--muted); white-space: nowrap; letter-spacing: .02em; }
.mast__brand b { color: var(--ink); font-weight: 800; margin-right: 4px; }
.mast__nav { display: flex; gap: 4px; margin-left: auto; }
.mast__nav a {
  text-decoration: none; font-size: 14px; padding: 6px 12px; border-radius: 99px; color: var(--ink-2); white-space: nowrap;
}
.mast__nav a:hover { background: rgba(26, 24, 21, .07); }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 0 22px; border-radius: 99px;
  font-size: 15px; font-weight: 700; letter-spacing: .02em; text-decoration: none;
  border: 1.5px solid var(--ink); cursor: pointer; transition: background-color .15s, color .15s, border-color .15s;
  -webkit-tap-highlight-color: transparent; touch-action: manipulation;
}
.btn--sm { min-height: 38px; padding: 0 16px; font-size: 14px; }
.btn--ink { background: var(--ink); color: #fff; }
.btn--ink:hover { background: #000; }
.btn--line { background: transparent; color: var(--ink); }
.btn--line:hover { background: rgba(26, 24, 21, .06); }
.btn.is-ok { background: #2f7a4f; border-color: #2f7a4f; color: #fff; }
.btn.is-fail { background: var(--red); border-color: var(--red); color: #fff; }

/* ---------- hero ---------- */
.hero {
  position: relative;
  max-width: var(--max); margin: 0 auto;
  padding: clamp(36px, 7vw, 88px) var(--pad) clamp(48px, 7vw, 96px);
  display: grid; grid-template-columns: minmax(0, 1.08fr) minmax(0, .92fr);
  gap: clamp(32px, 6vw, 88px); align-items: center;
}
.bean { position: absolute; width: 38px; fill: none; stroke: rgba(150, 120, 80, .28); stroke-width: 1.6; pointer-events: none; }
.bean--a { left: calc(var(--pad) - 8px); bottom: 28px; transform: rotate(-24deg); }
.bean--b { right: 46%; top: 26px; width: 30px; transform: rotate(18deg); }

.kicker { margin: 0 0 28px; display: flex; align-items: center; gap: 10px; color: var(--red); font-weight: 700; font-size: 15px; letter-spacing: .04em; }
.kicker__dot { width: 9px; height: 9px; border-radius: 50%; background: var(--red); flex: none; box-shadow: 14px 0 0 var(--blue), 28px 0 0 var(--orange); margin-right: 30px; }
.eyebrow { margin: 0 0 10px; font-size: 13px; letter-spacing: .3em; color: var(--muted); }
.display {
  margin: 0; font-family: var(--display); font-weight: 400;
  font-size: clamp(44px, 6.4vw, 92px); line-height: 1.08; letter-spacing: .005em;
  font-feature-settings: "palt";
}
.display span { display: block; }
.display .accent { color: var(--red); }

.index {
  list-style: none; margin: clamp(30px, 4vw, 44px) 0 0; padding: 0;
  display: grid; grid-template-columns: repeat(4, 1fr);
  border-top: 2px solid var(--ink); border-bottom: 1px solid var(--line);
}
.index li + li { border-left: 1px solid var(--line); }
.index a { display: block; padding: 14px 16px 16px; text-decoration: none; }
.index li:first-child a { padding-left: 0; }
.index a:hover .index__k { color: var(--red); }
.index__k { display: block; font-weight: 800; font-size: 16px; }
.index__v { display: block; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }

.hero__actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 30px; }

.hero__cover { margin: 0; justify-self: end; width: 100%; max-width: 470px; }
.cover-frame {
  display: block; width: 100%; padding: 12px; border: 0; cursor: zoom-in;
  background: var(--card); border-radius: 6px;
  box-shadow: 0 1px 0 rgba(0,0,0,.04), 0 18px 40px -18px rgba(70, 50, 25, .35), 0 0 0 1px rgba(26,24,21,.06);
}
.cover-frame img { width: 100%; height: auto; aspect-ratio: 1242 / 1656; object-fit: contain; border-radius: 2px; }
.hero__cover figcaption { margin-top: 14px; font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 10px; justify-content: center; }

.folio { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.folio b { display: inline-block; background: var(--ink); color: #fff; font-weight: 700; padding: 1px 9px; border-radius: 99px; margin-right: 2px; }

/* ---------- section heads ---------- */
.sec-no {
  margin: 0; font-family: var(--display); font-size: 15px; color: var(--red);
  letter-spacing: .1em; display: flex; align-items: center; gap: 10px;
}
.sec-no::after { content: ""; width: 34px; height: 2px; background: currentColor; }
.sec-title { margin: 8px 0 0; font-family: var(--display); font-weight: 400; font-size: clamp(30px, 3.6vw, 44px); line-height: 1.15; }
.sec-note { margin: 12px 0 0; color: var(--muted); font-size: 14px; line-height: 1.7; }

/* ---------- copy section ---------- */
.copy {
  max-width: var(--max); margin: 0 auto; padding: clamp(40px, 6vw, 80px) var(--pad) clamp(56px, 8vw, 110px);
  display: grid; grid-template-columns: minmax(0, 300px) minmax(0, 720px); justify-content: center;
  gap: clamp(28px, 6vw, 96px); align-items: start;
  border-top: 1px solid var(--line);
}
.copy__rail { position: sticky; top: 92px; }
.copy__btns { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 26px; }
.copy__btns .btn--ink { width: 100%; }
.status { min-height: 1.6em; margin: 12px 0 0; font-size: 14px; font-weight: 700; color: #2f7a4f; }
.status.is-fail { color: var(--red); }

.fallback { margin-top: 10px; padding: 14px; background: var(--card); border: 1.5px dashed var(--red); border-radius: 10px; }
.fallback__msg { margin: 0 0 10px; font-size: 14px; line-height: 1.6; color: var(--ink-2); }
.fallback textarea {
  width: 100%; resize: vertical; font: 14px/1.6 var(--sans); color: var(--ink);
  border: 1px solid var(--line); border-radius: 6px; padding: 10px; background: #fff;
}
.fallback .btn { margin-top: 10px; }

.paper {
  position: relative; background: var(--card); border-radius: 4px;
  padding: clamp(28px, 5vw, 60px) clamp(22px, 5vw, 64px) clamp(30px, 5vw, 56px);
  box-shadow: 0 0 0 1px rgba(26,24,21,.06), 0 24px 50px -30px rgba(70, 50, 25, .35);
}
.paper::before { /* masking-tape strip, echoing the polaroid tape on p06/p12 */
  content: ""; position: absolute; top: -12px; left: 50%; width: 120px; height: 24px; margin-left: -60px;
  background: rgba(196, 214, 232, .75); transform: rotate(-2deg);
}
.paper__tab {
  display: inline-block; font-size: 12px; font-weight: 700; letter-spacing: .25em;
  color: var(--muted); border: 1px solid var(--line); border-radius: 99px; padding: 1px 10px 1px 12px; margin-bottom: 14px;
}
.paper__head { padding-bottom: 26px; border-bottom: 2px solid var(--ink); }
.paper__title { margin: 0; font-size: clamp(22px, 2.6vw, 28px); line-height: 1.45; font-weight: 800; letter-spacing: .01em; }
.paper__body { padding: 30px 0 8px; font-size: 17px; line-height: 1.95; color: var(--ink-2); }
.paper__body p { margin: 0 0 1.15em; }
.paper__tags { padding-top: 22px; border-top: 1px solid var(--line); }
.tags { margin: 0; line-height: 2.3; font-size: 15px; }
.tag { display: inline-block; color: var(--blue); font-weight: 700; background: rgba(46, 82, 181, .08); border-radius: 99px; padding: 0 12px; line-height: 2; }

/* ---------- pages ---------- */
.pages {
  background: var(--paper-2);
  border-top: 1px solid var(--line);
  padding: clamp(48px, 7vw, 96px) 0 clamp(56px, 8vw, 110px);
}
.pages__head, .sheets { max-width: var(--max); margin-left: auto; margin-right: auto; padding-left: var(--pad); padding-right: var(--pad); }
.pages__head { display: grid; grid-template-columns: 1fr minmax(0, 420px); gap: 24px 48px; align-items: end; margin-bottom: clamp(28px, 4vw, 48px); }
.pages__head .sec-note { margin: 0; }

.sheets {
  list-style: none; margin-top: 0; margin-bottom: 0;
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: clamp(18px, 2.4vw, 32px) clamp(14px, 2vw, 26px);
}
.sheet { display: flex; flex-direction: column; min-width: 0; }
.sheet--cover { grid-column: span 2; grid-row: span 2; }
.sheet__open {
  display: block; width: 100%; padding: 8px; border: 0; cursor: zoom-in; background: var(--card); border-radius: 4px;
  box-shadow: 0 0 0 1px rgba(26,24,21,.07), 0 12px 26px -18px rgba(70, 50, 25, .45);
  transition: box-shadow .2s, transform .2s;
}
.sheet--cover .sheet__open { padding: 12px; }
.sheet__open:hover { box-shadow: 0 0 0 1px rgba(26,24,21,.14), 0 18px 34px -18px rgba(70, 50, 25, .55); transform: translateY(-2px); }
@media (prefers-reduced-motion: reduce) { .sheet__open { transition: none; } .sheet__open:hover { transform: none; } }
.sheet__open img { width: 100%; height: auto; aspect-ratio: 1242 / 1656; object-fit: contain; background: #efe9df; }
.sheet__meta { display: flex; align-items: center; gap: 8px; margin-top: 10px; font-size: 13px; }
.sheet__label { color: var(--ink-2); font-weight: 700; }
.sheet__dl { margin-left: auto; color: var(--muted); text-decoration: none; border-bottom: 1px solid currentColor; line-height: 1.3; white-space: nowrap; padding: 6px 0 2px; }
.sheet__dl:hover { color: var(--red); }
.sheet--cover .sheet__meta { font-size: 14px; }

/* ---------- footer ---------- */
.foot { background: var(--ink); color: #e9e1d4; text-align: center; padding: 34px var(--pad) 40px; }
.foot__mark { margin: 0; font-weight: 800; letter-spacing: .3em; font-size: 14px; }
.foot__mark span { color: var(--red); margin: 0 .6em; }
.foot__note { margin: 8px 0 0; font-size: 12px; color: #a59b8d; letter-spacing: .1em; }

/* ---------- viewer ---------- */
.viewer {
  width: 100vw; height: 100vh; height: 100dvh; max-width: none; max-height: none; margin: 0; padding: 0; border: 0;
  background: #171512; color: #f2ece2; overflow: hidden;
}
.viewer::backdrop { background: rgba(22, 20, 17, .7); }
.viewer[open] { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; }
.viewer__bar { display: flex; align-items: center; gap: 12px; padding: 12px clamp(12px, 3vw, 28px); padding-top: max(12px, env(safe-area-inset-top)); }
.viewer__count { font-variant-numeric: tabular-nums; font-weight: 700; letter-spacing: .06em; }
.viewer__tools { margin-left: auto; display: flex; gap: 8px; }
.vbtn {
  display: inline-flex; align-items: center; min-height: 40px; padding: 0 14px; border-radius: 99px;
  background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.22); color: #fff;
  font-size: 14px; text-decoration: none; cursor: pointer; white-space: nowrap;
}
.vbtn:hover, .vbtn[aria-pressed="true"] { background: #fff; color: var(--ink); }
.viewer__stage { position: relative; min-height: 0; display: flex; align-items: center; justify-content: center; padding: 4px clamp(8px, 7vw, 96px); overflow: hidden; touch-action: pan-y pinch-zoom; }
.viewer__stage img { max-width: 100%; max-height: 100%; width: auto; height: auto; object-fit: contain; border-radius: 2px; box-shadow: 0 20px 50px rgba(0,0,0,.45); }
.viewer__stage.is-actual { display: block; overflow: auto; text-align: center; -webkit-overflow-scrolling: touch; touch-action: auto; }
.viewer__stage.is-actual img { max-width: none; max-height: none; width: 1080px; height: auto; display: inline-block; margin: 0 auto; }
.viewer__nav {
  position: absolute; top: 50%; width: 52px; height: 52px; margin-top: -26px; border-radius: 50%;
  background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.25); color: #fff; font-size: 30px; line-height: 1; cursor: pointer;
}
.viewer__nav:hover { background: #fff; color: var(--ink); }
.viewer__nav--prev { left: clamp(8px, 2vw, 28px); }
.viewer__nav--next { right: clamp(8px, 2vw, 28px); }
.viewer__nav:disabled { opacity: .25; cursor: default; }
.viewer__dots { display: flex; justify-content: center; flex-wrap: wrap; gap: 6px; padding: 10px 12px 14px; padding-bottom: max(14px, env(safe-area-inset-bottom)); }
.viewer__dots button {
  min-width: 34px; height: 30px; border-radius: 99px; border: 1px solid rgba(255,255,255,.2); background: transparent; color: #cfc6b8;
  font-size: 12px; font-variant-numeric: tabular-nums; cursor: pointer;
}
.viewer__dots button[aria-current="true"] { background: var(--red); border-color: var(--red); color: #fff; }
body.is-locked { overflow: hidden; }

/* ---------- responsive ---------- */
@media (max-width: 1020px) {
  .sheets { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .copy { grid-template-columns: minmax(0, 1fr); }
  .copy__rail { position: static; }
  .copy__btns .btn--ink { width: auto; }
}
@media (max-width: 760px) {
  html { scroll-padding-top: 64px; }
  .mast__in { gap: 10px; padding-top: 8px; padding-bottom: 8px; }
  .mast__nav { display: none; }
  .mast__in .btn { margin-left: auto; }
  .hero { grid-template-columns: minmax(0, 1fr); }
  .bean--b { display: none; }
  .hero__cover { justify-self: center; max-width: 360px; }
  .index { grid-template-columns: repeat(2, 1fr); }
  .index li:nth-child(3) { border-left: 0; }
  .index li:nth-child(n+3) { border-top: 1px solid var(--line); }
  .index li:nth-child(3) a { padding-left: 0; }
  .hero__actions .btn { flex: 1 1 100%; }
  .copy__btns .btn--ink { width: 100%; }
  .copy__btns .btn--sm { flex: 1 1 calc(33% - 10px); padding: 0 8px; }
  .paper__body { font-size: 16px; line-height: 1.9; }
  .pages__head { grid-template-columns: minmax(0, 1fr); }
  .sheets { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sheet__meta { flex-wrap: wrap; row-gap: 0; }
  .sheet__label { display: none; }
  .sheet--cover .sheet__label { display: inline; }
  .viewer__stage { padding: 0 6px; }
  .viewer__nav { top: auto; bottom: max(10px, env(safe-area-inset-bottom)); margin-top: 0; width: 44px; height: 44px; font-size: 26px; }
  .viewer__dots { flex-wrap: nowrap; justify-content: flex-start; overflow-x: auto; margin: 0 60px; padding: 14px 2px 18px; padding-bottom: max(18px, env(safe-area-inset-bottom)); gap: 5px; scrollbar-width: none; }
  .viewer__dots::-webkit-scrollbar { display: none; }
  .viewer__dots button { flex: none; min-width: 34px; height: 30px; }
  .vbtn { padding: 0 11px; font-size: 13px; }
}
