/* ZDM Flipbook viewer */
.zdmfb {
	--zdmfb-bg: #2b2b2f;
	--zdmfb-accent: #ffffff;
	--zdmfb-bar: rgba(0, 0, 0, 0.28);
	position: relative;
	display: flex;
	flex-direction: column;
	width: 100%;
	margin: 0 auto 1.5em;
	background: var(--zdmfb-bg);
	border-radius: 6px;
	overflow: hidden;
	color: var(--zdmfb-accent);
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	font-size: 14px;
	line-height: 1.2;
	box-sizing: border-box;
	-webkit-tap-highlight-color: transparent;
}
.zdmfb *, .zdmfb *::before, .zdmfb *::after { box-sizing: border-box; }

.zdmfb-stage {
	position: relative;
	display: flex;
	align-items: center;
	justify-content: center;
	min-height: 320px;
	width: 100%;
	overflow: hidden;
}
.zdmfb--fixed .zdmfb-stage { height: var(--zdmfb-height, 600px); flex: none; }

.zdmfb-shell {
	position: relative;
	flex: none;
	transition: transform 0.45s ease;
	filter: drop-shadow(0 10px 24px rgba(0, 0, 0, 0.35));
}
.zdmfb-book { min-width: 0 !important; min-height: 0 !important; max-width: none !important; margin: 0; }
.zdmfb-book .stf__wrapper { height: 100%; padding-bottom: 0 !important; }

.zdmfb-page {
	background: #fff;
	overflow: hidden;
	user-select: none;
	-webkit-user-select: none;
}
.zdmfb-page:not(.is-rendered) {
	background: #fff linear-gradient(90deg, #f1f1f1 0, #fafafa 50%, #f1f1f1 100%);
	background-size: 200% 100%;
	animation: zdmfb-shimmer 1.4s linear infinite;
}
.zdmfb-img {
	position: absolute;
	inset: 0;
	display: block;
	width: 100% !important;
	height: 100% !important;
	max-width: none !important;
	margin: 0 !important;
	object-fit: contain;
	pointer-events: none;
	-webkit-user-drag: none;
	border: 0 !important;
	border-radius: 0 !important;
	box-shadow: none !important;
}
.zdmfb-img:not([src]) { visibility: hidden; }
.zdmfb-links { position: absolute; inset: 0; pointer-events: none; }
.zdmfb-link {
	position: absolute;
	display: block;
	pointer-events: auto;
	cursor: pointer;
	border-radius: 2px;
	transition: background-color 0.15s ease;
}
.zdmfb-link:hover, .zdmfb-link:focus-visible { background: rgba(255, 214, 0, 0.22); outline: none; }

/* Loading and errors */
.zdmfb-status {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 14px;
	padding: 40px 20px;
	text-align: center;
	opacity: 0.85;
}
.zdmfb-status p { margin: 0; color: inherit; }
.zdmfb-spinner {
	width: 34px;
	height: 34px;
	border: 3px solid currentColor;
	border-right-color: transparent;
	border-radius: 50%;
	animation: zdmfb-spin 0.8s linear infinite;
}
.zdmfb-fallback, .zdmfb-fallback:visited { color: inherit; text-decoration: underline; }

/* Buttons */
.zdmfb-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 40px;
	height: 40px;
	padding: 0;
	margin: 0;
	border: 0;
	border-radius: 6px;
	background: transparent;
	color: var(--zdmfb-accent);
	cursor: pointer;
	text-decoration: none;
	box-shadow: none;
	line-height: 1;
	transition: background-color 0.15s ease, opacity 0.15s ease;
}
.zdmfb-btn:hover, .zdmfb-btn:focus-visible { background: rgba(255, 255, 255, 0.14); color: var(--zdmfb-accent); outline: none; }
.zdmfb-btn:disabled { opacity: 0.3; cursor: default; background: transparent; }
.zdmfb-btn svg { display: block; }

.zdmfb-side {
	position: absolute;
	top: 50%;
	z-index: 5;
	width: 48px;
	height: 64px;
	margin-top: -32px;
	display: none;
}
.zdmfb-side svg { width: 30px; height: 30px; }
.zdmfb-side--prev { left: 8px; }
.zdmfb-side--next { right: 8px; }
.zdmfb--wide .zdmfb-side { display: inline-flex; }

/* Toolbar */
.zdmfb-bar {
	position: relative;
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 8px;
	flex-wrap: wrap;
	padding: 6px 10px;
	background: var(--zdmfb-bar);
}
.zdmfb-bar-group { display: flex; align-items: center; gap: 2px; }
.zdmfb-counter {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	margin: 0 6px;
	font-variant-numeric: tabular-nums;
	cursor: text;
}
.zdmfb .zdmfb-page-input {
	width: auto;
	min-width: 3.2em;
	height: 30px;
	margin: 0;
	padding: 0 6px;
	border: 1px solid rgba(255, 255, 255, 0.25);
	border-radius: 4px;
	background: rgba(0, 0, 0, 0.2);
	color: var(--zdmfb-accent);
	font: inherit;
	text-align: center;
	box-shadow: none;
}
.zdmfb .zdmfb-page-input:focus { border-color: var(--zdmfb-accent); outline: none; }
.zdmfb-total { opacity: 0.75; white-space: nowrap; }
.zdmfb-toast {
	position: absolute;
	left: 50%;
	bottom: calc(100% + 10px);
	transform: translate(-50%, 6px);
	padding: 8px 14px;
	border-radius: 20px;
	background: rgba(0, 0, 0, 0.8);
	color: #fff;
	font-size: 13px;
	white-space: nowrap;
	opacity: 0;
	pointer-events: none;
	transition: opacity 0.2s ease, transform 0.2s ease;
}
.zdmfb-toast.is-on { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 520px) {
	.zdmfb-hide-sm { display: none; }
	.zdmfb-bar { padding: 4px 6px; justify-content: center; row-gap: 0; }
	.zdmfb-btn { width: 38px; height: 38px; }
}

