:root {
  --desk: #2b2622;
  --desk-2: #221e1b;
  --paper: #f4efe4;
  --paper-shade: #e6dcc8;
  --ink: #1d1a16;
  --ink-soft: #5d564b;
  --ink-faint: #6b6352; /* 紙の上で読める濃さ（コントラスト比5:1以上） */
  --shu: #c0392b;
  --rule: #cfc4ad;
  --hl: #f2d6a2;
  --cloth: #6b1f1a;
  --cloth-dark: #4a1411;
  --gold: #d9b568;
  --on-desk: #d9d0bf;
  --mincho: "Shippori Mincho B1", "Hiragino Mincho ProN", "Yu Mincho", serif;
  --gothic: "Zen Kaku Gothic New", "Hiragino Sans", "Yu Gothic", sans-serif;
  --page-h: min(calc(100vh - 110px), 760px);
  --page-w: min(46vw, calc(var(--page-h) * 0.74), 520px);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --desk: #141210;
    --desk-2: #0c0b0a;
    --paper: #e9e2d3;
    --paper-shade: #d8ccb4;
  }
}

* { box-sizing: border-box; }

html, body { height: 100%; overflow: hidden; }

/* カーソルは自分の顔（中心が指す位置）。画像が使えないときは指の形 */
*, *::before, *::after {
  cursor: url("assets/cursor-32.png") 16 16, pointer !important;
  cursor: image-set(url("assets/cursor-32.png") 1x, url("assets/cursor-64.png") 2x) 16 16, pointer !important;
}

body {
  margin: 0;
  background: radial-gradient(ellipse at 50% 35%, var(--desk) 0%, var(--desk-2) 100%);
  color: var(--ink);
  font-family: var(--mincho);
  overflow-x: hidden;
}

.desk {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  min-height: 100%;
  padding: 24px 16px;
}

.stage { display: flex; justify-content: center; width: 100%; }

/* 本（中のめくりはライブラリが描く。表紙だけのときは表紙を中央に寄せる） */
.book {
  position: relative;
  width: min(calc(100vw - 72px), calc(var(--page-w) * 2));
  height: var(--page-h);
  transition: transform 0.8s cubic-bezier(0.4, 0.1, 0.2, 1);
}
.book.is-closed { transform: translateX(calc(var(--pw, var(--page-w)) / -2)); }
.book.is-back { transform: translateX(calc(var(--pw, var(--page-w)) / 2)); }
#flipbook { height: 100%; filter: drop-shadow(0 18px 30px rgba(0, 0, 0, 0.45)); }
.book.no-anim { transition: none; }

/* ページの厚み（小口に重なる紙） */
.book::before, .book::after {
  content: "";
  position: absolute;
  top: 4px;
  bottom: 4px;
  width: 7px;
  background: repeating-linear-gradient(90deg, var(--paper-shade) 0 1px, var(--paper) 1px 2px);
  z-index: -1;
  transition: opacity 0.4s;
}
.book::before { left: -5px; border-radius: 3px 0 0 3px; }
.book::after { right: -5px; border-radius: 0 3px 3px 0; }
.book.is-closed::before, .book.is-closed::after, .book.is-back::before, .book.is-back::after { opacity: 0; }

.page { background: var(--paper); overflow: hidden; }
/* 紙の目と、のどに向かう影 */
.flip-page {
  background-image:
    radial-gradient(circle at 1px 1px, rgba(120, 100, 60, 0.07) 1px, transparent 0),
    linear-gradient(var(--paper), var(--paper));
  background-size: 4px 4px, auto;
}
.flip-page.is-left {
  background-image:
    linear-gradient(to left, rgba(60, 40, 10, 0.24), rgba(60, 40, 10, 0.06) 22px, rgba(60, 40, 10, 0) 48px),
    radial-gradient(circle at 1px 1px, rgba(120, 100, 60, 0.07) 1px, transparent 0);
  background-size: auto, 4px 4px;
}
.flip-page.is-right {
  background-image:
    linear-gradient(to right, rgba(60, 40, 10, 0.24), rgba(60, 40, 10, 0.06) 22px, rgba(60, 40, 10, 0) 48px),
    radial-gradient(circle at 1px 1px, rgba(120, 100, 60, 0.07) 1px, transparent 0);
  background-size: auto, 4px 4px;
}

