.i3dm-viewer {
	width: 100%;
	position: relative;
}

.i3dm-stage {
	position: relative;
	width: 100%;
	height: var(--i3dm-height, 640px);
	min-height: 280px;
	overflow: hidden;
	background: var(--i3dm-background, #f4f4f2);
	border-radius: inherit;
	/* One-finger drags rotate on both axes; retain native browser pinch zoom. */
	touch-action: pinch-zoom;
	user-select: none;
	-webkit-user-select: none;
	cursor: grab;
	isolation: isolate;
}

.i3dm-stage:active {
	cursor: grabbing;
}

.i3dm-stage.is-clickable {
	cursor: pointer;
}

.i3dm-stage:focus-visible {
	outline: 3px solid #2271b1;
	outline-offset: 3px;
}

.i3dm-canvas {
	display: block;
	width: 100%;
	height: 100%;
}

.i3dm-loading,
.i3dm-error {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 12px;
	padding: 24px;
	text-align: center;
	color: #1d2327;
	background: var(--i3dm-background, #f4f4f2);
	z-index: 3;
}

.i3dm-loading[hidden],
.i3dm-error[hidden] {
	display: none;
}

.i3dm-spinner {
	width: 24px;
	height: 24px;
	border: 3px solid rgba(0, 0, 0, 0.16);
	border-top-color: currentColor;
	border-radius: 50%;
	animation: i3dm-spin 0.8s linear infinite;
}

.i3dm-viewer .i3dm-label {
	position: absolute;
	left: 50%;
	bottom: 28px;
	transform: translate(-50%, 10px);
	opacity: 0;
	pointer-events: none;
	visibility: hidden;
	box-sizing: border-box;
	min-height: 44px;
	min-width: 44px;
	max-width: calc(100% - 32px);
	margin: 0;
	white-space: normal;
	overflow-wrap: anywhere;
	text-transform: none;
	text-decoration: none;
	cursor: pointer;
	padding: 9px 14px;
	border-radius: 999px;
	background: var(--i3dm-label-background, #1d2327);
	border: 1px solid var(--i3dm-label-border, #1d2327);
	box-shadow: 0 8px 30px rgba(0, 0, 0, 0.18);
	backdrop-filter: blur(8px);
	color: var(--i3dm-label-text, #ffffff);
	font: 600 14px/1.2 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
	letter-spacing: 0.01em;
	transition: opacity 160ms ease, transform 160ms ease;
	z-index: 2;
}

.i3dm-viewer .i3dm-label.is-visible {
	opacity: 1;
	visibility: visible;
	pointer-events: auto;
	transform: translate(-50%, 0);
}

.i3dm-viewer .i3dm-label:hover,
.i3dm-viewer .i3dm-label:focus {
	background: var(--i3dm-label-background, #1d2327);
	border-color: var(--i3dm-label-border, #1d2327);
	color: var(--i3dm-label-text, #ffffff);
}

.i3dm-viewer .i3dm-label:focus-visible {
	outline: 3px solid currentColor;
	outline-offset: 3px;
}

.i3dm-link-list {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	gap: 8px 20px;
	margin: 18px 0 0;
	padding: 0;
	list-style: none;
}

.i3dm-link-list a {
	font-weight: 600;
}

/* Match the critical inline rule: hide optional links from first paint,
   retaining keyboard access and revealing the list on an explicit error. */
.i3dm-viewer:not(.is-error) .i3dm-links-collapsible:not(:focus-within) {
	clip: rect(1px, 1px, 1px, 1px);
	clip-path: inset(50%);
	height: 1px;
	width: 1px;
	margin: -1px;
	overflow: hidden;
	position: absolute !important;
}

.i3dm-link-list a:focus-visible,
.i3dm-controls button:focus-visible {
	outline: 3px solid #2271b1;
	outline-offset: 3px;
}

.i3dm-controls {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	gap: 8px;
	margin-top: 12px;
}

.i3dm-controls[hidden],
.i3dm-controls button[hidden] {
	display: none;
}

.i3dm-controls button {
	min-width: 44px;
	min-height: 44px;
	padding: 8px 14px;
	border: 1px solid #c8c8c8;
	border-radius: 5px;
	background: #fff;
	color: #1d2327;
	font: 600 14px/1.4 system-ui, sans-serif;
	cursor: pointer;
}

.i3dm-noscript-links {
	display: flex;
	flex-wrap: wrap;
	gap: 8px 20px;
	padding-left: 20px;
}

.i3dm-viewer .screen-reader-text {
	border: 0;
	clip: rect(1px, 1px, 1px, 1px);
	clip-path: inset(50%);
	height: 1px;
	margin: -1px;
	overflow: hidden;
	padding: 0;
	position: absolute !important;
	width: 1px;
	word-wrap: normal !important;
}

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

@media (max-width: 767px) {
	.i3dm-stage {
		height: var(--i3dm-mobile-height, 480px);
	}

	.i3dm-viewer .i3dm-label {
		bottom: 18px;
	}
}

@media (prefers-reduced-motion: reduce) {
	.i3dm-spinner {
		animation: none;
	}

	.i3dm-viewer .i3dm-label {
		transition: none;
	}
}
