.wcpsv-wrapper {
	position: relative;
	max-width: 900px;
	margin: 0 auto;
	background: #f0f0f1;
	border: 1px solid #ddd;
	border-radius: 6px;
	overflow: hidden;
	user-select: none; /* ลดโอกาสลาก/ก็อปข้อความง่ายๆ */
}

.wcpsv-toolbar {
	position: sticky;
	top: 0;
	z-index: 10;
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 8px 12px;
	background: #23282d;
	color: #fff;
}

.wcpsv-toolbar button {
	cursor: pointer;
	background: #333;
	color: #fff;
	border: none;
	border-radius: 4px;
	width: 28px;
	height: 28px;
	font-size: 16px;
	line-height: 1;
}

.wcpsv-toolbar button:hover {
	background: #444;
}

.wcpsv-page-info {
	font-size: 13px;
	opacity: 0.8;
}

.wcpsv-page-info:empty {
	display: none;
}

.wcpsv-toolbar .wcpsv-toc-btn {
	width: auto;
	padding: 0 10px;
	font-size: 13px;
	white-space: nowrap;
}

.wcpsv-toc-btn[hidden],
.wcpsv-page-jump[hidden],
.wcpsv-toc[hidden],
.wcpsv-toc-backdrop[hidden],
.wcpsv-toast[hidden] {
	display: none;
}

.wcpsv-chapter-name {
	flex: 1 1 auto;
	min-width: 0;
	margin-left: 6px;
	font-size: 13px;
	opacity: 0.75;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.wcpsv-page-jump {
	margin-left: auto;
	display: inline-flex;
	align-items: center;
	gap: 6px;
	font-size: 13px;
	white-space: nowrap;
}

.wcpsv-page-input {
	width: 52px;
	height: 28px;
	padding: 0 4px;
	box-sizing: border-box;
	text-align: center;
	font-size: 14px;
	color: #fff;
	background: #333;
	border: 1px solid #555;
	border-radius: 4px;
	user-select: text;
	-webkit-user-select: text;
}

.wcpsv-page-input:focus {
	outline: none;
	border-color: #8ab4f8;
}

/* สารบัญ */
.wcpsv-toc-backdrop {
	position: absolute;
	left: 0;
	right: 0;
	bottom: 0;
	background: rgba(0, 0, 0, 0.35);
	z-index: 19;
}

.wcpsv-toc {
	position: absolute;
	left: 0;
	bottom: 0;
	z-index: 20;
	display: flex;
	flex-direction: column;
	width: min(340px, 88%);
	background: #fff;
	color: #222;
	box-shadow: 2px 0 12px rgba(0, 0, 0, 0.25);
}

.wcpsv-toc-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 10px 14px;
	border-bottom: 1px solid #e5e5e5;
	font-size: 15px;
}

.wcpsv-toc-close {
	cursor: pointer;
	width: 28px;
	height: 28px;
	border: none;
	border-radius: 50%;
	background: #eee;
	font-size: 18px;
	line-height: 1;
}

.wcpsv-toc-list {
	flex: 1 1 auto;
	position: relative;
	margin: 0;
	padding: 6px 0;
	list-style: none;
	overflow-y: auto;
}

.wcpsv-toc-li {
	margin: 0;
	padding: 0;
}

.wcpsv-toc-item {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: 12px;
	width: 100%;
	padding: 9px 14px;
	border: none;
	border-left: 3px solid transparent;
	background: transparent;
	color: inherit;
	text-align: left;
	font: inherit;
	font-size: 14px;
	line-height: 1.4;
	cursor: pointer;
}

.wcpsv-toc-level-2 .wcpsv-toc-item {
	padding-left: 30px;
	font-size: 13px;
	color: #555;
}

.wcpsv-toc-item:hover {
	background: #f3f3f3;
}

.wcpsv-toc-item.is-active {
	border-left-color: #2271b1;
	background: #eaf2fa;
	font-weight: 600;
	color: #1a4f7a;
}

.wcpsv-toc-item.is-locked {
	color: #999;
}

