.agstsp-viewer {
	--agstsp-accent: #6d28d9;
	--agstsp-surface: #171717;
	--agstsp-border: rgba(255, 255, 255, 0.12);
	width: 100%;
	max-width: 1120px;
	margin: 24px auto;
	padding: 0;
	border: 1px solid var(--agstsp-border);
	border-radius: 14px;
	background: var(--agstsp-surface);
	overflow: hidden;
	-webkit-user-select: none;
	user-select: none;
}

.agstsp-viewer:focus-visible {
	outline: 3px solid color-mix(in srgb, var(--agstsp-accent) 65%, white);
	outline-offset: 3px;
}

.agstsp-viewer__header {
	position: sticky;
	top: 0;
	z-index: 3;
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 18px;
	padding: 14px 18px;
	border-bottom: 1px solid var(--agstsp-border);
	background: rgba(23, 23, 23, 0.96);
	backdrop-filter: blur(8px);
	color: #fff;
}

.agstsp-viewer__header strong {
	font-size: 15px;
	line-height: 1.4;
}

.agstsp-viewer__header span {
	flex: 0 0 auto;
	font-size: 12px;
	opacity: 0.7;
}

.agstsp-viewer__pages {
	display: grid;
	gap: 22px;
	padding: 22px;
}

.agstsp-page {
	position: relative;
	width: 100%;
	min-height: 280px;
	margin: 0;
	border-radius: 4px;
	background: #e7e7e7;
	box-shadow: 0 10px 32px rgba(0, 0, 0, 0.28);
	overflow: hidden;
	aspect-ratio: var(--agstsp-ratio, 1240 / 1754);
}

.agstsp-page img {
	display: block;
	position: relative;
	z-index: 2;
	width: 100%;
	height: auto;
	margin: 0;
	pointer-events: none;
	-webkit-user-drag: none;
}

.agstsp-page__loading {
	position: absolute;
	inset: 0;
	z-index: 1;
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 10px;
	padding: 20px;
	color: #4b5563;
	font-size: 13px;
	text-align: center;
}

.agstsp-page__loading span {
	width: 18px;
	height: 18px;
	border: 2px solid rgba(75, 85, 99, 0.2);
	border-top-color: var(--agstsp-accent);
	border-radius: 50%;
	animation: agstsp-spin 0.8s linear infinite;
}

.agstsp-page.is-loaded .agstsp-page__loading,
.agstsp-page.is-loaded figcaption {
	display: none;
}

.agstsp-page.has-error {
	aspect-ratio: auto;
	min-height: 180px;
}

.agstsp-page.has-error .agstsp-page__loading span {
	display: none;
}

.agstsp-page figcaption {
	position: absolute;
	right: 12px;
	bottom: 9px;
	z-index: 1;
	color: #6b7280;
	font-size: 11px;
}

.agstsp-viewer-message {
	margin: 18px 0;
	padding: 16px 18px;
	border: 1px solid rgba(109, 40, 217, 0.3);
	border-radius: 8px;
	background: rgba(109, 40, 217, 0.08);
	color: inherit;
}

@keyframes agstsp-spin {
	to { transform: rotate(360deg); }
}

@media (max-width: 680px) {
	.agstsp-viewer {
		margin: 14px auto;
		border-radius: 9px;
	}

	.agstsp-viewer__pages {
		gap: 12px;
		padding: 10px;
	}

	.agstsp-viewer__header {
		padding: 12px;
	}

	.agstsp-viewer__header span {
		display: none;
	}
}

@media print {
	.agstsp-viewer,
	.agstsp-viewer-message {
		display: none !important;
	}
}
