:root {
	--bg-color: #1e1e24;
	--card-bg: #2a2a35;
	--text-color: #f5f5f7;
	--accent-color: #007aff;
	--highlight-color: #ff3b30;
	--pin-default: #444454;
	--pin-border: #636370;
	--toggle-on: #34c759;
}

body {
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	background-color: var(--bg-color);
	color: var(--text-color);
	margin: 0;
	padding: 20px;
	display: flex;
	flex-direction: column;
	align-items: center;
	min-height: 100vh;
	box-sizing: border-box;
}

header {
	margin-bottom: 25px;
	text-align: center;
}

h1 {
	margin: 0 0 5px 0;
	font-size: 2rem;
	color: #ffffff;
}

p {
	margin: 0;
	color: #a1a1a6;
}

/* Unified Top Interface Layout Wrapper */
.top-interface {
	display: flex;
	gap: 20px;
	width: 100%;
	max-width: 1100px;
	margin-bottom: 50px; /* Increased margin below the inputs/dashboard */
	z-index: 100;
}

/* Controls Dashboard (Left Panel) */
.dashboard {
	background-color: var(--card-bg);
	padding: 20px;
	border-radius: 16px;
	box-shadow: 0 4px 12px rgba(0,0,0,0.3);
	flex: 2;
	display: flex;
	flex-direction: column;
	gap: 15px;
}

.top-row {
	display: flex;
	flex-wrap: wrap;
	gap: 15px;
	align-items: center;
	justify-content: space-between;
}

.search-container {
	position: relative;
	flex: 1;
	min-width: 250px;
}

.search-box {
	width: 100%;
	padding: 12px 15px;
	font-size: 1rem;
	border-radius: 8px;
	border: 2px solid var(--pin-border);
	background-color: #141419;
	color: #ffffff;
	outline: none;
	box-sizing: border-box;
	transition: border-color 0.2s;
}

.search-box:focus {
	border-color: var(--accent-color);
}

.suggestions {
	position: absolute;
	top: 100%;
	left: 0;
	right: 0;
	background: var(--card-bg);
	border: 1px solid var(--pin-border);
	border-top: none;
	border-bottom-left-radius: 8px;
	border-bottom-right-radius: 8px;
	max-height: 180px;
	overflow-y: auto;
	z-index: 200;
	display: none;
	box-shadow: 0 4px 12px rgba(0,0,0,0.5);
}

.suggestion-item {
	padding: 8px 15px;
	cursor: pointer;
	transition: background 0.2s;
}

.suggestion-item:hover {
	background-color: var(--accent-color);
}

.action-buttons {
	display: flex;
	gap: 10px;
}

button {
	background-color: #141419;
	color: #ffffff;
	border: 2px solid var(--pin-border);
	padding: 12px 20px;
	font-size: 0.95rem;
	border-radius: 8px;
	cursor: pointer;
	font-weight: 500;
	transition: all 0.2s ease;
}

button:hover {
	border-color: var(--accent-color);
	background-color: #22222b;
}

/* Toggle Switches Row */
.toggles-row {
	display: flex;
	flex-wrap: wrap;
	gap: 12px;
	justify-content: flex-start;
	background: #141419;
	padding: 12px;
	border-radius: 8px;
}

.toggle-container {
	display: flex;
	align-items: center;
	gap: 8px;
	cursor: pointer;
	user-select: none;
	font-size: 0.85rem;
}

.toggle-switch {
	position: relative;
	width: 36px;
	height: 20px;
	background-color: var(--pin-default);
	border-radius: 10px;
	transition: background-color 0.2s;
}

.toggle-switch::after {
	content: '';
	position: absolute;
	width: 16px;
	height: 16px;
	border-radius: 50%;
	background-color: white;
	top: 2px;
	left: 2px;
	transition: transform 0.2s;
}

input[type="checkbox"] {
	display: none;
}

input[type="checkbox"]:checked + .toggle-switch {
	background-color: var(--toggle-on);
}

