.sfb-wrapper {
	max-width: 900px;
	margin: 0 auto 40px;
	padding: 0 16px;
}

.sfb-title {
	text-align: center;
	margin-bottom: 16px;
}

.sfb-book {
	margin: 0 auto;
	touch-action: pan-y;
	cursor: zoom-in; /* 紙面の中央付近をクリックすると拡大表示（はしっこはページめくり） */
}

/* 目次（サムネイル一覧）。開閉ボタンは紙面の外（本の上）に置き、紙面には重ねない。 */
.sfb-toc-toolbar {
	display: flex;
	justify-content: flex-start;
	max-width: 900px;
	margin: 0 auto 8px;
}

.sfb-toc-toggle {
	background: #fff;
	border: 1px solid #ccc;
	border-radius: 4px;
	padding: 6px 12px;
	font-size: 13px;
	cursor: pointer;
	color: #333;
}

.sfb-toc-toggle:hover {
	background: #f5f5f5;
}

.sfb-stage {
	position: relative;
}

/* パネル自体は本に重ねて表示するオーバーレイ（開いている間だけ、本の左側にかぶさる）。 */
.sfb-toc-panel {
	position: absolute;
	top: 0;
	left: 0;
	bottom: 0;
	width: 140px;
	background: rgba(30, 30, 30, 0.9);
	overflow-y: auto;
	padding: 8px;
	display: none;
	flex-direction: column;
	gap: 10px;
	z-index: 15;
}

.sfb-toc-panel.is-open {
	display: flex;
}

.sfb-toc-item {
	cursor: pointer;
	text-align: center;
}

.sfb-toc-item img {
	width: 100%;
	height: auto;
	display: block;
	border: 2px solid transparent;
	border-radius: 2px;
	margin-bottom: 4px;
	background: #fff;
}

.sfb-toc-item span {
	display: block;
	font-size: 11px;
	color: #ddd;
	line-height: 1.3;
}

.sfb-toc-item:hover img {
	border-color: #7fd1a3;
}

.sfb-toc-item.is-active img {
	border-color: #2fae66;
}

.sfb-toc-item.is-active span {
	color: #fff;
	font-weight: bold;
}

@media (max-width: 700px) {
	.sfb-toc-panel {
		width: 100px;
	}
}

/* 拡大表示（ライトボックス）。JSが1つだけ生成し、全ての号で使い回す。 */
.sfb-lightbox {
	position: fixed;
	inset: 0;
	background: rgba(0, 0, 0, 0.88);
	display: none;
	align-items: center;
	justify-content: center;
	z-index: 100000;
	padding: 24px;
}

.sfb-lightbox.is-open {
	display: flex;
}

.sfb-lightbox-imgs {
	display: flex;
	gap: 4px;
	max-width: 100%;
	max-height: 100%;
	overflow: auto; /* クリックで拡大した画像がはみ出す分をスクロールで見られるようにする */
}

.sfb-lightbox-imgs img {
	max-width: 100%;
	max-height: 90vh;
	object-fit: contain;
	background: #fff;
	cursor: zoom-in; /* クリックで2段階拡大→3回目で原寸に戻る */
	transition: width 0.15s ease;
	-webkit-user-drag: none; /* ブラウザ標準の画像ドラッグと、手でつかんで動かす操作が競合しないように */
	user-select: none; /* ドラッグ中に文字選択されてしまうのを防ぐ */
}

.sfb-lightbox-imgs img.sfb-zoomed {
	cursor: grab; /* 拡大中は「つかんで動かす」ことを示すカーソルにする（ドラッグ中はJSでgrabbingに切り替え） */
	/* flexboxのデフォルト（縮小・高さの引き伸ばし）を止めて、指定した拡大サイズがそのまま反映されるようにする。
	   これが無いと、拡大用に広げたwidthがflexboxに縮められて戻され、
	   かつ高さだけコンテナに合わせて伸ばされてobject-fit:containの余白（白い帯）が
	   左右にできてしまい、見た目上「拡大されず白幅だけ増える」状態になる。 */
	flex: none;
	align-self: flex-start;
}

.sfb-lightbox-close {
	position: absolute;
	top: 16px;
	right: 20px;
	width: 40px;
	height: 40px;
	display: flex;
	align-items: center;
	justify-content: center;
	/* 拡大した画像の白い背景が×の裏に来ても見えるよう、常に暗い丸背景を敷いておく */
	background: rgba(0, 0, 0, 0.6);
	border: none;
	border-radius: 50%;
	color: #fff;
	font-size: 26px;
	line-height: 1;
	cursor: pointer;
	z-index: 20; /* 拡大表示中の画像より必ず手前に表示する */
}

.sfb-lightbox-close:hover {
	background: rgba(0, 0, 0, 0.8);
}

@media (max-width: 700px) {
	.sfb-lightbox-imgs {
		flex-direction: column;
	}

	.sfb-lightbox-imgs img {
		max-height: 45vh;
	}
}
