* { box-sizing: border-box; }

html, body {
	margin: 0;
	padding: 0;
	height: 100%;
	font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
	color: #fff;
	background: #000;
}

.app {
	display: flex;
	flex-direction: column;
	height: 100vh;
	width: 100vw;
	overflow: hidden;
}

/* Header */
header {
	background: rgba(0, 0, 0, 0.85);
	backdrop-filter: blur(10px);
	-webkit-backdrop-filter: blur(10px);
	border-bottom: 1px solid rgba(255, 255, 255, 0.08);
	flex: 0 0 auto;
	z-index: 10;
}

.header-row {
	display: flex;
	align-items: center;
	padding: 12px 24px;
}

.header-title {
	font-size: 22px;
	font-weight: 500;
	letter-spacing: 1px;
	margin: 0;
}

.spacer { flex: 1; }

.nav { display: flex; align-items: center; }

.nav-link {
	font-size: 14px;
	font-weight: 500;
	padding: 6px 14px;
	color: white;
	text-decoration: none;
	border-radius: 4px;
	margin: 0 2px;
	transition: background 0.2s;
}

.nav-link:hover { background: rgba(255, 255, 255, 0.12); }

.nav-link.current {
	opacity: 0.55;
	pointer-events: none;
	background: rgba(255, 255, 255, 0.06);
}

/* Main layout: side panel + canvas stage */
.layout {
	display: flex;
	flex: 1 1 auto;
	min-height: 0;
}

.panel {
	width: 300px;
	flex: 0 0 300px;
	background: rgba(20, 20, 24, 0.95);
	border-right: 1px solid rgba(255, 255, 255, 0.06);
	overflow-y: auto;
	padding: 16px;
}

.panel-toggle {
	display: none;
	background: transparent;
	color: white;
	border: 1px solid rgba(255, 255, 255, 0.2);
	border-radius: 4px;
	padding: 6px 10px;
	cursor: pointer;
	margin-bottom: 12px;
}

.panel-section {
	border-bottom: 1px solid rgba(255, 255, 255, 0.06);
	padding: 12px 0;
}
.panel-section:first-child { padding-top: 0; }
.panel-section:last-child { border-bottom: none; }

.panel-section h3 {
	margin: 0 0 10px 0;
	font-size: 13px;
	font-weight: 600;
	letter-spacing: 0.7px;
	text-transform: uppercase;
	color: rgba(255, 255, 255, 0.65);
}

.panel-section.help p {
	margin: 0 0 6px 0;
	font-size: 12px;
	color: rgba(255, 255, 255, 0.5);
}

.control { margin-bottom: 10px; }
.control:last-child { margin-bottom: 0; }

.control label {
	display: block;
	margin-bottom: 4px;
	font-size: 12px;
	color: rgba(255, 255, 255, 0.75);
}

.control.inline {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 10px;
}
.control.inline label {
	margin: 0;
	flex: 1;
}

.row {
	display: flex;
	gap: 6px;
	margin-bottom: 6px;
}
.row:last-child { margin-bottom: 0; }
.row .btn { flex: 1; }

input[type="number"],
input[type="color"],
input[type="range"] {
	width: 100%;
	box-sizing: border-box;
	font-family: inherit;
}

input[type="number"] {
	background: rgba(0, 0, 0, 0.4);
	border: 1px solid rgba(255, 255, 255, 0.15);
	border-radius: 4px;
	color: white;
	padding: 6px 8px;
	font-size: 14px;
}
input[type="number"]:focus {
	outline: none;
	border-color: #4dabf7;
	box-shadow: 0 0 0 2px rgba(77, 171, 247, 0.15);
}

input[type="color"] {
	height: 30px;
	width: 60px;
	background: transparent;
	border: 1px solid rgba(255, 255, 255, 0.15);
	border-radius: 4px;
	cursor: pointer;
	padding: 2px;
}

input[type="range"] {
	-webkit-appearance: none;
	background: transparent;
	height: 24px;
}
input[type="range"]::-webkit-slider-runnable-track {
	height: 4px;
	background: rgba(255, 255, 255, 0.15);
	border-radius: 2px;
}
input[type="range"]::-moz-range-track {
	height: 4px;
	background: rgba(255, 255, 255, 0.15);
	border-radius: 2px;
}
input[type="range"]::-webkit-slider-thumb {
	-webkit-appearance: none;
	height: 14px;
	width: 14px;
	border-radius: 50%;
	background: #4dabf7;
	margin-top: -5px;
	cursor: pointer;
}
input[type="range"]::-moz-range-thumb {
	height: 14px;
	width: 14px;
	border-radius: 50%;
	background: #4dabf7;
	border: none;
	cursor: pointer;
}

input[type="checkbox"] {
	accent-color: #4dabf7;
	cursor: pointer;
}

