.cpld-book-gallery {
	--cpld-book-gap: clamp(1.15rem, 2vw, 1.75rem);
	--cpld-book-border: var(--border, #e5e7eb);
	--cpld-book-muted: #4f625d;
	--cpld-book-surface: #ffffff;
	--cpld-book-surface-soft: var(--cpld-bg, #faf6ef);
	--cpld-book-text: var(--navy, #2b3646);
	--cpld-book-accent: var(--teal, #244744);
	--cpld-book-tab-border: var(--accent3, #f1d67c);
	--cpld-book-tab-active: var(--accent1, #7cc1a2);
	--cpld-book-tab-hover: var(--accent4, #bf5636);
	--cpld-book-tab-base: var(--dark, #0f2e2b);
	width: 100%;
	color: var(--cpld-book-text);
}

.cpld-book-gallery__tabs {
	display: flex;
	gap: 0;
	align-items: center;
	width: max-content;
	max-width: 100%;
	margin: 0 auto 1rem;
	padding: 0;
	overflow-x: auto;
	border-radius: var(--radius-pill, 999px);
	background: var(--cpld-book-tab-base);
	scrollbar-width: thin;
}

.cpld-book-gallery__tab {
	display: inline-flex;
	flex: 0 0 auto;
	gap: 0.45rem;
	align-items: center;
	justify-content: center;
	min-height: 2.45rem;
	padding: 0.55rem 0.9rem;
	border: 1px solid transparent;
	border-radius: 0;
	background: transparent;
	color: #fff !important;
	font: inherit;
	font-size: 0.95rem;
	line-height: 1.1;
	cursor: pointer;
	transition:
		background-color 140ms ease,
		border-color 140ms ease,
		color 140ms ease,
		box-shadow 140ms ease;
}



.cpld-book-gallery__tab:hover {
	color: #fff !important;
	background: var(--cpld-book-tab-hover);
}

.cpld-book-gallery__tab:focus-visible {
	outline: 3px solid var(--cpld-book-tab-border);
	outline-offset: -3px;
}

.cpld-book-gallery__tab.is-active {
	border-color: transparent;
	background: var(--cpld-book-tab-active);
	color: #111 !important;
	box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08);
}

.cpld-book-gallery__tab-label {
	font-weight: 700;
	white-space: nowrap;
}

.cpld-book-gallery__tab-count {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 1.45rem;
	height: 1.45rem;
	padding: 0 0.4rem;
	border-radius: 999px;
	background: var(--cpld-book-tab-border);
	color: #fff;
	font-size: 0.78rem;
	font-weight: 700;
	line-height: 1;
}

.cpld-book-gallery__tab.is-active .cpld-book-gallery__tab-count {
	background: rgba(255, 255, 255, 0.72);
	color: var(--cpld-book-tab-base);
}

.cpld-book-gallery__panel[hidden] {
	display: none;
}

.cpld-book-gallery__heading {
	margin: 0 0 0.8rem;
	font-size: clamp(1.35rem, 2.4vw, 1.8rem);
	line-height: 1.2;
}

.cpld-book-gallery__grid {
	display: grid;
	grid-template-columns: repeat(var(--cpld-book-columns, 4), minmax(0, 1fr));
	gap: var(--cpld-book-gap);
	align-items: stretch;
}

.cpld-book-card {
	min-width: 0;
	margin: 0;
}

.cpld-book-card__link {
	display: flex;
	height: 100%;
	flex-direction: column;
	color: inherit;
	text-decoration: none;
	border-radius: 0.55rem;
	outline-offset: 3px;
	transition:
		color 160ms ease,
		transform 160ms ease;
}

.cpld-book-card__link:hover {
	color: var(--cpld-book-accent);
	transform: translateY(-2px);
}

.cpld-book-card__link:focus-visible {
	outline: 3px solid rgba(15, 107, 153, 0.34);
}

.cpld-book-card__cover-wrap {
	aspect-ratio: 2 / 3;
	width: min(100%, 88%);
	margin-inline: auto;
	overflow: hidden;
	border: 1px solid rgba(16, 24, 40, 0.1);
	border-radius: 0.45rem;
	background: linear-gradient(180deg, #f8fafc 0%, #eef2f6 100%);
	box-shadow: 0 0.25rem 0.75rem rgba(16, 24, 40, 0.1);
}

.cpld-book-card__cover {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
}

.cpld-book-card__cover-missing {
	display: grid;
	height: 100%;
	place-items: center;
	padding: 1rem;
	color: var(--cpld-book-muted);
	font-size: 0.8rem;
	text-align: center;
}

.cpld-book-card__title {
	margin: 0.55rem 0 0;
	font-size: 0.98rem;
	font-weight: 700;
	line-height: 1.28;
	text-align: center;
	text-wrap: balance;
}

.cpld-book-card__author {
	margin: 0.15rem 0 0;
	color: var(--cpld-book-muted);
	font-size: 0.78rem;
	line-height: 1.25;
}

.cpld-book-gallery--battle {
	--cpld-book-gap: clamp(0.8rem, 1.4vw, 1.15rem);
}

.cpld-book-gallery--battle .cpld-book-gallery__grid {
	align-items: start;
}

.cpld-book-gallery--battle .cpld-book-card__cover-wrap {
	width: 100%;
	border-radius: 0.2rem;
	box-shadow: 0 0.18rem 0.45rem rgba(16, 24, 40, 0.08);
}

.cpld-book-gallery--battle .cpld-book-card__title {
	margin-top: 0.4rem;
	font-size: clamp(0.76rem, 1.2vw, 0.88rem);
	line-height: 1.2;
	text-align: center;
}

.cpld-book-gallery--battle .cpld-book-card__author {
	font-size: clamp(0.68rem, 1vw, 0.76rem);
	text-align: center;
}

.cpld-book-gallery__notice {
	padding: 1rem;
	border: 1px solid #c3c4c7;
	border-radius: 0.4rem;
	background: #fff;
}

.cpld-book-gallery .screen-reader-text {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

.cpld-book-gallery-editor__preview {
	padding: 1.5rem;
	border: 1px dashed #8c8f94;
	text-align: center;
}

.cpld-book-gallery-editor__preview code {
	display: block;
	overflow-wrap: anywhere;
}

@media (max-width: 900px) {
	.cpld-book-gallery__grid {
		grid-template-columns: repeat(3, minmax(0, 1fr));
	}
}

@media (max-width: 620px) {
	.cpld-book-gallery__tabs {
		display: flex;
		width: 100%;
		max-width: none;
		flex-direction: column;
		align-items: stretch;
		margin: 0 0 1rem;
		padding: 0;
		overflow: visible;
		border: 0;
		border-radius: 0;
		background: transparent;
	}

	.cpld-book-gallery__tab {
		justify-content: flex-start;
		min-height: 2.1rem;
		padding: 0.35rem 0;
		border: 0;
		border-radius: 0;
		background: transparent;
		color: var(--cpld-book-accent) !important;
		font-size: 0.9rem;
		text-align: left;
		text-decoration: underline;
		text-decoration-thickness: 1px;
		text-underline-offset: 0.18em;
	}

	.cpld-book-gallery__tab + .cpld-book-gallery__tab {
		border-left: 0;
	}

	.cpld-book-gallery__tab:hover,
	.cpld-book-gallery__tab.is-active {
		background: transparent;
		color: var(--cpld-book-tab-hover) !important;
		box-shadow: none;
	}

	.cpld-book-gallery__tab.is-active .cpld-book-gallery__tab-label {
		font-weight: 800;
	}

	.cpld-book-gallery__tab-count,
	.cpld-book-gallery__tab.is-active .cpld-book-gallery__tab-count {
		background: transparent;
		color: inherit;
		min-width: 0;
		height: auto;
		padding: 0;
		border-radius: 0;
		font-size: 0.85em;
	}

	.cpld-book-gallery__grid {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}
}

@media (prefers-reduced-motion: reduce) {
	.cpld-book-card__link,
	.cpld-book-gallery__tab {
		transition: none;
	}
}

.cpld-book-gallery-editor__file-controls {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem;
	margin-bottom: 0.75rem;
}

.cpld-book-gallery-editor__template {
	margin-bottom: 1rem;
	padding-bottom: 1rem;
	border-bottom: 1px solid #dcdcde;
}

.cpld-book-gallery-editor__template p {
	margin: 0 0 0.5rem;
}

.cpld-book-gallery-editor__filename {
	margin-top: 0;
	overflow-wrap: anywhere;
}

.cpld-book-gallery-editor__import-status {
	margin-bottom: 1rem;
}

.cpld-book-gallery-editor__import-status p {
	margin: 0 0 0.4rem;
}

.cpld-book-gallery-editor__progress {
	height: 0.4rem;
	overflow: hidden;
	border-radius: 999px;
	background: #dcdcde;
}

.cpld-book-gallery-editor__progress span {
	display: block;
	width: 40%;
	height: 100%;
	border-radius: inherit;
	background: #2271b1;
	animation: cpld-book-gallery-progress 1.1s ease-in-out infinite;
}

@keyframes cpld-book-gallery-progress {
	0% {
		transform: translateX(-110%);
	}

	100% {
		transform: translateX(260%);
	}
}

@media (prefers-reduced-motion: reduce) {
	.cpld-book-gallery-editor__progress span {
		width: 100%;
		animation: none;
	}
}

.cpld-book-gallery-editor__archive-export {
	margin-bottom: 1rem;
	padding: 0.75rem;
	border: 1px solid #dcdcde;
	border-radius: 0.25rem;
}

.cpld-book-gallery-editor__archive-export > p:first-child {
	margin-top: 0;
}

.cpld-book-gallery-editor__archive-actions {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem;
	margin-bottom: 0.75rem;
}

.cpld-book-gallery-editor__archive-export .components-notice {
	margin: 0;
}

.cpld-book-gallery-editor__empty {
	padding: 1rem;
	border: 1px dashed #8c8f94;
}

.cpld-book-gallery-editor__empty .components-button,
.cpld-book-gallery-editor__block-button {
	margin-top: 1rem;
}
