/*!
 * CSS Portal — CSS Grid Generator: layout editor and panel extras
 */
.gt [hidden] { display: none !important; }
.gd-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* layout presets as picture tiles */
#gridGenerator .gt-presets { grid-template-columns: repeat(3, minmax(0, 1fr)); }
#gridGenerator .gt-preset { flex-direction: column; align-items: stretch; height: auto; padding: 5px 5px 7px; gap: 5px; text-align: center; }
#gridGenerator .gt-preset__thumb { width: 100%; height: auto; aspect-ratio: 16 / 10; object-fit: contain; border-radius: 5px; }
#gridGenerator .gt-preset__swatch { display: none; }
#gridGenerator .gt-preset span:last-child { font-size: 12px; }

/* editor */
.gd-stage { padding: 22px 16px 16px 26px; background: var(--ct-surface); }
.gd-canvas {
	position: relative;
	display: grid;
	box-sizing: border-box;
	width: 100%;
	height: clamp(300px, 52vh, 480px);
	margin: 0;
	padding: 0;
	touch-action: none;
	user-select: none;
	-webkit-user-select: none;
	font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
	outline: none;
}
.gd-cell {
	position: relative;
	justify-self: stretch !important;
	align-self: stretch !important;
	min-width: 0;
	min-height: 24px;
	margin: 0;
	border: 1px dashed color-mix(in srgb, var(--ct-muted) 45%, transparent);
	border-radius: 4px;
	background: var(--ct-bg);
	cursor: crosshair;
}
.gd-cell:hover { background: var(--ct-accent-soft); border-color: var(--ct-accent); }
.gd-line { position: absolute; font: 600 10px/1 system-ui, sans-serif; font-style: normal; color: var(--ct-muted); pointer-events: none; }
.gd-line--c { top: -16px; left: -3px; }
.gd-line--r { left: -18px; top: -2px; }

.gd-item {
	--c: #6366f1;
	position: relative;
	z-index: 1;
	display: flex;
	align-items: center;
	justify-content: center;
	box-sizing: border-box;
	min-width: 28px;
	min-height: 28px;
	margin: 0;
	padding: 4px 8px;
	overflow: hidden;
	font-size: 13px;
	font-weight: 600;
	color: var(--ct-text);
	background: color-mix(in srgb, var(--c) 22%, var(--ct-bg));
	border: 2px solid var(--c);
	border-radius: 6px;
	cursor: grab;
}
.gd-item:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--ct-accent-soft), 0 0 0 5px var(--ct-accent); }
.gd-item.is-selected { background: color-mix(in srgb, var(--c) 38%, var(--ct-bg)); box-shadow: 0 0 0 3px color-mix(in srgb, var(--c) 35%, transparent); }
.gd-item.is-dragging { z-index: 3; opacity: .85; cursor: grabbing; box-shadow: 0 8px 24px rgba(15, 23, 42, .25); }
.gd-item__name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; pointer-events: none; }
.gd-item__del {
	position: absolute; top: 2px; right: 2px;
	display: none; place-items: center;
	width: 20px; height: 20px; margin: 0; padding: 0;
	font: 700 14px/1 system-ui, sans-serif; color: #fff;
	background: var(--c); border: 0; border-radius: 4px; cursor: pointer;
}
.gd-item__size {
	position: absolute; right: 0; bottom: 0;
	display: none; width: 18px; height: 18px;
	background: linear-gradient(135deg, transparent 50%, var(--c) 50%);
	cursor: nwse-resize;
}
.gd-item.is-selected .gd-item__del { display: grid; }
.gd-item.is-selected .gd-item__size { display: block; }
@media (hover: hover) { .gd-item:hover .gd-item__size { display: block; } }
.gd-ghost { z-index: 2; margin: 0; border: 2px dashed var(--ct-accent); border-radius: 6px; background: var(--ct-accent-soft); pointer-events: none; }
.gd-status { min-height: 1.4em; margin: 0; padding: 8px 16px 12px; font-size: 12.5px; color: var(--ct-muted); background: var(--ct-surface); }

/* panel extras */
.gd-tracks { display: grid; gap: 6px; }
.gd-tracks + .gd-tracks { margin-top: 10px; }
.gd-track { display: grid; grid-template-columns: 22px minmax(0, 1fr) minmax(0, 1.2fr) 32px; align-items: center; gap: 6px; }
.gd-track__n { font-size: 12px; font-weight: 600; color: var(--ct-muted); text-align: right; }
.gd-track input, .gd-track select, .gd-num input { min-width: 0; height: 32px; }
.gd-track__del { justify-content: center; width: 32px; height: 32px; padding: 0; }
.gd-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.gd-row select { flex: 1 1 140px; min-width: 0; height: 34px; }
.gd-grid4, .gd-grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 10px; }
.gd-num { display: grid; gap: 4px; margin: 0; font-size: 12.5px; font-weight: 600; color: var(--ct-text); }
.gd-danger { color: var(--ct-err, #dc2626); }
.gt .ct-tool:disabled { opacity: .45; pointer-events: none; }
.gt-custom input[type="number"], .gt-custom input[type="text"] {
	box-sizing: border-box; width: 100%; height: 34px; padding: 0 8px;
	font: inherit; font-size: 13px; color: var(--ct-text);
	background: var(--ct-bg); border: 1px solid var(--ct-border); border-radius: 8px; outline: none;
}
.gt-custom input:focus { border-color: var(--ct-accent); box-shadow: 0 0 0 3px var(--ct-accent-soft); }
.gt-custom input:disabled { opacity: .5; }
.gt-custom .gd-track select { padding-left: 8px; padding-right: 24px; background-position: right 7px center; }
.gd-card-head p { margin: 0; font-size: 12.5px; color: var(--ct-muted); }
