/* Place gallery viewer — scoped to #pd-gallery-modal and .tpl-place.pd-gallery-open */
body.tpl-place.pd-gallery-open { overflow: hidden; }

#pd-gallery-modal.pd-gallery-modal {
	background: #0f172a;
	border: 0;
	border-radius: 20px;
	box-shadow: 0 24px 60px rgba(15, 23, 42, .5);
	height: min(88dvh, 900px);
	max-height: none;
	max-width: 1140px;
	padding: 0;
	width: calc(100% - 48px);
}
#pd-gallery-modal.pd-gallery-modal::backdrop {
	background: rgba(15, 23, 42, .7);
	backdrop-filter: blur(6px);
}
#pd-gallery-modal.pd-gallery-modal [hidden] { display: none !important; }

.pd-gallery-modal .pd-gallery-modal-inner {
	display: flex;
	flex-direction: column;
	height: 100%;
	min-height: 0;
}

/* toolbar */
.pd-gallery-modal .pd-gallery-toolbar {
	align-items: center;
	background: #f8fafc;
	border-bottom: 1px solid #e2e8f0;
	display: flex;
	flex: 0 0 54px;
	gap: 12px;
	justify-content: space-between;
	padding: 0 16px;
}
.pd-gallery-modal .pd-gallery-toolbar-text { min-width: 0; }
.pd-gallery-modal .pd-gallery-modal-title {
	border: 0;
	color: #0f172a;
	font-size: 14px;
	font-weight: 700;
	margin: 0;
	padding: 0;
}
.pd-gallery-modal .pd-gallery-caption {
	color: #64748b;
	font-size: 12px;
	margin: 0;
	max-width: 60vw;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}
.pd-gallery-modal .pd-gallery-toolbar-side {
	align-items: center;
	display: flex;
	flex: 0 0 auto;
	gap: 12px;
}
.pd-gallery-modal .pd-gallery-counter { color: #64748b; font-size: 13px; font-weight: 600; }

.pd-gallery-modal .pd-gallery-btn,
.pd-gallery-modal .pd-gallery-nav {
	align-items: center;
	background: rgba(255, 255, 255, .12);
	border: 1px solid rgba(255, 255, 255, .2);
	border-radius: 50%;
	color: #f8fafc;
	cursor: pointer;
	display: inline-flex;
	font-size: 16px;
	height: 44px;
	justify-content: center;
	transition: background .15s ease;
	width: 44px;
}
.pd-gallery-modal .pd-gallery-btn {
	background: #e2e8f0;
	border-color: #cbd5e1;
	color: #0f172a;
}
.pd-gallery-modal .pd-gallery-btn:hover { background: #cbd5e1; }
.pd-gallery-modal .pd-gallery-nav:hover { background: rgba(255, 255, 255, .25); }
.pd-gallery-modal .pd-gallery-btn:focus-visible,
.pd-gallery-modal .pd-gallery-nav:focus-visible,
.pd-gallery-modal .pd-gallery-thumb:focus-visible {
	box-shadow: 0 0 0 3px rgba(0, 158, 224, .45);
	outline: none;
}

/* stage */
.pd-gallery-modal .pd-gallery-stage {
	align-items: center;
	display: flex;
	flex: 1;
	min-height: 0;
	position: relative;
}
.pd-gallery-modal .pd-gallery-figure {
	align-items: center;
	display: flex;
	flex: 1;
	height: 100%;
	justify-content: center;
	margin: 0;
	min-height: 0;
	min-width: 0;
	position: relative;
}
.pd-gallery-modal .pd-gallery-img {
	height: auto;
	max-height: 100%;
	max-width: 100%;
	object-fit: contain;
	width: auto;
}
.pd-gallery-modal .pd-gallery-status {
	color: #cbd5e1;
	font-size: 14px;
	left: 50%;
	position: absolute;
	top: 50%;
	transform: translate(-50%, -50%);
}
.pd-gallery-modal .pd-gallery-nav { position: absolute; top: 50%; transform: translateY(-50%); z-index: 2; }
.pd-gallery-modal .pd-gallery-nav-prev { left: 12px; }
.pd-gallery-modal .pd-gallery-nav-next { right: 12px; }

/* thumbs strip */
.pd-gallery-modal .pd-gallery-thumbs {
	background: #f8fafc;
	border-top: 1px solid #e2e8f0;
	display: flex;
	flex: 0 0 auto;
	gap: 8px;
	overflow-x: auto;
	padding: 10px 16px calc(10px + env(safe-area-inset-bottom, 0));
}
.pd-gallery-modal .pd-gallery-thumb {
	background: #e2e8f0;
	border: 2px solid transparent;
	border-radius: 8px;
	color: #64748b;
	cursor: pointer;
	flex: 0 0 60px;
	font-size: 12px;
	font-weight: 700;
	height: 60px;
	overflow: hidden;
	padding: 0;
}
.pd-gallery-modal .pd-gallery-thumb img { display: block; height: 100%; object-fit: cover; width: 100%; }
.pd-gallery-modal .pd-gallery-thumb.active { border-color: #009ee0; }

/* mobile: fullscreen */
@media (max-width: 640px) {
	#pd-gallery-modal.pd-gallery-modal {
		border-radius: 0;
		height: 100dvh;
		max-height: none;
		max-width: none;
		padding-bottom: env(safe-area-inset-bottom, 0);
		padding-top: env(safe-area-inset-top, 0);
		width: 100%;
	}
	.pd-gallery-modal .pd-gallery-thumb { flex-basis: 48px; height: 48px; }
	.pd-gallery-modal .pd-gallery-caption { max-width: 40vw; }
}
@media (prefers-reduced-motion: reduce) {
	.pd-gallery-modal .pd-gallery-btn,
	.pd-gallery-modal .pd-gallery-nav { transition: none; }
}