.page-inner {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 22px 34px 16px;
  font-size: 15px;
  line-height: 1.85;
}
.page-hashira {
  display: flex;
  justify-content: space-between;
  padding-bottom: 6px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--ink);
  font-family: var(--gothic);
  font-size: 11px;
  letter-spacing: 0.1em;
  color: var(--ink-soft);
}
.page-body {
  flex: 1;
  min-height: 0;
  overflow: hidden;
}
.fit { display: flex; flex-direction: column; }
/* 割り付けの計測用（画面には出さない） */
.page-probe, .flip-measure {
  position: absolute;
  top: 0;
  left: -99999px;
  visibility: hidden;
  pointer-events: none;
  /* 測るたびにページ全体のレイアウトをやり直さないよう、中だけで計算させる */
  contain: layout style paint;
}
.flip-page, .hard-page { contain: layout style paint; }
.nombre {
  margin-top: 8px;
  text-align: center;
  font-size: 12px;
  color: var(--ink-faint);
}

/* オープニング */
.intro {
  position: fixed;
  inset: 0;
  z-index: 100;
  overflow: hidden;
  background: radial-gradient(ellipse at 50% 35%, var(--desk) 0%, var(--desk-2) 100%);
  transition: opacity 0.5s;
}
.intro.is-done { opacity: 0; pointer-events: none; }
.no-intro .intro { display: none; }
.shelf-scene { position: absolute; inset: 0; transform-origin: var(--land-x, 50%) var(--land-y, 50%); }
.shelf {
  position: absolute;
  top: 9vh;
  left: 50%;
  width: min(880px, 94vw);
  transform: translateX(-50%);
  padding: 0 14px;
  background: linear-gradient(#1a1512, #241d18);
  box-shadow: inset 0 12px 24px rgba(0, 0, 0, 0.6);
}
.spines {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 2px;
  height: 32vh;
  padding-top: 16px;
}
.spine {
  position: relative;
  display: grid;
  place-items: center;
  flex: 0 0 var(--w);
  height: var(--h);
  background:
    linear-gradient(to right, rgba(0, 0, 0, 0.35), rgba(255, 255, 255, 0.06) 30%, rgba(0, 0, 0, 0.25)),
    var(--c);
  border-radius: 2px 2px 0 0;
  box-shadow: inset 0 6px 0 rgba(255, 255, 255, 0.05), inset 0 -10px 0 rgba(0, 0, 0, 0.18);
}
.spine i {
  writing-mode: vertical-rl;
  font-style: normal;
  font-size: clamp(9px, 1.4vh, 13px);
  letter-spacing: 0.2em;
  color: rgba(230, 220, 200, 0.55);
}
.spine.lean { transform: rotate(-4deg); transform-origin: bottom left; }
.spine.lean-r { transform: rotate(3deg); transform-origin: bottom right; }
.spine-me {
  flex: 0 0 7.5%;
  height: 92%;
  background:
    linear-gradient(to right, rgba(0, 0, 0, 0.4), rgba(255, 255, 255, 0.08) 30%, rgba(0, 0, 0, 0.3)),
    var(--cloth);
  z-index: 2;
}
.spine-me b {
  writing-mode: vertical-rl;
  font-size: clamp(11px, 1.9vh, 17px);
  letter-spacing: 0.25em;
  color: var(--gold);
}
.board {
  height: 16px;
  margin: 0 -14px;
  background: linear-gradient(#6b4a2f, #4a321f 60%, #2e1f13);
  box-shadow: 0 10px 18px rgba(0, 0, 0, 0.55);
}
.intro-cover {
  position: absolute;
  left: var(--land-x, 50%);
  top: var(--land-y, 50%);
  width: var(--cover-w, 300px);
  height: var(--cover-h, 420px);
  opacity: 0;
  transform: translate(-50%, -50%) perspective(900px) scale(var(--mini, 0.3)) rotateY(80deg);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
}
.intro-skip {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 18px;
  margin: 0;
  text-align: center;
  font-family: var(--gothic);
  font-size: 11px;
  letter-spacing: 0.2em;
  color: rgba(217, 208, 191, 0.45);
}

/* 1. 辞典が本棚から少し引き出され、傾いて落ちる（0.3〜1.65秒） */
@keyframes intro-drop {
  0% { transform: translate(0, 0) rotate(0); animation-timing-function: ease-out; }
  22% { transform: translate(0, -7%) scale(1.04); }
  34% { transform: translate(8px, -8%) rotate(5deg); animation-timing-function: cubic-bezier(0.55, 0, 1, 0.45); }
  74% { transform: translate(var(--dx), var(--dy)) rotate(-3deg); animation-timing-function: ease-out; }
  86% { transform: translate(var(--dx), calc(var(--dy) - 16px)) rotate(1deg); animation-timing-function: ease-in; }
  100% { transform: translate(var(--dx), var(--dy)) rotate(0); opacity: 1; }
}
/* 2. 落ちた本がこちらを向き（1.6秒〜）、3. 表紙へクローズアップする（2.1〜3.05秒） */
.intro.is-playing .spine-me { animation: intro-drop 1.35s 0.3s both, intro-hide 0.2s 1.62s both; }
@keyframes intro-hide { to { opacity: 0; } }
.intro.is-playing .intro-cover { animation: intro-face 1.45s 1.6s both; }
@keyframes intro-face {
  0% { opacity: 0; transform: translate(-50%, -50%) perspective(900px) scale(var(--mini)) rotateY(80deg); animation-timing-function: ease-out; }
  30% { opacity: 1; transform: translate(-50%, -50%) perspective(900px) scale(var(--mini)) rotateY(0); }
  38% { opacity: 1; transform: translate(-50%, -50%) perspective(900px) scale(var(--mini)) rotateY(0); animation-timing-function: cubic-bezier(0.6, 0, 0.3, 1); }
  100% { opacity: 1; transform: translate(-50%, -50%) perspective(900px) scale(1) rotateY(0); }
}
.intro.is-playing .shelf-scene { animation: intro-push 0.95s 2.1s cubic-bezier(0.6, 0, 0.3, 1) both; }
@keyframes intro-push {
  to { transform: scale(2.6); filter: blur(6px); opacity: 0; }
}

/* 組み立てる前の仮の表紙 */
.cover-placeholder { position: absolute; top: 0; right: 0; width: var(--page-w); height: 100%; }

/* 表紙と裏表紙（布張りの硬い紙） */
.hard-inner { display: flex; height: 100%; padding: 26px; }
.hard-page {
  background:
    repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.025) 0 2px, transparent 2px 4px),
    linear-gradient(to right, var(--cloth-dark), var(--cloth) 14px);
  box-shadow: inset 4px 0 8px rgba(0, 0, 0, 0.35);
}
.back-page {
  background:
    repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.025) 0 2px, transparent 2px 4px),
    linear-gradient(to left, var(--cloth-dark), var(--cloth) 14px);
}
.back-frame {
  flex: 1;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 28px;
  border: 1px solid rgba(217, 181, 104, 0.5);
  color: var(--gold);
  font-family: var(--gothic);
  font-size: 10px;
  letter-spacing: 0.35em;
  opacity: 0.8;
}
.cover-frame {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  border: 1px solid var(--gold);
  outline: 1px solid var(--gold);
  outline-offset: 5px;
  color: var(--gold);
  text-align: center;
}
.cover-small { font-family: var(--gothic); font-size: 12px; letter-spacing: 0.5em; }
.cover-title {
  font-size: clamp(34px, 5vw, 50px);
  font-weight: 800;
  line-height: 1.35;
  letter-spacing: 0.08em;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.4);
}
.cover-sub { font-family: var(--gothic); font-size: 10px; letter-spacing: 0.35em; opacity: 0.8; }
.cover-hint {
  margin-top: 24px;
  padding: 4px 18px;
  border: 1px solid var(--gold);
  font-size: 13px;
  letter-spacing: 0.4em;
  animation: breathe 2.4s ease-in-out infinite;
}
@keyframes breathe { 50% { opacity: 0.45; } }

