body {
	background-color: #101010;
	color: #f0f0f0;
	margin: 0;
	display: flex;
	flex-direction: column;
	align-items: center;
	font-family: sans-serif;
	overflow-x: hidden;
	overflow-y: auto;
	min-height: 100vh;
	width: 100vw;
}

#viewport-container {
	height: 100vh;
	width: 100vw;
	display: flex;
	flex-direction: column;
	flex-shrink: 0;
}
#controls {
	padding: 10px;
	background: #1a1a1a;
	border-bottom: 1px solid #333;
	width: 100%;
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	gap: 15px;
	align-items: flex-start; /* Align items to top to handle different heights */
	box-sizing: border-box;
	z-index: 10;
	flex-shrink: 0;
}

.system-controls {
	border-right: 1px solid #333;
	padding-right: 15px;
	display: flex;
	flex-direction: column;
	gap: 5px;
}

.system-controls:last-child {
	border-right: none;
}

.global-controls {
	display: flex;
	flex-direction: column;
	gap: 5px;
	justify-content: center;
	height: 100%;
}

.control-group {
	display: flex;
	align-items: center;
	gap: 5px;
}

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

input[type="number"] {
	background: #333;
	border: 1px solid #444;
	color: #fff;
	padding: 4px;
	border-radius: 4px;
	width: 60px;
}

button {
	background: #333;
	color: #fff;
	border: 1px solid #444;
	padding: 5px 10px;
	border-radius: 4px;
	cursor: pointer;
	transition: background 0.2s;
}

button:hover {
	background: #444;
}

button.active {
	background: #50FF50;
	color: #101010;
	border-color: #50FF50;
}

#container {
	position: relative;
	flex-grow: 1;
	width: 100%;
	display: flex;
	justify-content: center;
	align-items: center;
	overflow: hidden; /* Ensure canvas stays within */
	min-height: 0; /* Important for flex items to shrink */
}

canvas {
	display: block;
	max-width: 100%;
	max-height: 100%;
}

.legend {
	position: absolute;
	top: 10px;
	left: 10px;
	background: rgba(0, 0, 0, 0.5);
	padding: 5px;
	border-radius: 4px;
	pointer-events: none;
	display: none;
}

.legend-item {
	display: flex;
	align-items: center;
	gap: 5px;
	font-size: 0.8rem;
	margin-bottom: 2px;
}

.color-box {
	width: 10px;
	height: 10px;
	display: inline-block;
	vertical-align: middle;
	margin-right: 5px;
}

.s1-bg { background-color: #50FF50; }
.s2-bg { background-color: #FF5050; }

#row-s1 { color: #50FF50; }
#row-s2 { color: #FF5050; }

#data-display {	width: 100%;
	background: #1a1a1a;
	border-top: 1px solid #333;
	padding: 10px;
	box-sizing: border-box;
	flex-shrink: 0;
	display: flex;
	justify-content: center;
}

table {
	border-collapse: collapse;
	width: 100%;
	max-width: 600px;
	font-size: 0.9rem;
	font-family: monospace;
}

th {
	text-align: left;
	padding: 5px 10px;
	color: #888;
	border-bottom: 1px solid #333;
}

td {
	padding: 5px 10px;
}

.s1-text { color: #50FF50; }
.s2-text { color: #FF5050; }

.system-title {
	font-size: 0.8rem;
	margin-bottom: 5px;
}

.initial-pos-group {
	margin-top: 5px;
}

.global-btn-group {
	margin-bottom: 5px;
}

.history-header {
	text-align: center;
}

#records-container {
	width: 100%;
	background: #1a1a1a;
	padding: 20px;
	box-sizing: border-box;
	display: flex;
	flex-direction: column;
	align-items: center;
	border-top: 2px solid #333;
}

.records-wrapper {
	display: flex;
	gap: 20px;
	width: 100%;
	max-width: 1200px;
	justify-content: center;
}

.record-table-container {
	flex: 1;
	max-height: 400px;
	overflow-y: auto;
	border: 1px solid #333;
	background: #101010;
}

.record-table {
	width: 100%;
	border-collapse: collapse;
	font-size: 0.85rem;
	font-family: monospace;
}

.record-table th {
	position: sticky;
	top: 0;
	background: #222;
	z-index: 1;
	padding: 8px;
	text-align: right;
	border-bottom: 2px solid #333;
}

.record-table td {
	padding: 6px 8px;
	text-align: right;
	border-bottom: 1px solid #222;
}

.record-table tr:hover {
	background: #1a1a1a;
	cursor: pointer;
}

.record-table tr.selected-row {
	background: #333;
	border-left: 3px solid #fff;
}

#formula-container {
	border-left: 1px solid #333;
	padding-left: 15px;
	display: flex;
	flex-direction: column;
	gap: 5px;
	align-items: center;
}

#formula-container h2 {
	margin: 0;
	color: #888;
	font-size: 0.75rem;
	text-transform: uppercase;
}

.formula-description {
	font-size: 0.7rem;
	color: #666;
	margin-top: 2px;
}

.equations {
	display: flex;
	flex-direction: column;
	gap: 2px;
	font-family: 'Times New Roman', Times, serif;
	font-size: 0.95rem;
	background: transparent;
	padding: 0;
	border-radius: 0;
	border: none;
}

.equation {
	letter-spacing: 0.5px;
}

.derivative { color: #aaa; }
.parameter { color: #50FF50; }
.variable { color: #fff; font-style: italic; }
