/* Grid overlay controls (Background Effects + Fx panel) */

.fi-grid-overlay {
	padding: 12px;
	border: 1px solid rgba(255, 255, 255, 0.07);
	border-radius: 12px;
	background: rgba(0, 0, 0, 0.18);
}

.fi-grid-overlay__head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 10px;
	margin-bottom: 12px;
}

.fi-grid-overlay__title {
	margin: 0;
	font-size: 0.68rem;
	font-weight: 600;
	letter-spacing: 0.06em;
	text-transform: uppercase;
	color: rgba(96, 165, 250, 0.92);
}

.fi-grid-overlay__group {
	display: flex;
	flex-direction: column;
	gap: 12px;
}

.fi-grid-overlay__group.is-disabled {
	opacity: 0.4;
	pointer-events: none;
}

.fi-grid-overlay__pattern {
	display: flex;
	align-items: center;
	gap: 10px;
	width: 100%;
	padding: 8px 10px;
	border: 1px solid rgba(255, 255, 255, 0.1);
	border-radius: 9px;
	background: rgba(20, 21, 24, 0.9);
	color: #f4f4f5;
	font: inherit;
	font-size: 0.78rem;
	font-weight: 500;
	cursor: pointer;
	transition: border-color 0.15s ease, background 0.15s ease;
}

.fi-grid-overlay__pattern:hover {
	border-color: rgba(255, 255, 255, 0.18);
	background: rgba(28, 29, 33, 0.95);
}

.fi-grid-overlay__pattern-thumb {
	flex: 0 0 28px;
	width: 28px;
	height: 28px;
	border-radius: 6px;
	border: 1px solid rgba(255, 255, 255, 0.12);
	background-color: rgba(22, 23, 28, 0.98);
	background-size: cover;
	background-repeat: no-repeat;
	background-position: center;
}