/* つめ */
.tsume {
  position: absolute;
  right: -34px;
  top: 40px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 30;
  transition: opacity 0.4s 0.6s;
}
.book.is-closed .tsume, .is-closed-page .tsume, .is-closed-page .ribbon { opacity: 0; pointer-events: none; }
.tsume button {
  width: 30px;
  height: 54px;
  border: 0;
  border-radius: 0 6px 6px 0;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--mincho);
  font-weight: 800;
  font-size: 15px;
  cursor: pointer;
  transform: translateX(-4px);
  transition: transform 0.2s, background 0.2s;
}
.tsume button:hover { transform: translateX(0); }
.tsume button.is-current { background: var(--shu); transform: translateX(2px); }

/* 操作 */
.controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px 16px;
  color: var(--on-desk);
  font-family: var(--gothic);
  font-size: 13px;
  transition: opacity 0.5s 0.6s;
}
.is-closed-page .controls { opacity: 0; pointer-events: none; }
.turn {
  padding: 4px 12px;
  border: 1px solid rgba(217, 208, 191, 0.4);
  background: transparent;
  color: var(--on-desk);
  font: inherit;
  cursor: pointer;
}
.turn:hover:not([disabled]) { border-color: var(--on-desk); }
.turn[disabled] { opacity: 0.3; cursor: default; }
.count { min-width: 64px; text-align: center; letter-spacing: 0.1em; }
.hiku { display: flex; align-items: center; gap: 10px; }
.hiku label { letter-spacing: 0.1em; opacity: 0.8; }
.hiku-box { position: relative; }
.hiku input {
  width: 200px;
  padding: 4px 2px;
  border: 0;
  border-bottom: 1px solid rgba(217, 208, 191, 0.6);
  background: transparent;
  color: var(--on-desk);
  font: inherit;
  outline: none;
}
.hiku input:focus { border-bottom-color: var(--gold); }
.hiku-results {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 100%;
  z-index: 60;
  margin: 0 0 4px;
  padding: 4px 0;
  list-style: none;
  background: var(--paper);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}
