/* ========================================
   Layer Box — bottom-docked wide layout
   ======================================== */

.layers-component.wide {
	height: 130px;
	width: 100%;
	position: relative;
}

/* Resize handle at top edge of layer box */
.layer-box-resize-handle {
	position: absolute;
	top: -4px;
	left: 0;
	right: 0;
	height: 8px;
	cursor: ns-resize;
	z-index: 2;
	-webkit-tap-highlight-color: transparent;
}
.layer-box-resize-handle::after {
	content: "";
	display: block;
	width: 40px;
	height: 4px;
	margin: 2px auto 0;
	border-radius: 2px;
	background: rgba(0,0,0,0.25);
}

/* Close button */
.layer-box-close-btn {
	position: absolute;
	top: 2px;
	right: 2px;
	width: 28px;
	height: 28px;
	border: none;
	background: transparent;
	font-size: 18px;
	line-height: 1;
	cursor: pointer;
	color: inherit;
	padding: 0;
	z-index: 1;
	display: flex;
	align-items: center;
	justify-content: center;
	-webkit-tap-highlight-color: transparent;
	opacity: 0.6;
}
.layer-box-close-btn:hover,
.layer-box-close-btn:active {
	opacity: 1;
	background: rgba(0,0,0,0.1);
}

/* Toggle button to re-show the layer panel */
.layer-toggle-btn {
	font-size: 11px;
	padding: 4px 10px;
	margin: 2px 4px;
	cursor: pointer;
	min-height: 24px;
	border: 1px solid ButtonBorder;
	background: ButtonFace;
	color: ButtonText;
	-webkit-tap-highlight-color: transparent;
	flex: 0 0 auto;
}
.layer-toggle-btn:hover,
.layer-toggle-btn:active {
	background: Highlight;
	color: HighlightText;
}

/* Main layer box container */
.layer-box {
	display: flex;
	flex-direction: row;
	min-height: 0;
	flex: 1 1 auto;
	overflow: hidden;
	position: relative;
}

/* Left column: opacity + layer list (scrollable) */
.layer-box .layer-opacity-row {
	display: flex;
	align-items: center;
	padding: 2px 6px;
	gap: 4px;
	font-size: 11px;
	flex: 0 0 auto;
	min-height: 24px;
}

.layer-box .layer-opacity-row label {
	white-space: nowrap;
}

.layer-box .layer-opacity-row input[type="range"] {
	flex: 1 1 auto;
	min-width: 40px;
	min-height: 20px;
}

.layer-box .layer-opacity-row .opacity-value {
	width: 30px;
	text-align: right;
	font-size: 10px;
}

.layer-box .layer-list {
	flex: 1 1 auto;
	overflow-y: auto;
	overflow-x: hidden;
	-webkit-overflow-scrolling: touch;
	border: 1px inset;
	background: white;
	margin: 2px;
}

.layer-box .layer-row {
	display: flex;
	align-items: center;
	padding: 3px 6px;
	cursor: pointer;
	gap: 6px;
	border-bottom: 1px solid #ddd;
	min-height: 36px;
	user-select: none;
	-webkit-user-select: none;
	touch-action: none;
	position: relative;
}

.layer-box .layer-row:hover {
	background: #e8e8e8;
}

.layer-box .layer-row.active {
	background: Highlight;
	color: HighlightText;
}

/* Visual feedback during drag reorder */
.layer-box .layer-row.drag-over-above {
	border-top: 2px solid Highlight;
}
.layer-box .layer-row.drag-over-below {
	border-bottom: 2px solid Highlight;
}
.layer-box .layer-row.dragging {
	opacity: 0.4;
}

/* Visibility toggle: wrap checkbox in a larger touch target */
.layer-box .layer-row .layer-visibility-wrap {
	flex: 0 0 auto;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 28px;
	height: 28px;
	cursor: pointer;
	-webkit-tap-highlight-color: transparent;
}

.layer-box .layer-row .layer-visibility {
	cursor: pointer;
	width: 16px;
	height: 16px;
	margin: 0;
}

