/**
 * Custom Product Designer Pro — customer designer.
 * Workbench palette: dark stage so the mockup carries the eye, warm paper panel for controls.
 */

.cpd-launcher {
	margin: 0 0 18px;
}

.cpd-launcher .cpd-launch-button {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	background: #16130f;
	color: #f7f3ec;
	border: 0;
	border-radius: 3px;
	padding: 13px 22px;
	font-size: 15px;
	font-weight: 600;
	line-height: 1.2;
	cursor: pointer;
	transition: background 0.15s ease;
}

.cpd-launcher .cpd-launch-button:hover,
.cpd-launcher .cpd-launch-button:focus-visible {
	background: #2c2620;
	color: #fff;
}

.cpd-launcher__saved {
	display: flex;
	align-items: center;
	gap: 12px;
	margin-top: 12px;
	padding: 10px;
	border: 1px solid #e3dbcd;
	border-radius: 4px;
	background: #faf7f2;
	max-width: 340px;
}

.cpd-launcher__thumb {
	width: 64px;
	height: 64px;
	object-fit: contain;
	background: #fff;
	border-radius: 3px;
}

.cpd-launcher__status {
	display: block;
	font-size: 14px;
	color: #1f1b16;
}

.cpd-launcher__edit,
.cpd-linkbtn {
	background: none;
	border: 0;
	padding: 0;
	color: #8a6524;
	font-size: 13px;
	text-decoration: underline;
	cursor: pointer;
}

.cpd-launcher__note {
	margin: 8px 0 0;
	font-size: 13px;
	color: #6b6157;
}

/* Modal shell ------------------------------------------------------------ */

.cpd-modal {
	position: fixed;
	inset: 0;
	z-index: 999999;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 24px;
}

.cpd-modal[hidden] {
	display: none;
}

.cpd-modal__backdrop {
	position: absolute;
	inset: 0;
	background: rgba(14, 12, 10, 0.72);
}