.hiku-results button {
  display: block;
  width: 100%;
  padding: 6px 10px;
  border: 0;
  background: none;
  color: var(--ink);
  font-family: var(--mincho);
  font-size: 14px;
  text-align: left;
  cursor: pointer;
}
.hiku-results button:hover, .hiku-results button.active { background: var(--hl); }
.hiku-results .none { padding: 6px 10px; color: var(--ink-faint); }

/* ページの中の部品（辞書の組み） */
.entry { position: relative; padding: 0 0 18px 24px; margin-bottom: 18px; border-bottom: 1px dotted var(--rule); }
.entry:last-child { border-bottom: 0; }
.entry.flash { animation: flash 1.6s ease; }
@keyframes flash { 0%, 35% { background: var(--hl); } 100% { background: transparent; } }

.midashi { margin: 0 0 2px -24px; font-size: 21px; font-weight: 800; line-height: 1.6; }
.midashi::before { content: "■"; color: var(--shu); font-size: 0.6em; margin-right: 0.5em; vertical-align: 0.25em; }
.midashi rt { font-family: var(--gothic); font-size: 9px; font-weight: 400; letter-spacing: 0.12em; color: var(--ink-faint); }
.hyoki { font-weight: 600; font-size: 0.8em; }
.entry-main { padding-top: 24px; }
.entry-main .midashi { font-size: clamp(30px, 4vw, 42px); }
.entry-main .midashi::before { font-size: 0.35em; vertical-align: 0.5em; }
.entry-main .hyoki { display: block; font-size: 0.5em; margin-top: 2px; }
.entry-new .midashi::before { content: "★"; }

.hinshi { margin: 0 0 6px; font-family: var(--gothic); font-size: 12px; }
.kakko { color: var(--shu); font-weight: 700; }
.label { display: inline-block; margin-left: 6px; padding: 0 6px; border: 1px solid var(--ink); font-size: 10px; line-height: 1.7; }
.fuku { margin-left: 10px; color: var(--ink-soft); font-family: var(--mincho); }

.gogi { margin: 0 0 6px; padding: 0; list-style: none; counter-reset: gogi; }
.gogi li { position: relative; padding-left: 1.7em; counter-increment: gogi; }
.gogi li::before {
  position: absolute;
  left: 0;
  top: 0.34em;
  display: grid;
  place-items: center;
  width: 1.2em;
  height: 1.2em;
  background: var(--ink);
  color: var(--paper);
  border-radius: 50%;
  font-family: var(--gothic);
  font-size: 0.72em;
  line-height: 1;
  content: counter(gogi);
}
.gogi em { font-style: normal; background: linear-gradient(transparent 62%, var(--hl) 62%); }