/* Buttons */
.btn {
	background: rgba(255, 255, 255, 0.08);
	color: white;
	border: 1px solid rgba(255, 255, 255, 0.15);
	padding: 8px 12px;
	border-radius: 4px;
	font-size: 13px;
	font-weight: 500;
	font-family: inherit;
	cursor: pointer;
	transition: background 0.15s, border-color 0.15s;
}
.btn:hover:not(:disabled) {
	background: rgba(255, 255, 255, 0.14);
}
.btn:active:not(:disabled) {
	background: rgba(255, 255, 255, 0.2);
}
.btn:disabled {
	opacity: 0.4;
	cursor: not-allowed;
}
.btn.primary {
	background: #4dabf7;
	border-color: #4dabf7;
}
.btn.primary:hover:not(:disabled) {
	background: #74c0fc;
	border-color: #74c0fc;
}
.btn.small {
	padding: 6px 10px;
	font-size: 12px;
}

/* Segmented controls */
.seg {
	display: flex;
	background: rgba(0, 0, 0, 0.4);
	border: 1px solid rgba(255, 255, 255, 0.12);
	border-radius: 4px;
	overflow: hidden;
}
.seg-btn {
	flex: 1;
	background: transparent;
	color: rgba(255, 255, 255, 0.7);
	border: none;
	border-right: 1px solid rgba(255, 255, 255, 0.08);
	padding: 6px 8px;
	font-size: 12px;
	font-family: inherit;
	cursor: pointer;
	transition: background 0.15s, color 0.15s;
}
.seg-btn:last-child { border-right: none; }
.seg-btn:hover { background: rgba(255, 255, 255, 0.06); color: white; }
.seg-btn.active {
	background: #4dabf7;
	color: white;
}

/* Arm rows */
.arm-row {
	background: rgba(255, 255, 255, 0.04);
	border: 1px solid rgba(255, 255, 255, 0.08);
	border-radius: 4px;
	padding: 8px;
	margin-bottom: 8px;
}
.arm-row:last-child { margin-bottom: 0; }
.arm-row-header {
	font-size: 11px;
	font-weight: 600;
	color: rgba(255, 255, 255, 0.5);
	letter-spacing: 0.5px;
	margin-bottom: 6px;
}
.arm-field {
	display: flex;
	align-items: center;
	gap: 8px;
	margin-bottom: 4px;
}
.arm-field:last-child { margin-bottom: 0; }
.arm-field label {
	width: 50px;
	font-size: 11px;
	color: rgba(255, 255, 255, 0.6);
}
.arm-field input[type="number"] {
	width: 60px;
	flex: 0 0 60px;
	font-size: 12px;
	padding: 4px 6px;
}
.arm-field input[type="range"] {
	flex: 1;
}
.arm-field .val {
	width: 32px;
	font-size: 11px;
	color: rgba(255, 255, 255, 0.55);
	text-align: right;
}

.gcd-hint {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 8px;
	margin-top: 8px;
	padding: 8px 10px;
	background: rgba(255, 196, 80, 0.1);
	border: 1px solid rgba(255, 196, 80, 0.3);
	border-radius: 4px;
	font-size: 12px;
	color: rgba(255, 220, 160, 0.9);
}

.gcd-hint[hidden] { display: none; }

/* Stage and canvases */
.stage {
	flex: 1 1 auto;
	position: relative;
	background: #000;
	overflow: hidden;
	min-width: 0;
}

.stage canvas {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	display: block;
}
#trail { z-index: 1; }
#overlay { z-index: 2; pointer-events: none; }

/* About / 404 page */
.about-page { background: #000; }
.about-page main { overflow: auto; flex: 1 1 auto; min-height: 0; }
.about-page .layout { display: block; }

.page-content {
	padding: 32px 24px;
	max-width: 800px;
	margin: 0 auto;
}
.card {
	background: rgba(255, 255, 255, 0.05);
	border: 1px solid rgba(255, 255, 255, 0.08);
	border-radius: 8px;
}
.card-content {
	padding: 24px 28px;
	line-height: 1.6;
}
.card-content h2 {
	margin: 24px 0 8px 0;
	font-size: 18px;
	color: #74c0fc;
}
.card-content h2:first-child { margin-top: 0; }
.card-content p { margin: 0 0 12px 0; color: rgba(255, 255, 255, 0.85); }
.card-content pre {
	background: rgba(0, 0, 0, 0.5);
	border: 1px solid rgba(255, 255, 255, 0.08);
	padding: 12px 14px;
	border-radius: 4px;
	font-size: 13px;
	overflow-x: auto;
	color: #c8e6ff;
}
.page-message { text-align: center; padding: 48px 24px; }
.page-message h2 { margin: 0 0 12px 0; }
.page-message p { margin: 0 0 20px 0; }

/* Responsive */
@media (max-width: 768px) {
	.panel-toggle { display: block; }
	.panel {
		position: absolute;
		top: 0; bottom: 0; left: 0;
		z-index: 5;
		transform: translateX(-100%);
		transition: transform 0.25s;
		width: 280px;
		max-width: 80vw;
	}
	.panel.open { transform: translateX(0); }
	.stage .panel-toggle-floating {
		position: absolute;
		top: 12px;
		left: 12px;
		z-index: 4;
	}
}
