/* Three.js viewer-specific styles */
.viewer {
	width: min(900px, 95%);
	aspect-ratio: 3 / 4;
	max-height: 100%;
	margin: 0;
	position: relative;
	z-index: 0;
	filter: drop-shadow(0 4px 8px rgba(0,0,0,0.2));
	overflow: hidden; /* Clip zoomed canvas content to fit viewer */
}

/* Mobile: full width, topmost */
@media (max-width: 767px) {
	.viewer {
		width: 100%;
		max-width: 100%;
		max-height: 60vh;
		margin: 0;
	}
}

/* Tablet/Small Desktop */
@media (min-width: 768px) and (max-width: 1024px) {
	.viewer {
		width: min(600px, 90%);
		max-height: 100%;
	}
}

/* Medium Desktop */
@media (min-width: 1025px) and (max-width: 1280px) {
	.viewer {
		width: min(700px, 92%);
		max-height: 100%;
	}
}


.stage {
	position: relative;
	overflow: visible; /* Allow zoom lens to extend beyond stage */
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	width: 100%;
}

/* Mobile: stage adjustments */
@media (max-width: 767px) {
	.stage {
		width: 100%;
		order: 1;
		display: flex;
		flex-direction: column;
	}
}
.viewer canvas {
	position: absolute;
	inset: 0;
	width: 100% !important;
	height: 100% !important;
	display: block;
	object-fit: contain; /* Ensure canvas content fits within bounds */
}