.mark { display: inline-block; margin-right: 8px; padding: 0 5px; background: var(--ink); color: var(--paper); font-family: var(--gothic); font-size: 10px; line-height: 1.8; vertical-align: 0.1em; }
.mark-tai { background: transparent; color: var(--ink); border: 1px solid var(--ink); }
.mark-chu { background: transparent; color: var(--shu); border: 1px solid var(--shu); }

.youre { margin: 4px 0; color: var(--ink-soft); }
.youre b { color: var(--shu); font-weight: 800; }
.youre-next { margin-left: 8px; padding: 0; border: 0; border-bottom: 1px solid currentColor; background: none; color: var(--ink-faint); font-family: var(--gothic); font-size: 10px; cursor: pointer; }
.youre-next:hover { color: var(--shu); }
.youre-text { transition: opacity 0.2s; }
.youre-text.swap { opacity: 0; }
.rui { margin: 4px 0 0; color: var(--ink-soft); }
.chu { margin: 4px 0 0; color: var(--ink-soft); font-size: 13px; }
.guide { margin: 28px 0 0; font-family: var(--gothic); font-size: 11px; color: var(--ink-faint); text-align: center; }

.bu { display: flex; align-items: center; gap: 12px; margin: 4px 0 18px; font-size: 13px; font-weight: 600; letter-spacing: 0.6em; }
.bu::before, .bu::after { content: ""; flex: 1; height: 1px; background: var(--ink); }

.zuhan { margin: 10px 0 4px; }
.zuhan-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.shot { padding: 0; border: 1px solid var(--ink); background: none; cursor: zoom-in; filter: grayscale(0.85) contrast(1.05); transition: filter 0.3s; }
.shot:hover, .shot:focus-visible { filter: none; }
.shot img { display: block; width: 100%; height: auto; aspect-ratio: 16 / 9; object-fit: cover; }
.zuhan figcaption { margin-top: 3px; font-family: var(--gothic); font-size: 10px; color: var(--ink-faint); }

.play { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; margin: 8px 0 0; }
.play-btn { padding: 3px 12px; border: 1px solid var(--shu); background: transparent; color: var(--shu); font-family: var(--mincho); font-weight: 800; font-size: 14px; cursor: pointer; transition: background 0.2s, color 0.2s; }
.play-btn:hover:not([disabled]) { background: var(--shu); color: var(--paper); }
.play-btn[disabled] { border-color: var(--ink-faint); color: var(--ink-faint); cursor: not-allowed; }
.play .chu { margin: 0; font-size: 11px; }

.sanshou { margin: 0 0 0 24px; font-size: 18px; }
.sanshou a { color: var(--ink); text-decoration-color: var(--shu); text-underline-offset: 4px; }
.sanshou a:hover { color: var(--shu); }
.sakuin { margin: 32px 0 0; padding: 14px 0 0; border-top: 3px double var(--ink); }
.sakuin-title { margin: 0 0 8px; font-size: 12px; font-family: var(--gothic); letter-spacing: 0.4em; }
.sakuin ul, .mokuji { margin: 0; padding: 0; list-style: none; }
/* 目次とさくいん：見出しとページ番号を点線でつなぐ */
.sakuin button, .mokuji button {
  display: flex;
  align-items: baseline;
  width: 100%;
  gap: 6px;
  padding: 3px 0;
  border: 0;
  background: none;
  color: var(--ink-soft);
  font-family: var(--mincho);
  font-size: 14px;
  text-align: left;
  cursor: pointer;
}
.sakuin button::after, .mokuji button::after { content: ""; order: 1; flex: 1; border-bottom: 1px dotted var(--ink-faint); }
.sakuin button i, .mokuji button i { order: 2; font-style: normal; color: var(--ink-faint); font-size: 12px; }
.sakuin button:hover, .mokuji button:hover { color: var(--shu); }
.mokuji { margin-top: 10px; }
.mokuji button { font-size: 15px; padding: 5px 0; }
.mokuji-bu { margin: 14px 0 2px; font-family: var(--gothic); font-size: 11px; letter-spacing: 0.4em; color: var(--shu); }