/* Full screen */
.zdmfb:fullscreen { width: 100%; height: 100%; margin: 0; border-radius: 0; }
.zdmfb:-webkit-full-screen { width: 100%; height: 100%; margin: 0; border-radius: 0; }
.zdmfb.is-fs {
	position: fixed;
	inset: 0;
	z-index: 2147483000;
	width: 100%;
	max-width: none !important;
	height: 100%;
	height: 100dvh;
	margin: 0;
	border-radius: 0;
}
.zdmfb:fullscreen .zdmfb-stage, .zdmfb.is-fs .zdmfb-stage { flex: 1 1 auto; height: auto !important; min-height: 0; }
.zdmfb:-webkit-full-screen .zdmfb-stage { flex: 1 1 auto; height: auto !important; min-height: 0; }
html.zdmfb-locked, html.zdmfb-locked body { overflow: hidden !important; }

/* Overlays */
.zdmfb-overlay {
	position: fixed;
	inset: 0;
	z-index: 1000000;
	display: flex;
	flex-direction: column;
	background: rgba(18, 18, 20, 0.97);
	color: var(--zdmfb-accent, #fff);
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	font-size: 14px;
}
.zdmfb-overlay * { box-sizing: border-box; }
.zdmfb-overlay .zdmfb-btn { color: var(--zdmfb-accent, #fff); }
.zdmfb-overlay-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	padding: 8px 10px 8px 18px;
	flex: none;
}
.zdmfb-overlay-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; opacity: 0.9; }
.zdmfb-overlay-body { flex: 1 1 auto; overflow: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.zdmfb-overlay--zoom .zdmfb-overlay-body { display: flex; cursor: grab; }
.zdmfb-overlay--zoom .zdmfb-overlay-body.is-dragging { cursor: grabbing; user-select: none; }
.zdmfb-zoom-inner { display: flex; margin: auto; padding: 16px; box-sizing: content-box; }
.zdmfb-zoom-img { display: block; flex: 1 1 0; min-width: 0; width: 100%; height: auto; max-width: none; background: #fff; box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5); }

.zdmfb-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
	gap: 22px 16px;
	max-width: 1280px;
	margin: 0 auto;
	padding: 12px 18px 40px;
}
@media (min-width: 900px) { .zdmfb-grid { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); } }
.zdmfb-thumb {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 8px;
	padding: 0;
	border: 0;
	background: none;
	color: inherit;
	font: inherit;
	cursor: pointer;
}
.zdmfb-thumb-frame {
	display: block;
	width: 100%;
	background: #fff linear-gradient(90deg, #ececec 0, #f8f8f8 50%, #ececec 100%);
	background-size: 200% 100%;
	box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4);
	outline: 3px solid transparent;
	outline-offset: 3px;
	transition: outline-color 0.15s ease, transform 0.15s ease;
}
.zdmfb-thumb-frame img { display: block; width: 100%; height: 100%; object-fit: contain; }
.zdmfb-thumb-frame img:not([src]) { visibility: hidden; }
.zdmfb-thumb:hover .zdmfb-thumb-frame, .zdmfb-thumb:focus-visible .zdmfb-thumb-frame { transform: translateY(-3px); outline-color: rgba(255, 255, 255, 0.5); }
.zdmfb-thumb:focus-visible { outline: none; }
.zdmfb-thumb.is-current .zdmfb-thumb-frame { outline-color: var(--zdmfb-accent, #fff); }
.zdmfb-thumb-num { font-size: 13px; opacity: 0.8; font-variant-numeric: tabular-nums; }

/* Reader page (share link) */
body.zdmfb-reader {
	margin: 0 !important;
	padding: 0 !important;
	height: 100vh;
	height: 100dvh;
	display: flex;
	flex-direction: column;
	overflow: hidden;
}
.zdmfb-reader-head {
	display: flex;
	align-items: center;
	gap: 16px;
	padding: 10px 18px;
	flex: none;
	color: #fff;
	background: rgba(0, 0, 0, 0.3);
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
.zdmfb-reader-site, .zdmfb-reader-site:visited { color: inherit; text-decoration: none; font-weight: 600; flex: none; }
.zdmfb-reader-logo { display: block; max-height: 34px; width: auto; }
.zdmfb-reader-title { margin: 0; font-size: 15px; font-weight: 500; line-height: 1.3; opacity: 0.85; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: inherit; }
.zdmfb-reader-main { flex: 1 1 auto; display: flex; min-height: 0; }
.zdmfb-reader-main .zdmfb { margin: 0; border-radius: 0; flex: 1 1 auto; height: 100%; }
.zdmfb--reader .zdmfb-stage { flex: 1 1 auto; min-height: 0; }
.zdmfb-reader-empty { margin: auto; color: #fff; }
body.zdmfb-reader.admin-bar { height: calc(100dvh - 32px); }
@media (max-width: 782px) { body.zdmfb-reader.admin-bar { height: calc(100dvh - 46px); } }

@keyframes zdmfb-spin { to { transform: rotate(360deg); } }
@keyframes zdmfb-shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) {
	.zdmfb-shell { transition: none; }
	.zdmfb-page:not(.is-rendered), .zdmfb-spinner { animation: none; }
}