.layer-box .layer-row .layer-thumbnail {
	flex: 0 0 auto;
	width: 36px;
	height: 27px;
	border: 1px solid #999;
	background-image:
		linear-gradient(45deg, #ccc 25%, transparent 25%),
		linear-gradient(-45deg, #ccc 25%, transparent 25%),
		linear-gradient(45deg, transparent 75%, #ccc 75%),
		linear-gradient(-45deg, transparent 75%, #ccc 75%);
	background-size: 8px 8px;
	background-position: 0 0, 0 4px, 4px -4px, -4px 0;
	image-rendering: auto;
}

.layer-box .layer-row .layer-name {
	flex: 1 1 auto;
	font-size: 11px;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	min-width: 0;
	line-height: 1.4;
}

/* Rename button (replaces double-click) */
.layer-box .layer-row .layer-rename-btn {
	flex: 0 0 auto;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 24px;
	height: 24px;
	cursor: pointer;
	font-size: 12px;
	border: none;
	background: transparent;
	color: inherit;
	padding: 0;
	-webkit-tap-highlight-color: transparent;
	opacity: 0.5;
}
.layer-box .layer-row .layer-rename-btn:hover,
.layer-box .layer-row .layer-rename-btn:active {
	opacity: 1;
}
.layer-box .layer-row.active .layer-rename-btn {
	color: HighlightText;
}

.layer-box .layer-row .layer-name-input {
	font-size: 11px;
	border: 1px solid #000;
	padding: 2px 4px;
	width: 100%;
	box-sizing: border-box;
	min-height: 24px;
}

/* Action buttons — right side column in wide layout */
.layer-box .layer-actions {
	display: flex;
	flex-direction: column;
	gap: 2px;
	padding: 3px;
	flex: 0 0 auto;
	justify-content: flex-start;
}

.layer-box .layer-actions button {
	font-size: 10px;
	padding: 3px 6px;
	min-width: 0;
	min-height: 24px;
	white-space: nowrap;
}

/* ========================================
   Touch device enhancements
   ======================================== */

@media (pointer: coarse) {
	.layer-box-close-btn {
		width: 44px;
		height: 44px;
		font-size: 24px;
		top: 0;
		right: 0;
	}

	.layer-box-resize-handle {
		top: -8px;
		height: 16px;
	}
	.layer-box-resize-handle::after {
		width: 50px;
		height: 5px;
		margin-top: 5px;
	}

	.layer-toggle-btn {
		font-size: 14px;
		padding: 8px 14px;
		min-height: 36px;
	}

	.layer-box .layer-row {
		min-height: 44px;
		padding: 4px 8px;
		gap: 8px;
	}

	.layer-box .layer-row .layer-visibility-wrap {
		width: 40px;
		height: 40px;
	}

	.layer-box .layer-row .layer-visibility {
		width: 20px;
		height: 20px;
	}

	.layer-box .layer-row .layer-thumbnail {
		width: 44px;
		height: 33px;
	}

	.layer-box .layer-row .layer-name {
		font-size: 13px;
	}

	.layer-box .layer-row .layer-rename-btn {
		width: 40px;
		height: 40px;
		font-size: 16px;
		opacity: 0.7;
	}

	.layer-box .layer-actions button {
		font-size: 12px;
		padding: 4px 8px;
		min-height: 36px;
	}

	.layer-box .layer-opacity-row {
		min-height: 36px;
		padding: 4px 8px;
	}

	.layer-box .layer-opacity-row input[type="range"] {
		min-height: 28px;
	}

	.layers-component.wide {
		height: 150px;
	}
}

/* ========================================
   Enlarge UI mode
   ======================================== */

.enlarge-ui .layers-component.wide {
	height: 180px;
}

.enlarge-ui .layer-box .layer-row {
	min-height: 48px;
	padding: 6px 10px;
	gap: 10px;
}

.enlarge-ui .layer-box .layer-row .layer-visibility-wrap {
	width: 44px;
	height: 44px;
}

.enlarge-ui .layer-box .layer-row .layer-visibility {
	width: 22px;
	height: 22px;
}

.enlarge-ui .layer-box .layer-row .layer-thumbnail {
	width: 52px;
	height: 39px;
}

.enlarge-ui .layer-box .layer-row .layer-name {
	font-size: 1rem;
}

.enlarge-ui .layer-box .layer-row .layer-rename-btn {
	width: 44px;
	height: 44px;
	font-size: 1.2rem;
}

.enlarge-ui .layer-box .layer-row .layer-name-input {
	font-size: 1rem;
	min-height: 32px;
}

.enlarge-ui .layer-box .layer-actions button {
	font-size: 1rem;
	padding: 6px 10px;
	min-height: 40px;
}

.enlarge-ui .layer-box .layer-opacity-row {
	min-height: 40px;
	font-size: 1rem;
	padding: 6px 10px;
}

.enlarge-ui .layer-box .layer-opacity-row input[type="range"] {
	min-height: 28px;
}

.enlarge-ui .layer-box .layer-opacity-row .opacity-value {
	font-size: 0.9rem;
	width: 40px;
}
