.makebead-app {
	max-width: 1100px;
	margin: 0 auto;
	font-family: inherit;
	display: flex;
	align-items: flex-start;
	gap: 16px;
}

body:has(.makebead-app[data-hide-title]) .wp-block-post-title,
body:has(.makebead-app[data-hide-title]) .entry-title,
body:has(.makebead-app[data-hide-title]) .page-title {
	display: none;
}

.makebead-toolbar {
	display: flex;
	flex-direction: column;
	flex: 0 0 190px;
	gap: 16px;
	padding: 10px;
	border: 1px solid #ddd;
	border-radius: 4px;
	background: #f5f5f5;
}

.makebead-main {
	flex: 1;
	min-width: 0;
	background: #a8a8a8;
	border: 1px solid #888;
	border-radius: 4px;
	padding: 20px;
}

.makebead-toolgroup {
	display: flex;
	flex-direction: column;
	align-items: stretch;
	gap: 6px;
}

.makebead-toolgroup-label {
	font-size: 0.75em;
	text-transform: uppercase;
	color: #777;
}

.makebead-toolgroup button {
	cursor: pointer;
	width: 100%;
	text-align: center;
}

.makebead-toolgroup button#makebead-save,
.makebead-toolgroup button#makebead-add-to-cart {
	padding: 8px 4px;
	font-weight: 600;
}

.makebead-toolgroup button#makebead-add-to-cart {
	background: #2f7d32;
	color: #fff;
	border-color: #2f7d32;
}

.makebead-toolgroup label {
	display: flex;
	justify-content: space-between;
	align-items: center;
	gap: 6px;
}

.makebead-toolgroup-row {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 4px;
}

button.makebead-icon-btn {
	width: 36px;
	height: 36px;
	flex: 0 0 auto;
	padding: 0;
	display: inline-flex;
	align-items: center;
	justify-content: center;
}

.makebead-icon-toolbar {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 4px;
	background: #f0f0f0;
	border: 1px solid #999;
	border-radius: 4px;
	padding: 6px;
	margin-bottom: 16px;
}

.makebead-icon-toolbar-sep {
	width: 1px;
	align-self: stretch;
	background: #bbb;
	margin: 2px 4px;
}

.makebead-icon-btn svg {
	display: block;
	pointer-events: none;
}

.makebead-icon-btn,
.makebead-bead-swatch {
	position: relative;
}

.makebead-icon-btn::after,
.makebead-bead-swatch::after {
	content: attr(data-tooltip);
	position: absolute;
	bottom: calc(100% + 7px);
	left: 50%;
	transform: translateX(-50%) translateY(4px);
	background: #222;
	color: #fff;
	font-size: 12px;
	line-height: 1.3;
	white-space: nowrap;
	padding: 4px 8px;
	border-radius: 4px;
	pointer-events: none;
	opacity: 0;
	visibility: hidden;
	transition: opacity 0.1s ease, transform 0.1s ease;
	z-index: 30;
}

.makebead-icon-btn:hover::after,
.makebead-icon-btn:focus-visible::after,
.makebead-bead-swatch:hover::after,
.makebead-bead-swatch:focus-visible::after {
	opacity: 1;
	visibility: visible;
	transform: translateX(-50%) translateY(0);
}

.makebead-app .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;
	width: 1px;
	word-wrap: normal !important;
}

.makebead-tool-btn.is-active {
	background: #333;
	color: #fff;
	border-color: #333;
}

button:disabled {
	opacity: 0.4;
	cursor: not-allowed;
}

.makebead-canvas-wrap {
	display: flex;
	justify-content: center;
	overflow: auto;
	max-width: 100%;
	padding: 4px;
}

.makebead-palette {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
}

.makebead-bead-swatch {
	width: 32px;
	height: 32px;
	border-radius: 50%;
	border: 2px solid transparent;
	cursor: grab;
	box-shadow: 0 0 2px rgba(0, 0, 0, 0.4) inset;
}

.makebead-bead-swatch.is-selected {
	border-color: #333;
}

.makebead-toolgroup input[type="number"] {
	width: 56px;
}

#makebead-eraser.is-selected {
	background: #333;
	color: #fff;
	border-color: #333;
}

.makebead-grid {
	display: inline-grid;
	gap: 1px;
	background: #ccc;
	border: 2px solid #fff;
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
	touch-action: none;
	user-select: none;
}

.makebead-cell {
	background: #fafafa;
	cursor: pointer;
	box-sizing: border-box;
}

.makebead-cell:hover {
	outline: 1px solid #999;
	outline-offset: -1px;
}

.makebead-modal-overlay {
	position: fixed;
	inset: 0;
	background: rgba(0, 0, 0, 0.5);
	display: flex;
	align-items: center;
	justify-content: center;
	z-index: 1000;
	padding: 20px;
}

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

.makebead-modal {
	background: #fff;
	border-radius: 6px;
	padding: 20px;
	width: 100%;
	max-width: 360px;
	max-height: 85vh;
	overflow-y: auto;
	box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

.makebead-modal-wide {
	max-width: 560px;
}

.makebead-modal h3 {
	margin-top: 0;
}

.makebead-modal input[type="text"] {
	width: 100%;
	box-sizing: border-box;
	padding: 8px;
	margin-bottom: 16px;
}

.makebead-modal-actions {
	display: flex;
	justify-content: flex-end;
	gap: 8px;
}

.makebead-load-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
	gap: 12px;
	margin-bottom: 16px;
	min-height: 60px;
}

.makebead-load-item {
	cursor: pointer;
	border: 1px solid #ddd;
	border-radius: 4px;
	padding: 8px;
	text-align: center;
	background: none;
	font: inherit;
}

.makebead-load-item:hover {
	border-color: #333;
	background: #f5f5f5;
}

.makebead-load-item img {
	width: 100%;
	height: 90px;
	object-fit: contain;
	background: #fafafa;
	border-radius: 3px;
	display: block;
	margin-bottom: 6px;
}

.makebead-load-item-title {
	display: block;
	font-size: 0.85em;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.makebead-load-empty {
	color: #777;
	grid-column: 1 / -1;
}

@media (max-width: 640px) {
	.makebead-app {
		flex-direction: column;
	}

	.makebead-toolbar {
		flex: 0 0 auto;
		width: 100%;
		flex-direction: row;
		flex-wrap: wrap;
	}

	.makebead-toolgroup {
		flex-direction: row;
		flex-wrap: wrap;
		width: auto;
	}

	.makebead-toolgroup button {
		width: auto;
	}

	.makebead-toolgroup-label {
		flex-basis: 100%;
	}
}