.small-title { margin: 0 0 8px; font-size: 12px; font-family: var(--gothic); font-weight: 700; letter-spacing: 0.4em; }
.small-title.center { text-align: center; margin-top: 12px; font-size: 14px; letter-spacing: 0.8em; }

/* 扉と凡例 */
.tobira { display: flex; flex-direction: column; align-items: center; padding: 44px 0 36px; border-bottom: 3px double var(--ink); margin-bottom: 22px; }
.tobira-ed { margin: 0; font-family: var(--gothic); font-size: 11px; letter-spacing: 0.5em; color: var(--ink-faint); }
.tobira-title { margin: 10px 0 6px; font-size: 30px; font-weight: 800; letter-spacing: 0.12em; }
.tobira-by { margin: 0; font-size: 13px; color: var(--ink-soft); }
.hanrei dl { display: grid; grid-template-columns: 56px 1fr; gap: 6px 10px; margin: 0; font-size: 13px; }
.hanrei dt { text-align: center; }
.hanrei dd { margin: 0; color: var(--ink-soft); }
.sq { color: var(--shu); }
.num { display: inline-grid; place-items: center; width: 1.3em; height: 1.3em; border-radius: 50%; background: var(--ink); color: var(--paper); font-family: var(--gothic); font-size: 11px; }

/* 語源・使用上の注意 */
.gogen { margin: 6px 0; color: var(--ink-soft); }
.chui-list { margin: 6px 0 10px; padding: 0; list-style: none; }
.chui-list li { position: relative; padding: 0 0 8px 1.3em; font-size: 14px; color: var(--ink-soft); }
.chui-list li::before { content: "▲"; position: absolute; left: 0; top: 0.15em; color: var(--shu); font-size: 0.7em; }
.chui-list b { color: var(--ink); }
.suki { margin: 4px 0 0; color: var(--ink-soft); font-size: 14px; }

/* 年表 */
.nenpyo { display: grid; grid-template-columns: 58px 1fr; margin: 0; font-size: 13.5px; line-height: 1.75; }
.nenpyo dt {
  grid-column: 1;
  padding: 6px 8px 6px 0;
  font-family: var(--gothic);
  font-weight: 700;
  font-size: 12px;
  color: var(--shu);
  text-align: right;
}
.nenpyo dd { grid-column: 2; margin: 0; padding: 6px 0 6px 12px; border-left: 1px solid var(--ink); border-bottom: 1px dotted var(--rule); color: var(--ink-soft); }
.nenpyo dt + dd { position: relative; }
/* 年表の丸：縦線（1pxの左罫）の真ん中と、1行目の文字の高さの真ん中にそろえる */
.nenpyo dt + dd::before {
  content: "";
  position: absolute;
  left: -0.5px;
  top: calc(6px + 0.875em);
  width: 9px;
  height: 9px;
  box-sizing: border-box;
  border-radius: 50%;
  background: var(--paper);
  border: 1.5px solid var(--ink);
  transform: translate(-50%, -50%);
}
.nenpyo dd + dd { grid-column: 2; }
.nenpyo dd:has(+ dd) { border-bottom: 0; }
.nenpyo b { color: var(--ink); }
.tsuzuku { margin-left: 6px; color: var(--ink-faint); font-size: 12px; }

/* 見返し */
.mikaeshi { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; flex: 1; color: var(--ink-faint); letter-spacing: 0.6em; }
.mikaeshi p { margin: 0; }
.back-to-top { padding: 4px 14px; border: 1px solid var(--ink-faint); background: none; color: var(--ink-soft); font-family: var(--gothic); font-size: 12px; letter-spacing: 0.2em; cursor: pointer; }
.back-to-top:hover { border-color: var(--shu); color: var(--shu); }

