* {
	box-sizing: border-box;
}

html,
body {
	height: 100%;
	margin: 0;
	padding: 0;
	font-family: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
	color: #0f172a;
	background: #f8fafc;
}

/* Mobile-first responsive layout */
.app {
	display: flex;
	flex-direction: column;
	min-height: 100vh;
}

.sidebar {
	padding: 16px;
	background: #ffffff;
	border-bottom: 1px solid #e2e8f0;
	display: flex;
	flex-direction: column;
	gap: 12px;
	width: 100%;
	flex-shrink: 0;
}

.sidebar h1 {
	font-size: 1.25rem;
	margin: 0 0 8px;
}

.controls {
	display: flex;
	flex-direction: column;
	gap: 14px;
}

.buttons {
	display: flex;
	gap: 8px;
	margin-top: 16px;
}

.group {
	display: flex;
	flex-direction: column;
	gap: 6px;
}

label {
	font-size: 0.9rem;
	color: #334155;
	font-weight: 500;
}

input[type="range"] {
	width: 100%;
	height: 6px;
	border-radius: 3px;
	background: #e2e8f0;
	outline: none;
	-webkit-appearance: none;
}
	transition: opacity 0.2s;


input[type="range"]:disabled {
	opacity: 0.45;
	cursor: not-allowed;
	filter: grayscale(60%);
}
input[type="range"]::-webkit-slider-thumb {
	-webkit-appearance: none;
	appearance: none;
	width: 18px;
	height: 18px;
	border-radius: 50%;
	background: #0ea5e9;
	cursor: pointer;
}

input[type="range"]::-moz-range-thumb {
	width: 18px;
	height: 18px;
	border-radius: 50%;
	background: #0ea5e9;
	cursor: pointer;
	border: none;
}

button {
	padding: 10px 16px;
	border: 1px solid #cbd5e1;
	background: #ffffff;
	border-radius: 8px;
	cursor: pointer;
	font-weight: 600;
	font-size: 0.9rem;
	transition: all 0.2s ease;
	flex: 1;
}

button.primary {
	background: #0ea5e9;
	color: white;
	border-color: #0284c7;
}

button.primary:hover {
	background: #0284c7;
}

button.ghost {
	background: transparent;
}

button.ghost:hover {
	background: #f1f5f9;
}

button:disabled {
	opacity: 0.6;
	cursor: not-allowed;
}

.main {
	flex: 1;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 16px;
	overflow: hidden;
}

.canvas-container {
	width: 100%;
	height: 100%;
	display: flex;
	align-items: center;
	justify-content: center;
}

#defaultCanvas0 {
	border: 1px solid #e2e8f0;
	background: #ffffff;
	border-radius: 8px;
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

footer {
	color: #64748b;
	font-size: 0.8rem;
	text-align: center;
	margin-top: 16px;
	transition: color 0.2s, opacity 0.2s;
}

input[type="range"]:disabled + span,
input[type="range"]:disabled ~ label,
input[type="range"]:disabled ~ span,
label:has(+ input[type="range"]:disabled),
label:has(input[type="range"]:disabled) {
	color: #b0b6be !important;
	opacity: 0.7;
}

/* Desktop layout */
@media (min-width: 769px) {
	.app {
		flex-direction: row;
		height: 100vh;
	}

	.sidebar {
		width: 320px;
		flex-shrink: 0;
		border-bottom: none;
		border-right: 1px solid #e2e8f0;
		height: 100vh;
		overflow-y: auto;
	}

	.buttons {
		margin-top: auto;
	}

	.main {
		flex: 1;
		padding: 24px;
		height: 100vh;
		overflow: hidden;
	}

	footer {
		text-align: left;
	}
}

.app {
	display: grid;
	grid-template-columns: 320px 1fr;
	height: 100vh;
}

.sidebar {
	padding: 16px 14px;
	border-right: 1px solid #e2e8f0;
	background: #ffffff;
	display: flex;
	flex-direction: column;
	gap: 12px;
}

.sidebar h1 {
	font-size: 1.25rem;
	margin: 0 0 8px;
}

.controls {
	display: flex;
	flex-direction: column;
	gap: 14px;
	flex: 1; /* take available vertical space so buttons can sit at bottom */
}

.group {
	display: flex;
	flex-direction: column;
	gap: 6px;
}

label {
	font-size: 0.9rem;
	color: #334155;
}

input[type="range"] {
	width: 100%;
}

button {
	padding: 8px 10px;
	border: 1px solid #cbd5e1;
	background: #ffffff;
	border-radius: 8px;
	cursor: pointer;
	font-weight: 600;
}

button.primary {
	background: #0ea5e9;
	color: white;
	border-color: #0284c7;
}

button.primary:hover {
	background: #0284c7;
}

button.ghost {
	background: transparent;
}

button:disabled {
	opacity: 0.6;
	cursor: not-allowed;
}

/* Move Start/Reset buttons to the bottom of the controls column */
#toggleBtn,
#resetBtn {
	order: 1; /* ensure buttons come after all slider groups */
}

#toggleBtn {
	margin-top: auto; /* push the button block to the bottom */
}

footer {
	margin-top: auto;
	color: #64748b;
	font-size: 0.8rem;
}

.main {
	display: grid;
	place-items: center;
	overflow: hidden;
}

.canvas-container {
	width: 100%;
	height: 100%;
	display: grid;
	place-items: center;
}

/* Canvas should fit nicely */
#defaultCanvas0 {
	border: 1px dashed #cbd5e1;
	background: #ffffff;
}

/* Responsive layout: stack sidebar over canvas on small screens */
@media (max-width: 768px) {
	.app {
	grid-template-columns: 1fr;
	grid-template-rows: auto auto;
	height: auto; /* let the whole page scroll, no nested scroll areas */
	}

	.sidebar {
	border-right: none;
	border-bottom: 1px solid #e2e8f0;
	background: #ffffff;
	}

	.main {
	overflow: visible; /* no inner scroll; page scrolls instead */
	}

	.canvas-container {
	width: 100%;
	height: auto;
	}

	/* Make the canvas fit the screen width while preserving aspect */
		/* Canvas size is controlled in JS at setup time; do not scale via CSS on mobile */
}