/* DTF Gang Sheet Builder - editor (Phase 2) */
body.dtfgs-editor-open { overflow: hidden; }

.dtfgs-editor,
.dtfgs-editor * { box-sizing: border-box; }

.dtfgs-editor {
	position: fixed;
	inset: 0;
	z-index: 999999;
	display: flex;
	flex-direction: column;
	background: #f0f0f1;
	color: #1d2327;
	font: 14px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	--dtfgs-accent: #2271b1;
	--dtfgs-topbar-h: 56px;
}
.dtfgs-editor[hidden] { display: none; }
.dtfgs-editor canvas { max-width: none; }

/* Buttons */
.dtfgs-editor .dtfgs-btn {
	appearance: none;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 4px;
	min-width: 36px;
	height: 36px;
	padding: 0 12px;
	margin: 0;
	border: 1px solid #c3c4c7;
	border-radius: 6px;
	background: #fff;
	color: #1d2327;
	font: inherit;
	line-height: 1;
	cursor: pointer;
	white-space: nowrap;
	text-transform: none;
	letter-spacing: 0;
}
.dtfgs-editor .dtfgs-btn:hover:not(:disabled) { background: #f6f7f7; border-color: #8c8f94; }
.dtfgs-editor .dtfgs-btn:disabled { opacity: .4; cursor: default; }
.dtfgs-editor .dtfgs-btn:focus-visible,
.dtfgs-editor .dtfgs-tool:focus-visible { outline: 2px solid var(--dtfgs-accent); outline-offset: 1px; }
.dtfgs-editor .dtfgs-primary { background: var(--dtfgs-accent); border-color: var(--dtfgs-accent); color: #fff; font-weight: 600; }
.dtfgs-editor .dtfgs-primary:hover:not(:disabled) { background: #135e96; border-color: #135e96; }
.dtfgs-editor .dtfgs-danger { color: #b32d2e; }

/* Top bar */
.dtfgs-topbar {
	flex: 0 0 var(--dtfgs-topbar-h);
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 0 10px;
	background: #fff;
	border-bottom: 1px solid #dcdcde;
	overflow-x: auto;
	overflow-y: hidden;
}
.dtfgs-title { font-weight: 600; margin: 0 6px; }
.dtfgs-group { display: inline-flex; align-items: center; gap: 4px; }
.dtfgs-zoom { min-width: 48px; text-align: center; font-variant-numeric: tabular-nums; }
.dtfgs-spacer { flex: 1 1 auto; }
.dtfgs-only-narrow { display: none !important; }

/* Body layout */
.dtfgs-body {
	flex: 1 1 auto;
	min-height: 0;
	display: grid;
	grid-template-columns: 84px minmax(0, 1fr) 300px;
}

.dtfgs-tools {
	display: flex;
	flex-direction: column;
	gap: 6px;
	padding: 8px;
	background: #fff;
	border-right: 1px solid #dcdcde;
	overflow-y: auto;
}
.dtfgs-editor .dtfgs-tool {
	appearance: none;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 4px;
	width: 100%;
	padding: 10px 4px;
	margin: 0;
	border: 1px solid transparent;
	border-radius: 8px;
	background: transparent;
	color: #1d2327;
	font: inherit;
	font-size: 12px;
	cursor: pointer;
}
.dtfgs-editor .dtfgs-tool:hover { background: #f0f6fc; border-color: #c5d9ed; }
.dtfgs-ico { font-size: 22px; line-height: 1; }

.dtfgs-stage {
	position: relative;
	overflow: hidden;
	background: #dfe1e4;
	touch-action: none;
	cursor: default;
}
.dtfgs-stage .canvas-container { position: absolute !important; inset: 0; }
.dtfgs-stage.is-pan-ready { cursor: grab; }
.dtfgs-stage.is-panning { cursor: grabbing; }

.dtfgs-toast {
	position: absolute;
	left: 50%;
	bottom: 16px;
	transform: translateX(-50%);
	max-width: 90%;
	padding: 8px 14px;
	border-radius: 6px;
	background: #1d2327;
	color: #fff;
	pointer-events: none;
	z-index: 5;
}
.dtfgs-toast[hidden] { display: none; }

/* Right panel */
.dtfgs-panel {
	padding: 12px;
	background: #fff;
	border-left: 1px solid #dcdcde;
	overflow-y: auto;
}
.dtfgs-section { margin: 0 0 18px; }
.dtfgs-section[hidden] { display: none; }
.dtfgs-panel h3 { margin: 0 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: #50575e; }
.dtfgs-panel h4 { margin: 14px 0 6px; font-size: 12px; color: #50575e; }
.dtfgs-field { display: flex; flex-direction: column; gap: 3px; margin: 0 0 8px; font-size: 12px; color: #50575e; }
.dtfgs-field input,
.dtfgs-field select {
	width: 100%;
	height: 34px;
	margin: 0;
	padding: 4px 8px;
	border: 1px solid #8c8f94;
	border-radius: 4px;
	background: #fff;
	color: #1d2327;
	font: inherit;
}
.dtfgs-field input[type="color"] { padding: 2px; }
.dtfgs-grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }
.dtfgs-check { display: flex; align-items: center; gap: 8px; margin: 0 0 8px; }
.dtfgs-check input { margin: 0; width: 18px; height: 18px; }
.dtfgs-btnrow { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.dtfgs-btnrow .dtfgs-btn { padding: 0 6px; font-size: 12px; }
.dtfgs-price-row { display: flex; justify-content: space-between; align-items: baseline; margin: 10px 0 4px; font-size: 16px; }
.dtfgs-hint { margin: 4px 0; font-size: 12px; color: #646970; }
.dtfgs-hint p { margin: 0; }
.dtfgs-warn { margin: 8px 0 0; padding: 8px 10px; border-left: 3px solid #d63638; background: #fcf0f1; color: #8a2424; font-size: 12px; }
.dtfgs-warn[hidden] { display: none; }

/* Narrow screens: tools move to the bottom, properties become a slide-over drawer */
/* Uploads tray */
.dtfgs-tray {
	display: none;
	flex-direction: column;
	gap: 8px;
	padding: 12px;
	background: #fff;
	border-right: 1px solid #dcdcde;
	overflow-y: auto;
}
.dtfgs-editor.is-tray-open .dtfgs-tray { display: flex; }
.dtfgs-editor.is-tray-open .dtfgs-body { grid-template-columns: 84px 280px minmax(0, 1fr) 300px; }
.dtfgs-tray-head { display: flex; align-items: center; justify-content: space-between; }
.dtfgs-tray-head h3 { margin: 0; font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: #50575e; }
.dtfgs-tray .dtfgs-hint { margin: 0; }
.dtfgs-uploads { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.dtfgs-up { border: 1px solid #dcdcde; border-radius: 8px; padding: 8px; background: #fafafa; }
.dtfgs-up.is-error { border-color: #d63638; background: #fcf0f1; }
.dtfgs-up-main { display: flex; gap: 8px; align-items: center; }
.dtfgs-up-thumb {
	flex: 0 0 56px;
	width: 56px;
	height: 56px;
	object-fit: contain;
	border-radius: 4px;
	background: repeating-conic-gradient(#e4e4e4 0 25%, #fff 0 50%) 50% / 12px 12px;
	cursor: pointer;
}
.dtfgs-up-info { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.dtfgs-up-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dtfgs-up-meta { font-size: 11px; color: #646970; }
.dtfgs-up-actions { display: flex; align-items: center; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.dtfgs-up-actions label { display: flex; align-items: center; gap: 4px; font-size: 12px; color: #50575e; margin: 0; }
.dtfgs-up-actions input[type="number"] { width: 54px; height: 32px; padding: 2px 6px; border: 1px solid #8c8f94; border-radius: 4px; font: inherit; }
.dtfgs-editor .dtfgs-up-actions .dtfgs-btn { height: 32px; min-width: 32px; padding: 0 10px; font-size: 12px; }
.dtfgs-bar { height: 6px; margin-top: 8px; border-radius: 3px; background: #dcdcde; overflow: hidden; }
.dtfgs-bar > span { display: block; width: 0; height: 100%; background: var(--dtfgs-accent); transition: width .15s; }
.dtfgs-stage.is-drop::after,
.dtfgs-tray.is-drop::after {
	content: "";
	position: absolute;
	inset: 6px;
	border: 3px dashed var(--dtfgs-accent);
	border-radius: 10px;
	background: rgba(34, 113, 177, .08);
	pointer-events: none;
}
.dtfgs-tray.is-drop { position: relative; }

/* Resolution status */
.dtfgs-dpi { margin: 8px 0 0; padding: 6px 10px; border-left: 4px solid #8c8f94; background: #f6f7f7; font-size: 12px; }
.dtfgs-dpi[hidden] { display: none; }
.dtfgs-dpi.is-good, .dtfgs-dpi.is-vector { border-color: #00a32a; background: #edfaef; }
.dtfgs-dpi.is-ok { border-color: #dba617; background: #fcf9e8; }
.dtfgs-dpi.is-low { border-color: #d63638; background: #fcf0f1; }

@media (max-width: 900px) {
	.dtfgs-editor.is-tray-open .dtfgs-body { grid-template-columns: minmax(0, 1fr); }
	.dtfgs-tray {
		position: fixed;
		left: 0;
		right: 0;
		bottom: 78px;
		max-height: 55vh;
		z-index: 9;
		border-right: 0;
		border-top: 1px solid #dcdcde;
		box-shadow: 0 -4px 16px rgba(0, 0, 0, .2);
	}
	.dtfgs-only-narrow { display: inline-flex !important; }
	.dtfgs-title { display: none; }
	.dtfgs-body { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; }
	.dtfgs-stage { grid-row: 1; }
	.dtfgs-tools {
		grid-row: 2;
		flex-direction: row;
		justify-content: space-around;
		border-right: 0;
		border-top: 1px solid #dcdcde;
		padding: 6px;
		overflow-x: auto;
	}
	.dtfgs-editor .dtfgs-tool { flex: 1 0 64px; padding: 8px 2px; }
	.dtfgs-panel {
		position: fixed;
		top: var(--dtfgs-topbar-h);
		right: 0;
		bottom: 0;
		width: min(340px, 90vw);
		z-index: 10;
		box-shadow: -4px 0 16px rgba(0, 0, 0, .2);
		transform: translateX(105%);
		transition: transform .2s ease;
	}
	.dtfgs-editor.is-panel-open .dtfgs-panel { transform: none; }
}

@media (pointer: coarse) {
	.dtfgs-editor .dtfgs-btn { min-height: 44px; min-width: 44px; }
	.dtfgs-field input, .dtfgs-field select { height: 42px; font-size: 16px; }
}

/* Phase 4 */
.dtfgs-editor [hidden] { display: none !important; }
.dtfgs-field textarea {
	width: 100%;
	margin: 0;
	padding: 6px 8px;
	border: 1px solid #8c8f94;
	border-radius: 4px;
	background: #fff;
	color: #1d2327;
	font: inherit;
	resize: vertical;
}
.dtfgs-btnrow2 { grid-template-columns: repeat(2, 1fr); }
.dtfgs-editor .dtfgs-btn.is-on { background: var(--dtfgs-accent); border-color: var(--dtfgs-accent); color: #fff; }
.dtfgs-editor .dtfgs-wide { width: 100%; margin-top: 4px; }

/* Phase 5 */
.dtfgs-price-sub { font-size: 13px; color: #50575e; margin: 4px 0; }
.dtfgs-editor .dtfgs-primary:disabled { opacity: .6; }