/* ページの角のめくれ（めくれることを知らせる） */
.peel {
  position: absolute;
  bottom: 0;
  z-index: 35;
  width: 34px;
  height: 34px;
  cursor: pointer;
  transition: width 0.25s ease, height 0.25s ease, opacity 0.3s;
}
.peel-next { right: 0; background: linear-gradient(315deg, transparent 50%, var(--paper-shade) 50%, #fbf8f1 75%); box-shadow: -3px -3px 6px rgba(0, 0, 0, 0.15); border-radius: 0 0 4px 0; }
.peel-prev { left: 0; background: linear-gradient(45deg, transparent 50%, var(--paper-shade) 50%, #fbf8f1 75%); box-shadow: 3px -3px 6px rgba(0, 0, 0, 0.15); border-radius: 0 0 0 4px; }
.peel:hover { width: 56px; height: 56px; }
.peel.is-hidden, .book.is-closed .peel { opacity: 0; pointer-events: none; }

/* しおりのひも */
/* 本文に重ならないよう、ページの下からはみ出した先だけを見せる */
.ribbon {
  position: absolute;
  bottom: -30px;
  right: 18%;
  z-index: -1;
  width: 10px;
  height: 40px;
  background: linear-gradient(to right, #8e1f17, var(--shu) 45%, #8e1f17);
  clip-path: polygon(0 0, 100% 0, 100% 100%, 50% calc(100% - 7px), 0 100%);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
  pointer-events: none;
  transition: opacity 0.4s 0.8s;
}
.book.is-closed .ribbon { opacity: 0; transition-delay: 0s; }

/* 初回だけのめくり方の案内 */
.toast {
  position: absolute;
  left: 50%;
  bottom: 24px;
  z-index: 45;
  margin: 0;
  padding: 6px 16px;
  background: rgba(29, 26, 22, 0.88);
  color: var(--paper);
  font-family: var(--gothic);
  font-size: 12px;
  letter-spacing: 0.05em;
  white-space: nowrap;
  transform: translate(-50%, 8px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s, transform 0.4s;
}
.toast.is-shown { opacity: 1; transform: translate(-50%, 0); }

.cover-resume {
  padding: 2px 4px;
  border: 0;
  border-bottom: 1px solid rgba(217, 181, 104, 0.6);
  background: none;
  color: var(--gold);
  font-family: var(--gothic);
  font-size: 11px;
  letter-spacing: 0.2em;
}
.cover-resume:hover { text-decoration: underline; }

/* キーボードで操作するときの目印 */
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.page :focus-visible { outline-color: var(--shu); }

.okuzuke { display: flex; flex-direction: column; justify-content: flex-end; flex: 1; padding-bottom: 20px; font-family: var(--gothic); font-size: 12px; color: var(--ink-soft); }
.okuzuke-title { margin: 0 0 10px; padding-bottom: 8px; border-bottom: 1px solid var(--ink); font-family: var(--mincho); font-size: 18px; font-weight: 800; color: var(--ink); }
.okuzuke dl { display: grid; grid-template-columns: auto 1fr; gap: 2px 16px; margin: 0; }
.okuzuke dt { color: var(--ink-faint); }
.okuzuke dd { margin: 0; }
.okuzuke-note { margin: 14px 0 0; font-size: 11px; color: var(--ink-faint); }

/* ダイアログ */
dialog { border: 0; padding: 0; background: transparent; }
dialog::backdrop { background: rgba(10, 8, 6, 0.85); }
.viewer img { display: block; max-width: 92vw; max-height: 86vh; border: 1px solid var(--paper); }
.game-dialog { width: min(1280px, 96vw); }
.game-bar { display: flex; justify-content: space-between; align-items: center; padding: 8px 12px; background: var(--paper); color: var(--ink); font-weight: 800; }
.game-bar button { border: 1px solid var(--ink); background: none; color: var(--ink); font-family: var(--gothic); cursor: pointer; }
.game-dialog iframe { display: block; width: 100%; aspect-ratio: 16 / 9; border: 0; background: #000; }

/* スマホ：1ページずつ */
@media (max-width: 899px) {
  :root {
    --page-w: min(calc(100vw - 72px), 460px);
    --page-h: min(calc(100svh - 130px), 720px);
  }
  /* 本の幅をページ1枚分にすると、ライブラリが1ページずつの表示に切り替える */
  .book { width: var(--page-w); }
  .book.is-closed, .book.is-back { transform: none; }
  .book::before { display: none; }
  .flip-page.is-left, .flip-page.is-right {
    background-image:
      linear-gradient(to right, rgba(60, 40, 10, 0.18), rgba(60, 40, 10, 0) 24px),
      radial-gradient(circle at 1px 1px, rgba(120, 100, 60, 0.07) 1px, transparent 0);
  }
  .page-inner { padding: 18px 20px 12px; font-size: 14px; }
  .tsume { right: -28px; }
  .tsume button { width: 26px; height: 46px; font-size: 13px; }
  .hiku input { width: 160px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* 柱は1行に収め、長い見出しは「…」で切る */
.page-hashira { gap: 12px; white-space: nowrap; }
.page-hashira span { min-width: 0; overflow: hidden; text-overflow: ellipsis; }

/* ボタンの中の文字や画像を押しても、ボタン自身が押されたことにする（めくりのライブラリが中の要素を見て判断するため） */
.page button * { pointer-events: none; }

/* 続きのページのさくいんには、区切りの罫を引かない */
.sakuin.entry-cont, .sakuin.is-cont { border-top: 0; margin-top: 0; padding-top: 0; }

/* 表紙の「めくる」はボタン */
button.cover-hint { background: none; color: var(--gold); font-family: var(--mincho); }
button.cover-hint:hover { background: rgba(217, 181, 104, 0.12); }

/* 画面には出さず、読み上げにだけ伝える */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --shu: #b03224; --ink-faint: #6b6352; }
}

/* 挿絵：見出し語の右に回り込ませる */
.sashie { float: right; width: 24%; max-width: 104px; margin: 8px 0 6px 12px; text-align: center; }
.sashie img { display: block; width: 100%; height: auto; }
.sashie figcaption { margin-top: 2px; font-family: var(--gothic); font-size: 9px; line-height: 1.4; color: var(--ink-faint); }
.entry-main::after { content: ""; display: block; clear: both; }
.mikaeshi .mikaeshi-sub { margin-top: -8px; font-size: 11px; letter-spacing: 0.2em; }

/* 言語の切り替え */
.lang-switch { display: flex; gap: 2px; margin-left: 8px; }
.lang-switch button {
  padding: 3px 8px;
  border: 1px solid rgba(217, 208, 191, 0.3);
  background: transparent;
  color: var(--on-desk);
  font-family: var(--gothic);
  font-size: 11px;
  opacity: 0.75;
}
.lang-switch button[aria-pressed="true"] { border-color: var(--gold); color: var(--gold); opacity: 1; }
.lang-switch button:hover { opacity: 1; }

/* 韓国語：ハングルの明朝体とゴシック体を先に使う */
:root[data-lang="ko"] {
  --mincho: "Nanum Myeongjo", "Shippori Mincho B1", "Batang", serif;
  --gothic: "Gothic A1", "Zen Kaku Gothic New", "Malgun Gothic", sans-serif;
}
:root[data-lang="ko"] .gogi, :root[data-lang="ko"] .chui-list, :root[data-lang="ko"] .nenpyo { word-break: keep-all; }

/* 英語：字間を詰め、長い表紙の書名を小さめに */
:root[data-lang="en"] .bu { letter-spacing: 0.25em; }
:root[data-lang="en"] .cover-title { font-size: clamp(26px, 3.6vw, 38px); letter-spacing: 0.02em; }
:root[data-lang="en"] .tobira-title { letter-spacing: 0.02em; }
:root[data-lang="en"] .small-title { letter-spacing: 0.25em; }
:root[data-lang="en"] .page-inner, :root[data-lang="ko"] .page-inner { line-height: 1.7; }
:root[data-lang="en"] .gogi, :root[data-lang="en"] .chu, :root[data-lang="en"] .youre { hyphens: auto; }
/* 凡例：記号の欄は中身に合わせて広げる（英語の〔embellished〕などが説明と重ならないように） */
.hanrei dl { grid-template-columns: minmax(56px, max-content) 1fr; }

/* 中国語（簡体字）：中国語の明朝体とゴシック体を先に使う */
:root[data-lang="zh"] {
  --mincho: "Noto Serif SC", "Shippori Mincho B1", "SimSun", serif;
  --gothic: "Noto Sans SC", "Zen Kaku Gothic New", "Microsoft YaHei", sans-serif;
}