.wcpsv-toc-pg {
	flex: none;
	font-size: 12px;
	color: #888;
}

/* แจ้ง "อ่านต่อจากหน้า X" */
.wcpsv-toast {
	position: absolute;
	left: 50%;
	bottom: 16px;
	transform: translateX(-50%);
	z-index: 15;
	display: flex;
	align-items: center;
	gap: 10px;
	max-width: calc(100% - 24px);
	padding: 8px 10px 8px 16px;
	border-radius: 999px;
	background: #23282d;
	color: #fff;
	font-size: 13px;
	box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
}

.wcpsv-toast button {
	cursor: pointer;
	flex: none;
	padding: 4px 12px;
	border: none;
	border-radius: 999px;
	background: #3c434a;
	color: #fff;
	font-size: 12px;
}

.wcpsv-toast button:hover {
	background: #50575e;
}

.wcpsv-toast .wcpsv-toast-x {
	padding: 0;
	width: 24px;
	height: 24px;
	font-size: 16px;
	line-height: 1;
	background: transparent;
}

@media (max-width: 600px) {
	.wcpsv-chapter-name,
	.wcpsv-toc-btn-label {
		display: none;
	}

	.wcpsv-page-input {
		font-size: 16px; /* กัน iOS ซูมหน้าเองตอนแตะช่องกรอก */
	}
}

.wcpsv-loading {
	padding: 40px;
	text-align: center;
	color: #555;
}

.wcpsv-pages {
	position: relative; /* ให้ offsetTop ของแต่ละหน้าอ้างอิงกล่องนี้ (ใช้คำนวณหน้าที่กำลังอ่าน) */
	max-height: 80vh;
	overflow-y: auto;
	padding: 16px 0;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 16px;
}

.wcpsv-page {
	flex: none;
	max-width: 100%;
	box-shadow: 0 1px 4px rgba(0,0,0,0.25);
	background: #fff;
}

.wcpsv-page-canvas {
	display: block;
	width: 100%;
	height: 100%;
	pointer-events: none; /* กันลาก/คลิกขวาบนตัว canvas โดยตรง */
}

.wcpsv-preview-banner {
	max-width: 900px;
	margin: 0 auto 10px;
	padding: 10px 14px;
	background: #fff3cd;
	border: 1px solid #ffe69c;
	border-radius: 6px;
	font-size: 14px;
	color: #664d03;
	text-align: center;
}

.wcpsv-buy-cta {
	width: 100%;
	max-width: 600px;
	padding: 28px 20px;
	text-align: center;
	background: #fff;
	border: 2px dashed #ccc;
	border-radius: 8px;
}

.wcpsv-buy-cta p {
	margin: 0 0 14px;
	font-size: 16px;
	color: #444;
}

.wcpsv-buy-button {
	display: inline-block;
	padding: 10px 22px;
	background: #2271b1;
	color: #fff;
	text-decoration: none;
	border-radius: 4px;
	font-weight: 600;
}

.wcpsv-buy-button:hover {
	background: #1a5a8a;
	color: #fff;
}

.wcpsv-sample-open {
	cursor: pointer;
}

.wcpsv-sample-modal {
	display: none;
	position: fixed;
	inset: 0;
	background: rgba(0, 0, 0, 0.65);
	z-index: 99999;
	align-items: center;
	justify-content: center;
	padding: 20px;
}

.wcpsv-sample-modal-inner {
	position: relative;
	background: #fff;
	width: 100%;
	max-width: 900px;
	max-height: 90vh;
	overflow-y: auto;
	border-radius: 8px;
	padding: 20px;
}

.wcpsv-sample-close {
	position: absolute;
	top: 10px;
	right: 10px;
	width: 32px;
	height: 32px;
	border: none;
	border-radius: 50%;
	background: #eee;
	font-size: 20px;
	line-height: 1;
	cursor: pointer;
	z-index: 2;
}

.wcpsv-sample-close:hover {
	background: #ddd;
}

@media (max-width: 600px) {
	.wcpsv-sample-modal-inner {
		max-height: 95vh;
		padding: 16px;
	}
}