.fi-grid-overlay__pattern-label {
	flex: 1 1 auto;
	min-width: 0;
	text-align: left;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.fi-grid-overlay__pattern-add {
	flex: 0 0 auto;
	font-size: 1rem;
	line-height: 1;
	color: rgba(244, 244, 245, 0.55);
}

.fi-grid-overlay__colors {
	display: flex;
	align-items: center;
	gap: 10px;
}

.fi-grid-overlay__color {
	flex: 0 0 28px;
	width: 28px;
	height: 28px;
	padding: 0;
	border: 2px solid transparent;
	border-radius: 50%;
	cursor: pointer;
	transition: border-color 0.15s ease, transform 0.15s ease;
}

.fi-grid-overlay__color:hover {
	transform: scale(1.05);
}

.fi-grid-overlay__color.is-active {
	border-color: var(--xfp-accent, #2f6fed);
}

.fi-grid-overlay__color[data-fi-grid-color="white"] {
	background: #fff;
}

.fi-grid-overlay__color[data-fi-grid-color="black"] {
	background: #000;
}

.fi-grid-overlay__color[data-fi-grid-color="grey"] {
	background: #888;
}

.fi-grid-overlay__row {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 10px;
}

.fi-grid-overlay__row-label {
	font-size: 0.68rem;
	font-weight: 600;
	letter-spacing: 0.06em;
	text-transform: uppercase;
	color: rgba(244, 244, 245, 0.52);
}

.fi-grid-overlay__field {
	display: flex;
	flex-direction: column;
	gap: 6px;
}

.fi-grid-overlay__field-label {
	font-size: 0.68rem;
	font-weight: 600;
	letter-spacing: 0.06em;
	text-transform: uppercase;
	color: rgba(244, 244, 245, 0.52);
}

.fi-grid-overlay__select {
	position: relative;
}

.fi-grid-overlay__select::after {
	content: "";
	position: absolute;
	top: 50%;
	right: 12px;
	width: 8px;
	height: 8px;
	margin-top: -5px;
	border-right: 1.5px solid rgba(244, 244, 245, 0.55);
	border-bottom: 1.5px solid rgba(244, 244, 245, 0.55);
	transform: rotate(45deg);
	pointer-events: none;
}

.fi-grid-overlay__select select {
	width: 100%;
	height: 36px;
	padding: 0 30px 0 12px;
	border: 1px solid rgba(255, 255, 255, 0.1);
	border-radius: 9px;
	background: rgba(20, 21, 24, 0.9);
	color: #f4f4f5;
	font-size: 0.78rem;
	font-weight: 500;
	cursor: pointer;
	appearance: none;
	-webkit-appearance: none;
}

.fi-grid-overlay__select select:focus {
	outline: none;
	border-color: var(--xfp-accent, #2f6fed);
}

/* Pattern gallery modal — floating, draggable, no app blur */

.fi-grid-gallery {
	position: fixed;
	inset: 0;
	z-index: 5100;
	pointer-events: none;
}

.fi-grid-gallery[hidden] {
	display: none !important;
}

.fi-grid-gallery__dialog {
	position: fixed;
	left: 50%;
	top: 50%;
	z-index: 1;
	width: min(380px, calc(100vw - 32px));
	max-height: min(640px, calc(100vh - 48px));
	display: flex;
	flex-direction: column;
	border: 1px solid rgba(255, 255, 255, 0.12);
	border-radius: 14px;
	background: rgba(18, 19, 22, 0.98);
	box-shadow: 0 20px 48px rgba(0, 0, 0, 0.42);
	overflow: hidden;
	pointer-events: auto;
}

html.xfp-desktop .fi-grid-gallery__dialog,
.ls-app--desktop .fi-grid-gallery__dialog {
	top: calc(50% + (var(--ls-header-h, 44px) / 2));
}

html.xfp-desktop .fi-grid-gallery__dialog,
html.xfp-desktop .fi-grid-gallery__dialog *,
.ls-app--desktop .fi-grid-gallery__dialog,
.ls-app--desktop .fi-grid-gallery__dialog * {
	-webkit-app-region: no-drag;
}

.fi-grid-gallery__head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 10px;
	padding: 14px 16px;
	border-bottom: 1px solid rgba(255, 255, 255, 0.08);
	cursor: grab;
	user-select: none;
	touch-action: none;
}

.fi-grid-gallery__head.is-dragging {
	cursor: grabbing;
}

.fi-grid-gallery__title {
	margin: 0;
	font-size: 0.72rem;
	font-weight: 600;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	color: rgba(244, 244, 245, 0.88);
}

.fi-grid-gallery__close {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 28px;
	height: 28px;
	padding: 0;
	border: 0;
	border-radius: 8px;
	background: transparent;
	color: rgba(244, 244, 245, 0.65);
	cursor: pointer;
}

.fi-grid-gallery__close:hover {
	background: rgba(255, 255, 255, 0.06);
	color: #f4f4f5;
}

.fi-grid-gallery__grid {
	display: grid;
	grid-template-columns: repeat(3, minmax(0, 1fr));
	grid-auto-flow: row;
	gap: 8px;
	padding: 14px 16px;
	overflow-x: hidden;
	overflow-y: auto;
	flex: 1 1 auto;
	min-height: 0;
}

.fi-grid-gallery__item {
	position: relative;
	aspect-ratio: 1;
	padding: 0;
	border: 1px solid rgba(255, 255, 255, 0.1);
	border-radius: 8px;
	background-color: rgba(22, 23, 28, 0.98);
	background-size: cover;
	background-repeat: no-repeat;
	background-position: center;
	cursor: pointer;
	transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.fi-grid-gallery__item:hover {
	border-color: rgba(255, 255, 255, 0.22);
}

.fi-grid-gallery__item.is-active {
	border-color: var(--xfp-accent, #2f6fed);
	box-shadow: inset 0 0 0 1px rgba(47, 111, 237, 0.35);
}

.fi-grid-gallery__item.is-active::after {
	content: "";
	position: absolute;
	top: 4px;
	right: 4px;
	width: 14px;
	height: 14px;
	border-radius: 50%;
	background: var(--xfp-accent, #2f6fed);
	box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.9);
}

.fi-grid-gallery__foot {
	padding: 12px 16px 14px;
	border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.fi-grid-gallery__remove {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	padding: 8px 12px;
	border: 0;
	border-radius: 8px;
	background: transparent;
	color: rgba(244, 244, 245, 0.55);
	font: inherit;
	font-size: 0.76rem;
	font-weight: 500;
	cursor: pointer;
}

.fi-grid-gallery__remove:hover {
	color: #f4f4f5;
	background: rgba(255, 255, 255, 0.05);
}

.fi-fx-panel__section--grid {
	margin-top: 0;
}