.cpd-modal__dialog {
	position: relative;
	display: flex;
	flex-direction: column;
	width: min(1180px, 100%);
	max-height: calc(100vh - 48px);
	background: #faf7f2;
	color: #1f1b16;
	border-radius: 6px;
	overflow: hidden;
	box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

.cpd-modal__head {
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	gap: 16px;
	padding: 18px 22px;
	border-bottom: 1px solid #e3dbcd;
}

.cpd-modal__eyebrow {
	margin: 0;
	font-size: 13px;
	color: #857a6c;
}

.cpd-modal__title {
	margin: 2px 0 0;
	font-size: 22px;
	line-height: 1.25;
	font-weight: 600;
	color: #1f1b16;
}

.cpd-modal__close {
	background: none;
	border: 0;
	font-size: 28px;
	line-height: 1;
	color: #6b6157;
	cursor: pointer;
	padding: 4px 8px;
}

.cpd-modal__body {
	display: grid;
	grid-template-columns: minmax(0, 1fr) 360px;
	gap: 0;
	flex: 1;
	min-height: 0;
}

/* Stage ------------------------------------------------------------------ */

.cpd-stage {
	display: flex;
	flex-direction: column;
	background: #16130f;
	padding: 20px;
	min-height: 0;
}

.cpd-stage__frame {
	position: relative;
	flex: 1;
	display: flex;
	align-items: center;
	justify-content: center;
	min-height: 0;
}

.cpd-stage__frame canvas {
	max-width: 100%;
	touch-action: none;
}

.cpd-stage__frame .canvas-container {
	margin: 0 auto;
}

.cpd-stage__loader {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	background: #16130f;
}

.cpd-stage__loader[hidden] {
	display: none;
}

.cpd-stage__loader span {
	width: 26px;
	height: 26px;
	border: 2px solid rgba(247, 243, 236, 0.25);
	border-top-color: #b8863b;
	border-radius: 50%;
	animation: cpd-spin 0.8s linear infinite;
}

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

@media (prefers-reduced-motion: reduce) {
	.cpd-stage__loader span {
		animation-duration: 3s;
	}
}

.cpd-stage__bar {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	padding-top: 16px;
}

.cpd-chip {
	background: rgba(247, 243, 236, 0.08);
	border: 1px solid rgba(247, 243, 236, 0.18);
	color: #e8e1d6;
	border-radius: 999px;
	padding: 7px 14px;
	font-size: 13px;
	cursor: pointer;
}

.cpd-chip:hover {
	background: rgba(247, 243, 236, 0.16);
}

.cpd-chip[aria-pressed="true"] {
	border-color: #b8863b;
	color: #f0d9ad;
}

.cpd-chip--danger:hover {
	background: rgba(160, 48, 40, 0.35);
	border-color: rgba(220, 120, 110, 0.6);
}

/* Controls --------------------------------------------------------------- */

.cpd-controls {
	overflow-y: auto;
	border-left: 1px solid #e3dbcd;
	background: #faf7f2;
	-webkit-overflow-scrolling: touch;
}

.cpd-panel {
	padding: 18px 20px;
	border-bottom: 1px solid #ece4d7;
}

.cpd-panel__title {
	margin: 0 0 12px;
	font-size: 15px;
	font-weight: 600;
	color: #1f1b16;
}

.cpd-field {
	margin-bottom: 14px;
}

.cpd-field:last-child {
	margin-bottom: 0;
}

.cpd-field label {
	display: block;
	font-size: 13px;
	color: #6b6157;
	margin-bottom: 5px;
}

.cpd-field--split {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 12px;
}

.cpd-field--row {
	display: flex;
	gap: 8px;
}

.cpd-modal input[type="text"],
.cpd-modal select {
	width: 100%;
	padding: 9px 10px;
	border: 1px solid #d9cfbe;
	border-radius: 3px;
	background: #fff;
	font-size: 14px;
	color: #1f1b16;
	box-sizing: border-box;
}

.cpd-modal input[type="range"] {
	width: 100%;
	accent-color: #b8863b;
}

.cpd-modal input[type="color"] {
	width: 38px;
	height: 32px;
	padding: 0;
	border: 1px solid #d9cfbe;
	border-radius: 3px;
	background: #fff;
	cursor: pointer;
}

.cpd-upload {
	display: block;
	border: 1px dashed #cbbda4;
	border-radius: 4px;
	padding: 18px;
	text-align: center;
	cursor: pointer;
	background: #fffdf9;
}

.cpd-upload:hover {
	border-color: #b8863b;
}

.cpd-upload__label {
	display: block;
	font-size: 14px;
	font-weight: 600;
}

.cpd-upload__hint {
	display: block;
	font-size: 12px;
	color: #857a6c;
	margin-top: 4px;
}

.cpd-upload input[type="file"] {
	position: absolute;
	width: 1px;
	height: 1px;
	opacity: 0;
	overflow: hidden;
}

.cpd-artwork-status {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 10px;
	margin-top: 10px;
	font-size: 13px;
	color: #4a423a;
}

.cpd-artwork-status[hidden] {
	display: none;
}

.cpd-swatches {
	display: flex;
	align-items: center;
	gap: 8px;
	flex-wrap: wrap;
}

.cpd-swatch {
	width: 28px;
	height: 28px;
	border-radius: 50%;
	border: 1px solid rgba(31, 27, 22, 0.2);
	cursor: pointer;
	padding: 0;
}

.cpd-swatch[aria-pressed="true"] {
	box-shadow: 0 0 0 2px #b8863b;
}

.cpd-btn {
	border: 0;
	border-radius: 3px;
	padding: 10px 16px;
	font-size: 14px;
	font-weight: 600;
	cursor: pointer;
	line-height: 1.2;
}

.cpd-btn--primary {
	background: #b8863b;
	color: #1a1611;
}

.cpd-btn--primary:hover {
	background: #a4762f;
}

.cpd-btn--primary[disabled] {
	opacity: 0.6;
	cursor: progress;
}

.cpd-btn--ghost {
	background: #fff;
	border: 1px solid #d9cfbe;
	color: #1f1b16;
}

.cpd-btn--ghost:hover {
	border-color: #b8863b;
}

.cpd-field .cpd-btn--ghost {
	margin-top: 8px;
}

.cpd-empty {
	margin: 0;
	font-size: 13px;
	color: #857a6c;
}

.cpd-layers {
	list-style: none;
	margin: 14px 0 0;
	padding: 0;
}

.cpd-layers li {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 8px;
	padding: 8px 10px;
	border: 1px solid #ece4d7;
	border-radius: 3px;
	margin-bottom: 6px;
	font-size: 13px;
	background: #fff;
	cursor: pointer;
}

.cpd-layers li.is-active {
	border-color: #b8863b;
	background: #fdf6e9;
}

/* Footer ----------------------------------------------------------------- */

.cpd-modal__foot {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 16px;
	padding: 14px 22px;
	border-top: 1px solid #e3dbcd;
	background: #f4efe6;
}

.cpd-message {
	margin: 0;
	font-size: 13px;
	color: #4a423a;
	min-height: 18px;
}

.cpd-message.is-error {
	color: #8c1d18;
}

.cpd-modal__actions {
	display: flex;
	gap: 10px;
	flex-shrink: 0;
}

.cpd-modal :focus-visible {
	outline: 2px solid #b8863b;
	outline-offset: 2px;
}

/* Responsive ------------------------------------------------------------- */

@media (max-width: 900px) {
	.cpd-modal {
		padding: 0;
	}

	.cpd-modal__dialog {
		width: 100%;
		max-height: 100vh;
		height: 100%;
		border-radius: 0;
	}

	.cpd-modal__body {
		grid-template-columns: minmax(0, 1fr);
		overflow-y: auto;
	}

	.cpd-stage {
		padding: 14px;
	}

	.cpd-stage__frame {
		min-height: 46vh;
	}

	.cpd-controls {
		border-left: 0;
		border-top: 1px solid #e3dbcd;
		overflow: visible;
	}

	.cpd-modal__foot {
		flex-direction: column;
		align-items: stretch;
	}

	.cpd-modal__actions .cpd-btn {
		flex: 1;
	}
}