input[type="checkbox"]:checked + .toggle-switch::after {
	transform: translateX(16px);
}

/* Status Section (Right Panel) */
.info-panel {
	background-color: var(--card-bg);
	padding: 20px;
	border-radius: 16px;
	box-shadow: 0 4px 12px rgba(0,0,0,0.3);
	flex: 1;
	min-width: 280px;
	display: flex;
	flex-direction: column;
	justify-content: flex-start;
	border: 2px solid #3a3a4a;
	box-sizing: border-box;
}

.info-title {
	font-weight: bold;
	color: var(--accent-color);
	margin-bottom: 10px;
	text-transform: uppercase;
	font-size: 0.85rem;
	letter-spacing: 1px;
	border-bottom: 1px solid #3a3a4a;
	padding-bottom: 5px;
	text-align: center;
}

#infoContent {
	font-size: 0.95rem;
	line-height: 1.4;
	color: #e5e5ea;
}

/* Safe Layout Canvas Frame */
.board-perspective {
	position: relative;
	width: 100%;
	max-width: 1200px;
	height: 820px; /* Increased canvas height to handle larger pin structures during 90° turns */
	display: flex;
	align-items: center;
	justify-content: center;
	margin: 20px 0;
}

.board-container {
	display: flex;
	gap: 25px; /* Increased gap between individual header cards */
	justify-content: center;
	align-items: center;
	transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.1);
	transform-origin: center center;
}

.header-card {
	background-color: var(--card-bg);
	border-radius: 12px;
	padding: 15px;
	box-shadow: 0 6px 12px rgba(0,0,0,0.15);
	display: flex;
	flex-direction: column;
	align-items: center;
	transition: opacity 0.25s, transform 0.25s;
	opacity: 1;
}

.header-card.hidden {
	opacity: 0;
	transform: scale(0.8);
	pointer-events: none;
	position: absolute;
	visibility: hidden;
}

.header-card h3 {
	margin: 0 0 12px 0;
	font-size: 0.9rem;
	color: #ffffff;
	border-bottom: 2px solid var(--accent-color);
	padding-bottom: 6px;
	width: 100%;
	text-align: center;
}

/* Pin Grids - scaled to match larger pin sizes */
.pin-grid {
	display: grid;
	gap: 5px;
	padding: 8px;
	background-color: #141419;
	border-radius: 8px;
	border: 1px dashed var(--pin-border);
}

.morpho-grid { grid-template-columns: repeat(2, 40px); }
.arduino-grid { grid-template-columns: 40px; }

/* Larger, highly readable Pin Nodes */
.pin-node {
	width: 35px;        /* Increased from 26px */
	height: 35px;       /* Increased from 26px */
	border-radius: 50%;
	background-color: var(--pin-default);
	border: 2px solid var(--pin-border);
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 0.72rem;  /* Increased text size for easy parsing */
	font-weight: bold;
	color: #ffffff;
	cursor: pointer;
	user-select: none;
	transition: all 0.2s ease;
}

.pin-node:hover {
	transform: scale(1.15);
	background-color: var(--accent-color);
	border-color: #ffffff;
}

.pin-node.highlighted {
	background-color: var(--highlight-color);
	border-color: #ffffff;
	box-shadow: 0 0 0 0 rgba(255, 59, 48, 0.7);
	animation: pulse 1.2s infinite cubic-bezier(0.66, 0, 0, 1);
	transform: scale(1.2);
	z-index: 50;
}

@keyframes pulse {
	to { box-shadow: 0 0 0 14px rgba(255, 59, 48, 0); }
}

/* Responsive Breakpoint for Mobile/Small Screens */
@media (max-width: 820px) {
	.top-interface {
		flex-direction: column;
		margin-bottom: 30px;
	}
	.dashboard, .info-panel {
		width: 100%;
	}
	.board-perspective {
		height: auto;
	}
	.board-container {
		flex-direction: column;
		transform: none !important; /* Disables rotation engine tracking on cramped vertical screens */
	}
}