.debug-toolbar {
	position: fixed;
	left: 16px;
	bottom: 16px;
	display: flex;
	gap: 8px;
	padding: 8px 10px;
	background: rgba(0,0,0,0.45);
	border: 1px solid rgba(255,255,255,0.18);
	border-radius: 10px;
	z-index: 9999;
}
.dbg-btn {
	background: rgba(255,255,255,0.9);
	color: #111;
	border: none;
	border-radius: 8px;
	padding: 8px 10px;
	cursor: pointer;
	font-weight: 700;
}
.dbg-btn:hover { background: #fff; }
.dbg-select {
	background: rgba(255,255,255,0.9);
	color: #111;
	border: none;
	border-radius: 8px;
	padding: 8px 10px;
	cursor: pointer;
	font-weight: 700;
	font-size: 13px;
}
.dbg-select:hover { background: #fff; }

.zoom-control {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 12px;
	margin-top: 16px;
	margin-left: auto;
	margin-right: auto;
	padding: 12px;
	background: rgba(255, 255, 255, 0.08);
	border: 1px solid rgba(255, 255, 255, 0.18);
	border-radius: 10px;
	max-width: 400px;
	width: 100%;
	box-sizing: border-box;
}

/* Mobile: zoom slider below viewer, full width */
@media (max-width: 767px) {
	.zoom-control {
		max-width: 100%;
		margin: 0;
		padding: 16px;
		border-radius: 0;
		border-left: none;
		border-right: none;
		background: rgba(0, 0, 0, 0.4);
		-webkit-backdrop-filter: blur(10px);
		backdrop-filter: blur(10px);
	}
}

.zoom-label {
	font-size: 14px;
	font-weight: 600;
	color: var(--text, #e9edf1);
	font-family: Orbitron, Inter, system-ui, sans-serif;
}

.zoom-slider {
	flex: 1;
	height: 6px;
	border-radius: 3px;
	background: rgba(255, 255, 255, 0.2);
	outline: none;
	-webkit-appearance: none;
	appearance: none;
}

.zoom-slider::-webkit-slider-thumb {
	-webkit-appearance: none;
	appearance: none;
	width: 18px;
	height: 18px;
	border-radius: 50%;
	background: var(--accent, #00d1ff);
	cursor: pointer;
	border: 2px solid rgba(255, 255, 255, 0.3);
	box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.zoom-slider::-moz-range-thumb {
	width: 18px;
	height: 18px;
	border-radius: 50%;
	background: var(--accent, #00d1ff);
	cursor: pointer;
	border: 2px solid rgba(255, 255, 255, 0.3);
	box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.zoom-value {
	font-size: 13px;
	font-weight: 700;
	color: var(--text, #e9edf1);
	min-width: 45px;
	text-align: right;
	font-family: Orbitron, Inter, system-ui, sans-serif;
}

.zoom-lens-control {
	position: absolute;
	right: calc(100% + 20px);
	top: 50%;
	transform: translateY(-50%);
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 8px;
	z-index: 100;
	pointer-events: auto;
}

.zoom-lens-control[hidden] {
	display: none !important;
}

/* When zoom-lens-control is sibling of viewer in stage, position it to the left of viewer */
.stage > .zoom-lens-control {
	right: auto;
	/* Position to the left of the viewer - desktop positioning */
	left: clamp(162px, calc((100% - min(900px, 85%)) / 2 - 16px), 100%);
	transform: translateX(-100%) translateY(-50%);
}

/* Medium/Large screens (max-width: 1200px) */
@media (max-width: 1200px) {
	.stage > .zoom-lens-control {
		left: clamp(129px, calc((100% - min(900px, 85%)) / 2 - 16px), 100%);
	}
}

/* Mobile/Tablet (max-width: 980px) */
@media (max-width: 980px) {
	.stage > .zoom-lens-control {
		left: clamp(20px, calc((100% - min(900px, 85%)) / 2 - 16px), 100%);
	}
}

/* Mobile: hide zoom lens control */
@media (max-width: 767px) {
	.zoom-lens-control {
		display: none !important;
	}
}

.zoom-lens {
	position: relative;
	width: 120px;
	height: 120px;
	cursor: grab;
	user-select: none;
}

.zoom-lens:active {
	cursor: grabbing;
}

.zoom-lens-svg {
	width: 100%;
	height: 100%;
	transform-origin: center;
	transition: transform 0.1s ease-out;
}

.zoom-lens-handle {
	position: absolute;
	top: 5px;
	left: 50%;
	width: 8px;
	height: 8px;
	background: var(--accent, #00d1ff);
	border-radius: 50%;
	box-shadow: 0 0 8px rgba(0, 209, 255, 0.6);
	pointer-events: none;
	transform-origin: center 60px;
}

.zoom-lens-label {
	font-size: 11px;
	font-weight: 600;
	color: var(--muted, #a7b0bb);
	text-align: center;
	font-family: Inter, system-ui, sans-serif;
}

.zoom-lens-colors {
	margin-top: 16px;
	padding: 12px;
	background: rgba(0, 0, 0, 0.4);
	-webkit-backdrop-filter: blur(10px);
	backdrop-filter: blur(10px);
	border: 1px solid rgba(255, 255, 255, 0.15);
	border-radius: 10px;
	width: 100%;
	min-width: 140px;
}

.zoom-color-item {
	display: flex;
	align-items: center;
	gap: 10px;
	margin-bottom: 10px;
}

.zoom-color-item:last-child {
	margin-bottom: 0;
}

.zoom-color-swatch {
	width: 32px;
	height: 32px;
	border-radius: 6px;
	border: 2px solid rgba(255, 255, 255, 0.2);
	flex-shrink: 0;
	box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.zoom-color-info {
	flex: 1;
	min-width: 0;
}

.zoom-color-name {
	font-size: 12px;
	font-weight: 700;
	color: var(--text, #e9edf1);
	font-family: Orbitron, Inter, system-ui, sans-serif;
	letter-spacing: 0.3px;
	margin-bottom: 2px;
}

.zoom-color-hex {
	font-size: 11px;
	font-weight: 600;
	color: var(--muted, #a7b0bb);
	font-family: 'Courier New', monospace;
	letter-spacing: 0.5px;
}

.color-harmony-indicator {
	margin-top: 12px;
	padding-top: 12px;
	border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.harmony-header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	margin-bottom: 6px;
}

.harmony-label {
	font-size: 11px;
	font-weight: 700;
	color: var(--text, #e9edf1);
	font-family: Orbitron, Inter, system-ui, sans-serif;
	letter-spacing: 0.5px;
}

.harmony-score {
	font-size: 12px;
	font-weight: 800;
	color: var(--accent, #00d1ff);
	font-family: Orbitron, Inter, system-ui, sans-serif;
}

.harmony-bar {
	width: 100%;
	height: 6px;
	background: rgba(255, 255, 255, 0.1);
	border-radius: 3px;
	overflow: hidden;
	margin-bottom: 6px;
}

.harmony-fill {
	height: 100%;
	background: linear-gradient(90deg, #ef4444 0%, #f59e0b 50%, #22c55e 100%);
	border-radius: 3px;
	transition: width 0.3s ease;
	width: 0%;
}

.harmony-type {
	font-size: 10px;
	font-weight: 600;
	color: var(--muted, #a7b0bb);
	font-family: Inter, system-ui, sans-serif;
	text-align: center;
	text-transform: uppercase;
	letter-spacing: 0.5px;
	position: relative;
	cursor: help;
}

.harmony-info-tooltip {
	position: absolute;
	bottom: 100%;
	left: 50%;
	transform: translateX(-50%);
	margin-bottom: 8px;
	padding: 8px 12px;
	background: rgba(0, 0, 0, 0.95);
	-webkit-backdrop-filter: blur(10px);
	backdrop-filter: blur(10px);
	border: 1px solid rgba(255, 255, 255, 0.2);
	border-radius: 8px;
	font-size: 11px;
	color: var(--text, #e9edf1);
	white-space: nowrap;
	opacity: 0;
	pointer-events: none;
	transition: opacity 0.2s ease;
	z-index: 10000;
	font-family: Inter, system-ui, sans-serif;
	line-height: 1.4;
	max-width: 200px;
	white-space: normal;
}

.harmony-type:hover .harmony-info-tooltip {
	opacity: 1;
}

.harmony-info-tooltip::after {
	content: '';
	position: absolute;
	top: 100%;
	left: 50%;
	transform: translateX(-50%);
	border: 6px solid transparent;
	border-top-color: rgba(0, 0, 0, 0.95);
}

.debug-color-controls {
	position: fixed;
	left: 16px;
	bottom: 16px;
	display: flex;
	flex-direction: column;
	gap: 12px;
	padding: 16px;
	background: rgba(0, 0, 0, 0.75);
	-webkit-backdrop-filter: blur(10px);
	backdrop-filter: blur(10px);
	border: 1px solid rgba(255, 255, 255, 0.18);
	border-radius: 10px;
	min-width: 280px;
	z-index: 1000;
	max-height: 80vh;
	overflow-y: auto;
	transition: transform 0.3s ease, opacity 0.3s ease;
}

/* Mobile: hide debug panel */
@media (max-width: 767px) {
	.debug-color-controls {
		display: none !important;
	}
}

.debug-color-controls.is-collapsed {
	transform: translateY(calc(100% - 50px));
}

.debug-color-controls.is-collapsed .debug-content {
	display: none;
}

.debug-toggle {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 8px;
	width: 100%;
	padding: 0;
	background: transparent;
	border: none;
	cursor: pointer;
	color: var(--text, #e9edf1);
}

.debug-title {
	margin: 0;
	font-size: 14px;
	font-weight: 700;
	color: var(--text, #e9edf1);
	font-family: Orbitron, Inter, system-ui, sans-serif;
	text-align: left;
}

.debug-toggle-icon {
	transition: transform 0.3s ease;
	flex-shrink: 0;
}

.debug-color-controls.is-collapsed .debug-toggle-icon {
	transform: rotate(180deg);
}

.debug-content {
	display: flex;
	flex-direction: column;
	gap: 12px;
	margin-top: 8px;
}

.debug-control-row {
	display: flex;
	align-items: center;
	gap: 12px;
}

.debug-color-picker-row {
	display: flex;
	align-items: center;
	gap: 12px;
	margin-bottom: 4px;
}

.debug-label {
	font-size: 12px;
	font-weight: 600;
	color: var(--text, #e9edf1);
	min-width: 100px;
	font-family: Inter, system-ui, sans-serif;
}

.debug-slider {
	flex: 1;
	height: 6px;
	border-radius: 3px;
	background: rgba(255, 255, 255, 0.2);
	outline: none;
	-webkit-appearance: none;
	appearance: none;
}

.debug-slider::-webkit-slider-thumb {
	-webkit-appearance: none;
	appearance: none;
	width: 16px;
	height: 16px;
	border-radius: 50%;
	background: var(--accent, #00d1ff);
	cursor: pointer;
	border: 2px solid rgba(255, 255, 255, 0.3);
	box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.debug-slider::-moz-range-thumb {
	width: 16px;
	height: 16px;
	border-radius: 50%;
	background: var(--accent, #00d1ff);
	cursor: pointer;
	border: 2px solid rgba(255, 255, 255, 0.3);
	box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.debug-select {
	flex: 1;
	padding: 6px 10px;
	border-radius: 6px;
	background: rgba(255, 255, 255, 0.15);
	border: 1px solid rgba(255, 255, 255, 0.2);
	color: var(--text, #e9edf1);
	font-size: 12px;
	font-weight: 600;
	font-family: Inter, system-ui, sans-serif;
	cursor: pointer;
	outline: none;
	-webkit-appearance: none;
	appearance: none;
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23e9edf1' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
	background-repeat: no-repeat;
	background-position: right 8px center;
	background-size: 12px;
	padding-right: 28px;
}

.debug-select:hover {
	background-color: rgba(255, 255, 255, 0.2);
	border-color: rgba(255, 255, 255, 0.3);
}

.debug-select:focus {
	border-color: var(--accent, #00d1ff);
	box-shadow: 0 0 0 2px rgba(0, 209, 255, 0.2);
}

.debug-value {
	font-size: 12px;
	font-weight: 700;
	color: var(--text, #e9edf1);
	min-width: 40px;
	text-align: right;
	font-family: Orbitron, Inter, system-ui, sans-serif;
}

.debug-color-picker {
	width: 50px;
	height: 32px;
	border: 2px solid rgba(255, 255, 255, 0.3);
	border-radius: 6px;
	cursor: pointer;
	background: transparent;
	-webkit-appearance: none;
	appearance: none;
}

.debug-color-picker::-webkit-color-swatch-wrapper {
	padding: 0;
}

.debug-color-picker::-webkit-color-swatch {
	border: none;
	border-radius: 4px;
}

.debug-color-picker::-moz-color-swatch {
	border: none;
	border-radius: 4px;
}


