* {
	box-sizing: border-box;
}

html, body {
	margin: 0;
	padding: 0;
	width: 100%;
	overflow-x: hidden; /* guard against any off-screen element widening the page */
}

body {
	background: #101114;
	color: #eee;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
	text-align: center;
	display: flex;
	flex-direction: column;
	align-items: center;
	padding: 32px 16px 60px;
}

h1 {
	margin: 0 0 8px;
	font-size: 22px;
	line-height: 1.3;
}

.subtitle {
	max-width: 560px;
	margin: 0 auto 24px;
	color: #aaa;
	font-size: 14px;
	line-height: 1.5;
}

.panel {
	width: 100%;
	max-width: 420px;
	display: flex;
	flex-direction: column;
	align-items: stretch;
	gap: 12px;
	background: #1a1c20;
	padding: 20px;
	border-radius: 10px;
	margin-bottom: 28px;
}

.file-label {
	background: #2c2f36;
	padding: 12px 16px;
	border-radius: 6px;
	cursor: pointer;
	font-size: 14px;
	text-align: center;
}

input[type="file"] {
	position: absolute;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip: rect(0 0 0 0);
	white-space: nowrap;
}

button {
	font-size: 15px;
	padding: 12px 20px;
	border: none;
	border-radius: 6px;
	background-color: #2a6df4;
	color: #fff;
	cursor: pointer;
	transition: background-color .15s, opacity .15s;
	width: 100%;
}

button:hover:not(:disabled) {
	background-color: #4884ff;
}

button:disabled {
	background-color: #3a3c42;
	color: #888;
	cursor: not-allowed;
}

#cancel-btn {
	background-color: #c0392b;
}

#cancel-btn:hover:not(:disabled) {
	background-color: #e74c3c;
}

.progress-wrap {
	width: 100%;
	display: flex;
	align-items: center;
	gap: 10px;
}

.progress-bar {
	flex: 1;
	height: 8px;
	background: #2c2f36;
	border-radius: 4px;
	overflow: hidden;
}

.progress-fill {
	height: 100%;
	width: 0%;
	background: #2a6df4;
	transition: width .1s linear;
}

.progress-label {
	font-size: 13px;
	color: #aaa;
	min-width: 38px;
	text-align: right;
}

.threshold-wrap {
	width: 100%;
	text-align: left;
}

.threshold-wrap label {
	display: block;
	font-size: 13px;
	color: #aaa;
	margin-bottom: 6px;
}

.threshold-row {
	display: flex;
	align-items: center;
	gap: 10px;
}

.threshold-row input[type="range"] {
	flex: 1;
	width: auto;
	accent-color: #2a6df4;
}

.threshold-value {
	font-size: 13px;
	color: #eee;
	min-width: 36px;
	text-align: right;
}

.status-label {
	width: 100%;
	font-size: 13px;
	color: #888;
	min-height: 16px;
}

/* the output canvas is only used as an off-screen drawing surface for the
   encoder (mediabunny reads it via drawImage/CanvasSource) - it never needs
   to be painted on screen, and painting a 1080x1920 canvas every frame was
   pure wasted GPU work, so it's fully removed from rendering here */
.preview-wrap,
#output-canvas {
	display: none;
}

/* source video is decoded off-screen but must stay "visible" (not display:none)
   so the browser keeps rendering frames; clip it instead of pushing it far
   off-canvas, which was widening the page and throwing layout off-center */
#source-video {
	position: absolute;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip: rect(0 0 0 0);
	white-space: nowrap;
}

@media (min-width: 480px) {
	.panel {
		flex-direction: row;
		flex-wrap: wrap;
		justify-content: center;
		align-items: center;
	}

	.file-label,
	button {
		width: auto;
	}

	.progress-wrap {
		width: 100%;
	}
}